Skip to content

Commit

Permalink
Merge #48
Browse files Browse the repository at this point in the history
48: define Artifacts.toml file at top-level, use artifacts"" macro r=charleskawczynski a=simonbyrne



Co-authored-by: Simon Byrne <simonbyrne@gmail.com>
  • Loading branch information
bors[bot] and simonbyrne authored May 19, 2023
2 parents f68dc14 + 68c19a6 commit f2ba81e
Show file tree
Hide file tree
Showing 13 changed files with 24 additions and 72,038 deletions.
6 changes: 6 additions & 0 deletions Artifacts.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[orb_params_dataset]
git-tree-sha1 = "4fda5e46a91c2a0cf12c9b46dad3a4189ebcfb37"

[[orb_params_dataset.download]]
sha256 = "652d52f3b311c4df65052287b1cb4f0be0b996aba130c9a5b42183cb5bba59dc"
url = "https://caltech.box.com/shared/static/hibf8tlxjujbqy5qa65tad2ved184otc.gz"
5 changes: 2 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
name = "Insolation"
uuid = "e98cc03f-d57e-4e3c-b70c-8d51efe9e0d8"
authors = ["Climate Modeling Alliance"]
version = "0.5.0"
version = "0.6.0"

[deps]
ArtifactWrappers = "a14bc488-3040-4b00-9dc1-f6467924858a"
Artifacts = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab"
Interpolations = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59"

[compat]
ArtifactWrappers = "0.2"
Interpolations = "0.13, 0.14"
julia = "1.7, 1.8"
2 changes: 0 additions & 2 deletions data/Artifacts.toml

This file was deleted.

72,002 changes: 0 additions & 72,002 deletions data/INSOL.LA2004.BTL.csv

This file was deleted.

