From ec7da49daaca9e3f62b92dc8a8fc07d2775fb5e2 Mon Sep 17 00:00:00 2001 From: Gabriele Bozzola Date: Thu, 26 Sep 2024 13:58:40 -0700 Subject: [PATCH] Conditionally use high res version of SST/SIC Following https://github.com/CliMA/ClimaArtifacts/pull/45, we have a thinned down artifact that can be automatically downloaded if the higher resolution version is not available. --- NEWS.md | 15 +++++++++++++++ Project.toml | 2 ++ experiments/ClimaEarth/Artifacts.toml | 9 ++++++++- experiments/ClimaEarth/run_amip.jl | 20 ++++++++++++++++++-- src/Utilities.jl | 19 +++++++++++++++++++ 5 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 NEWS.md diff --git a/NEWS.md b/NEWS.md new file mode 100644 index 0000000000..d14ac4b75e --- /dev/null +++ b/NEWS.md @@ -0,0 +1,15 @@ +ClimaCoupler.jl Release Notes +============================ + +`main` +------- + +### ClimaEarth features + +### Sea-surface temperature and sea ice concentration data can now be automatically downloaded + +Sea-surface temperature and sea ice concentration require external files. Now, a +low-resolution version of such files is automatically downloaded when a +higher-resolution version is not available. Please, refer to +[ClimaArtifacts](https://github.com/CliMA/ClimaArtifacts) for more information. + diff --git a/Project.toml b/Project.toml index 93a603b66d..4bd05b8cda 100644 --- a/Project.toml +++ b/Project.toml @@ -4,6 +4,7 @@ authors = ["CliMA Contributors "] version = "0.1.1" [deps] +Artifacts = "56f22d72-fd6d-98f1-02f0-08ddc0907c33" ClimaComms = "3a4d1b5c-c61d-41fd-a00a-5873ba7a1b0d" ClimaCore = "d414da3d-4745-48bb-8d80-42e94e092884" ClimaCoreTempestRemap = "d934ef94-cdd4-4710-83d6-720549644b70" @@ -17,6 +18,7 @@ SurfaceFluxes = "49b00bb7-8bd4-4f2b-b78c-51cd0450215f" Thermodynamics = "b60c26fb-14c3-4610-9d3e-2d17fe7ff00c" [compat] +Artifacts = "1" ClimaComms = "0.5.6, 0.6" ClimaCore = "0.14.6" ClimaCoreTempestRemap = "0.3" diff --git a/experiments/ClimaEarth/Artifacts.toml b/experiments/ClimaEarth/Artifacts.toml index 746dc6c3e0..b5ee62ead6 100644 --- a/experiments/ClimaEarth/Artifacts.toml +++ b/experiments/ClimaEarth/Artifacts.toml @@ -22,4 +22,11 @@ git-tree-sha1 = "7486bf32e9352493f69364aead26f01eaf90d2af" git-tree-sha1 = "945e31f8028a581f7e8435cb691462124484567a" [historical_sst_sic] -git-tree-sha1 = "c4f82cd33fb26513ee45bff78330c6b606630fa5" +git-tree-sha1 = "0d30d71a6f9b6548fe7395ca647e853ec36d1699" + +[historical_sst_sic_lowres] +git-tree-sha1 = "7f7b6d4ae6055c4c2b6a6dfba5be8b4e6ca1b0be" + + [[historical_sst_sic_lowres.download]] + sha256 = "b68c0ce6ea682c38e29cb87c9c6ced6736ecac32d0d32dbaba78beb66046a06c" + url = "https://caltech.box.com/shared/static/ufnesb00zkvlc3sxzhnnmqc3zbatxkb9.gz" diff --git a/experiments/ClimaEarth/run_amip.jl b/experiments/ClimaEarth/run_amip.jl index 5ee14f1549..209de995cb 100644 --- a/experiments/ClimaEarth/run_amip.jl +++ b/experiments/ClimaEarth/run_amip.jl @@ -173,8 +173,24 @@ The data files are downloaded from the `ClimaCoupler` artifacts directory. If th original sources. =# include(joinpath(pkgdir(ClimaCoupler), "artifacts", "artifact_funcs.jl")) -sst_data = joinpath(@clima_artifact("historical_sst_sic", comms_ctx), "MODEL.SST.HAD187001-198110.OI198111-202206.nc") -sic_data = joinpath(@clima_artifact("historical_sst_sic", comms_ctx), "MODEL.ICE.HAD187001-198110.OI198111-202206.nc") + +if Utilities.artifact_exists("historical_sst_sic") + sst_data = + joinpath(@clima_artifact("historical_sst_sic", comms_ctx), "MODEL.SST.HAD187001-198110.OI198111-202206.nc") + sic_data = + joinpath(@clima_artifact("historical_sst_sic", comms_ctx), "MODEL.ICE.HAD187001-198110.OI198111-202206.nc") +else + ClimaComms.iamroot(comms_ctx) && + @warn "Using lowres sst sic. If you want the higher resolution version, you have to obtain it from ClimaArtifacts" + sst_data = joinpath( + @clima_artifact("historical_sst_sic_lowres", comms_ctx), + "MODEL.SST.HAD187001-198110.OI198111-202206_lowres.nc", + ) + sic_data = joinpath( + @clima_artifact("historical_sst_sic_lowres", comms_ctx), + "MODEL.ICE.HAD187001-198110.OI198111-202206_lowres.nc", + ) +end co2_data = joinpath(co2_dataset_path(), "mauna_loa_co2.nc") land_mask_data = joinpath(mask_dataset_path(), "seamask.nc") diff --git a/src/Utilities.jl b/src/Utilities.jl index 914686f4db..abb0a71042 100644 --- a/src/Utilities.jl +++ b/src/Utilities.jl @@ -6,12 +6,31 @@ modules in the coupler. """ module Utilities +import Artifacts import ClimaComms import ClimaCore as CC import Logging export swap_space! +""" + artifact_exists(name) + +Return whether the artifact with the given name exists and is available to use. +""" +function artifact_exists(name) + # There seems to be no easy way to determine if an artifact exists from the name + # only... + return try + # We need to macroexpand because we only want to resolve @artifact_str when + # we call this function + @macroexpand Artifacts.@artifact_str(name) + true + catch error + false + end +end + """ swap_space!(space_out::CC.Spaces.AbstractSpace, field_in::CC.Fields.Field)