Skip to content

Commit

Permalink
Merge pull request #66 from CliMA/sb/artifact-script
Browse files Browse the repository at this point in the history
Script to build artifact
  • Loading branch information
simonbyrne authored Jan 3, 2024
2 parents 56730a0 + 1058ad8 commit 098e63f
Show file tree
Hide file tree
Showing 9 changed files with 178 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ docs/site/
*.swp
*.png

*Manifest.toml
Manifest.toml

src/data/*.tsv
src/data/*.ipynb
10 changes: 5 additions & 5 deletions Artifacts.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[orb_params_dataset]
git-tree-sha1 = "4fda5e46a91c2a0cf12c9b46dad3a4189ebcfb37"
[laskar2004]
git-tree-sha1 = "e4044f4093e731021a3e62428f594ee7b5ea56e2"

[[orb_params_dataset.download]]
sha256 = "652d52f3b311c4df65052287b1cb4f0be0b996aba130c9a5b42183cb5bba59dc"
url = "https://caltech.box.com/shared/static/hibf8tlxjujbqy5qa65tad2ved184otc.gz"
[[laskar2004.download]]
sha256 = "8b3a9510ade307e1834c51968421ab803d0d570f1c27529cb417d7a185fbcc3e"
url = "https://data.caltech.edu/records/v9dp1-jb227/files/laskar2004.tar.gz"
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Insolation"
uuid = "e98cc03f-d57e-4e3c-b70c-8d51efe9e0d8"
authors = ["Climate Modeling Alliance"]
version = "0.8.1"
version = "0.8.2"

[deps]
Artifacts = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"
Expand All @@ -14,4 +14,4 @@ Artifacts = "<0.0.1, 1"
Dates = "<0.0.1, 1"
DelimitedFiles = "<0.0.1, 1"
Interpolations = "0.13, 0.14, 0.15"
julia = "1.7, 1.8, 1.9"
julia = "1.7"
2 changes: 2 additions & 0 deletions artifacts/laskar2004/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
!Manifest.toml
*.tar.gz
95 changes: 95 additions & 0 deletions artifacts/laskar2004/Manifest.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# This file is machine-generated - editing it directly is not advised

julia_version = "1.10.0"
manifest_format = "2.0"
project_hash = "b9ce7e2b2ba966a9d962c19f15fc32c0b4b43bd5"

[[deps.ArgTools]]
uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f"
version = "1.1.1"

[[deps.Artifacts]]
uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"

[[deps.CodecZlib]]
deps = ["TranscodingStreams", "Zlib_jll"]
git-tree-sha1 = "cd67fc487743b2f0fd4380d4cbd3a24660d0eec8"
uuid = "944b1d66-785c-5afd-91f1-9de20f533193"
version = "0.7.3"

[[deps.Downloads]]
deps = ["ArgTools", "FileWatching", "LibCURL", "NetworkOptions"]
uuid = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
version = "1.6.0"

[[deps.FileWatching]]
uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee"

[[deps.LibCURL]]
deps = ["LibCURL_jll", "MozillaCACerts_jll"]
uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21"
version = "0.6.4"

[[deps.LibCURL_jll]]
deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"]
uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0"
version = "8.4.0+0"

[[deps.LibSSH2_jll]]
deps = ["Artifacts", "Libdl", "MbedTLS_jll"]
uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8"
version = "1.11.0+1"

[[deps.Libdl]]
uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb"

[[deps.MbedTLS_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1"
version = "2.28.2+1"

[[deps.MozillaCACerts_jll]]
uuid = "14a3606d-f60d-562e-9121-12d972cd8159"
version = "2023.1.10"

[[deps.NetworkOptions]]
uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908"
version = "1.2.0"

[[deps.Printf]]
deps = ["Unicode"]
uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7"

[[deps.SHA]]
uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce"
version = "0.7.0"

[[deps.Tar]]
deps = ["ArgTools", "SHA"]
uuid = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e"
version = "1.10.0"

[[deps.TranscodingStreams]]
git-tree-sha1 = "1fbeaaca45801b4ba17c251dd8603ef24801dd84"
uuid = "3bb67fe8-82b1-5028-8e26-92a6c54297fa"
version = "0.10.2"

[deps.TranscodingStreams.extensions]
TestExt = ["Test", "Random"]

[deps.TranscodingStreams.weakdeps]
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[[deps.Unicode]]
uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"

[[deps.Zlib_jll]]
deps = ["Libdl"]
uuid = "83775a58-1f1d-513f-b197-d71354ab007a"
version = "1.2.13+1"

[[deps.nghttp2_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d"
version = "1.52.0+1"
6 changes: 6 additions & 0 deletions artifacts/laskar2004/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[deps]
CodecZlib = "944b1d66-785c-5afd-91f1-9de20f533193"
Downloads = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
SHA = "ea8e919c-243c-51af-8825-aaa63cd721ce"
Tar = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e"
17 changes: 17 additions & 0 deletions artifacts/laskar2004/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Laskar et. al. (2004) data

This is repackaged data from http://vo.imcce.fr/insola/earth/online/earth/earth.html, specifically:
- [`INSOLN.LA2004.BTL.ASC`](http://vo.imcce.fr/insola/earth/online/earth/La2004/INSOLN.LA2004.BTL.ASC)
- [`INSOLP.LA2004.BTL.ASC`](http://vo.imcce.fr/insola/earth/online/earth/La2004/INSOLP.LA2004.BTL.ASC)

From the following paper:
> Laskar, J., Robutel, P., Joutel, F., Gastineau, M., Correia, A.C.M., Levrard, B.
> A long term numerical solution for the insolation quantities of the Earth.
> A&A 428, 261-285 (2004), DOI: 10.1051/0004-6361:20041335
The two files are combined into one, with columns
1. Time from J2000 in 1000 years
2. eccentricity
3. obliquity (radians)
4. longitude of perihelion from moving equinox (radians)
- modified from the original files to be continuous over time
49 changes: 49 additions & 0 deletions artifacts/laskar2004/create_artifact.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using Downloads, Printf, Tar, CodecZlib, SHA, Pkg

insoln_file = Downloads.download("http://vo.imcce.fr/insola/earth/online/earth/La2004/INSOLN.LA2004.BTL.ASC")
insolp_file = Downloads.download("http://vo.imcce.fr/insola/earth/online/earth/La2004/INSOLP.LA2004.BTL.ASC")

insoln_lines = reverse(readlines(insoln_file)) # stored in reverse order
insolp_lines = readlines(insolp_file)[2:end] # 0 is duplicated in both files

out_dir = mktempdir()

out_csv = joinpath(out_dir, "INSOL.LA2004.BTL.csv")
open(out_csv; write=true) do f
println(f, "# t (kyr from J2000), ecc, obliq (rad), varpi (rad)")
varpi_offset = Float64(pi)
varpi_rad_prev = 1.0 + varpi_offset
for line in vcat(insoln_lines, insolp_lines)
kyr_s, ecc_s, obliq_rad_s, varpi_rad_s = split(line)
kyr = parse(Float64, kyr_s)
ecc = parse(Float64, replace(ecc_s, 'D' => 'e'))
obliq_rad = parse(Float64, replace(obliq_rad_s, 'D' => 'e'))
varpi_rad = parse(Float64, replace(varpi_rad_s, 'D' => 'e'))

# keep continuous so it can be interpolated
if varpi_rad + varpi_offset < varpi_rad_prev - pi
varpi_offset += 2pi
elseif varpi_rad + varpi_offset > varpi_rad_prev + pi
varpi_offset -= 2pi
end
varpi_rad += varpi_offset
varpi_rad_prev = varpi_rad
@printf(f, "%.3f,%.16e,%.16e,%.16e\n", kyr, ecc, obliq_rad, varpi_rad)
end
end

# add README
cp(joinpath(@__DIR__, "README.md"), joinpath(out_dir, "README.md"))

git_tree_sha1 = bytes2hex(Pkg.GitTools.tree_hash(SHA1_CTX, out_dir))

out_tar = joinpath(@__DIR__, "laskar2004.tar.gz")
open(out_tar, write=true) do f
gzf = GzipCompressorStream(f)
Tar.create(out_dir, gzf)
close(gzf)
end

archive_sha256 = bytes2hex(open(sha256, out_tar))

@info "Created artifact" file=out_tar git_tree_sha1 archive_sha256
2 changes: 1 addition & 1 deletion src/Insolation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ struct OrbitalData{E, G, O}
end

function OrbitalData()
datapath = joinpath(artifact"orb_params_dataset", "INSOL.LA2004.BTL.csv")
datapath = joinpath(artifact"laskar2004", "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 =
Expand Down

2 comments on commit 098e63f

@simonbyrne
Copy link
Member Author

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/98483

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

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.8.2 -m "<description of version>" 098e63fd41c2be4ca3d0a435ee5c37c16728628f
git push origin v0.8.2

Please sign in to comment.