8 changes: 4 additions & 4 deletions docs/src/InsolationExamples.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ include("plot_diurnal_cycle.jl")
lat, lon = [34.15, -118.14]
date = DateTime(2020, 01, 10)
timezone = +8 # Pacific Standard Time
od = Insolation.OrbitalData(Insolation.datadir())
od = Insolation.OrbitalData()
diurnal_cycle(lat, lon, date, od, timezone, "Pasadena_January.png")
# Finland in June
Expand All @@ -37,7 +37,7 @@ include("plot_insolation.jl")
γ0 = IP.obliq_epoch(param_set)
ϖ0 = IP.lon_perihelion_epoch(param_set)
e0 = IP.eccentricity_epoch(param_set)
od = Insolation.OrbitalData(Insolation.datadir())
od = Insolation.OrbitalData()
days, lats, F0 = calc_day_lat_insolation(od, 365, 180, param_set)
title = format("γ = {:.2f}°, ϖ = {:.2f}°, e = {:.2f}", rad2deg(γ0), rad2deg(ϖ0), e0) #hide
Expand All @@ -58,7 +58,7 @@ include("plot_insolation.jl") # hide
γ0 = IP.obliq_epoch(param_set) # hide
ϖ0 = IP.lon_perihelion_epoch(param_set) # hide
e0 = IP.eccentricity_epoch(param_set) # hide
od = Insolation.OrbitalData(Insolation.datadir())
od = Insolation.OrbitalData()
days, lats, F0 = calc_day_lat_insolation(od, 365, 180, param_set) # hide
# decrease γ to 20.0°
Expand Down Expand Up @@ -87,7 +87,7 @@ include("plot_insolation.jl") # hide
γ0 = IP.obliq_epoch(param_set) # hide
ϖ0 = IP.lon_perihelion_epoch(param_set) # hide
e0 = IP.eccentricity_epoch(param_set) # hide
od = Insolation.OrbitalData(Insolation.datadir())
od = Insolation.OrbitalData()
days, lats, F0 = calc_day_lat_insolation(od, 365, 180, param_set) # hide
# now change obliquity to 97.86°
Expand Down
6 changes: 3 additions & 3 deletions docs/src/Milankovitch.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using Insolation
using Plots
od = Insolation.OrbitalData(Insolation.datadir())
od = Insolation.OrbitalData()
dt = collect(-500e3:100:500e3); # years
y = hcat(collect.(orbital_params.(Ref(od), dt))...);
ϖ, γ, e = y[1,:], y[2,:], y[3,:];
Expand All @@ -32,7 +32,7 @@ include("find_equinox_perihelion_dates.jl")
years = 1800:2200;
days_eq = zeros(length(years));
days_per = zeros(length(years));
od = Insolation.OrbitalData(Insolation.datadir())
od = Insolation.OrbitalData()
for (i,year) in enumerate(years)
f = (x -> zdiff(x, year, od))
days_eq[i] = find_zeros(f,-30,60)[1]
Expand Down Expand Up @@ -62,7 +62,7 @@ The Gregorian calendar was introduced (with leap years and leap centuries) preci
```@example
using Roots
include("find_equinox_perihelion_dates.jl")
od = Insolation.OrbitalData(Insolation.datadir())
od = Insolation.OrbitalData()
years = -50e3:100:30e3
days_eq = zeros(length(years))
for (i,year) in enumerate(years)
Expand Down
21 changes: 3 additions & 18 deletions src/Insolation.jl
Original file line number Diff line number Diff line change
@@ -1,29 +1,14 @@
module Insolation

using Dates, DelimitedFiles, Interpolations
import ArtifactWrappers as AW
using Artifacts

include("Parameters.jl")
import .Parameters as IP
const AIP = IP.AbstractInsolationParams

export orbital_params

#= For test/docs use only =#
datadir() = joinpath(dirname(@__DIR__), "data")

function orbital_parameters_dataset_path(artifact_dir)
orb_params_dataset = AW.ArtifactWrapper(
artifact_dir,
"orb_params_dataset",
AW.ArtifactFile[AW.ArtifactFile(
url = "https://caltech.box.com/shared/static/3y02smnlxhgwednm3eho7lve2xhq1n7r.csv",
filename = "INSOL.LA2004.BTL.csv",
),],
)
return AW.get_data_folder(orb_params_dataset)
end

"""
OrbitalData
Expand All @@ -39,8 +24,8 @@ struct OrbitalData{E, G, O}
e_spline_etp::E
γ_spline_etp::G
ϖ_spline_etp::O
function OrbitalData(artifact_dir)
datapath = joinpath(orbital_parameters_dataset_path(artifact_dir), "INSOL.LA2004.BTL.csv");
function OrbitalData()
datapath = joinpath(artifact"orb_params_dataset", "INSOL.LA2004.BTL.csv");
x, _ = readdlm(datapath, ',', Float64, header=true);
t_range = x[1,1]*1e3 : 1e3 : x[end,1]*1e3; # array of every 1 kyr to range of years
e_spline_etp = CubicSplineInterpolation(t_range, x[:,2], extrapolation_bc = NaN);
Expand Down
2 changes: 1 addition & 1 deletion test/test_equinox.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function xtomarchdate(x, year)
return basedate + deltat
end

od = Insolation.OrbitalData(Insolation.datadir())
od = Insolation.OrbitalData()
days = zeros(length(1900:2100))
for (i,year) in enumerate(1900:2100)
f = (x -> zdiff(x, year, od))
Expand Down
2 changes: 1 addition & 1 deletion test/test_insolation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ atol = 1e-4
rtol = 1e-2
rtol_insol = 0.1

od = Insolation.OrbitalData(Insolation.datadir())
od = Insolation.OrbitalData()
## Test zero insolation at night
# sunrise at equator
date = Dates.DateTime(2020, 1, 1, 6, 0, 0)
Expand Down
2 changes: 1 addition & 1 deletion test/test_orbit_param.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
rtol = 1e-2
od = Insolation.OrbitalData(Insolation.datadir())
od = Insolation.OrbitalData()
@test mod(Insolation.ϖ_spline(od, 0.0),2π) mod(IP.lon_perihelion_epoch(param_set),2π) rtol=rtol
@test Insolation.γ_spline(od, 0.0) IP.obliq_epoch(param_set) rtol=rtol
@test Insolation.e_spline(od, 0.0) IP.eccentricity_epoch(param_set) rtol=rtol
Expand Down
2 changes: 1 addition & 1 deletion test/test_perihelion.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ end

years = 1900:2100
days = zeros(length(years))
od = Insolation.OrbitalData(Insolation.datadir())
od = Insolation.OrbitalData()
for (i,year) in enumerate(years)
f = (x -> edist(x, year, od))
res = optimize(f,1.,30)
Expand Down
2 changes: 1 addition & 1 deletion test/test_types.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
date = Dates.DateTime(2020, 2, 20, 11, 11, 0)
lon, lat = [FT(80.0), FT(20.0)]

od = Insolation.OrbitalData(Insolation.datadir())
od = Insolation.OrbitalData()

sza, azi, d = instantaneous_zenith_angle(
date,
Expand Down
2 changes: 1 addition & 1 deletion test/test_zenith_angle.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
rtol = 1e-2
od = Insolation.OrbitalData(Insolation.datadir())
od = Insolation.OrbitalData()
# sunrise at equator
date = Dates.DateTime(2020, 2, 20, 6, 11, 0)
lon, lat = [FT(0.0), FT(0.0)]
Expand Down

2 comments on commit f2ba81e

@charleskawczynski
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/83905

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.6.0 -m "<description of version>" f2ba81ee1e25348951f759e022145ecc8aa20c85
git push origin v0.6.0

Please sign in to comment.