Skip to content

Commit

Permalink
use ClimaArtifacts Bonan data
Browse files Browse the repository at this point in the history
  • Loading branch information
juliasloan25 committed Oct 31, 2024
1 parent 86e1ed1 commit 8c0a334
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 28 deletions.
6 changes: 6 additions & 0 deletions Artifacts.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,9 @@ git-tree-sha1 = "b849eb95c09190095e7bf021494ddeda8858af01"
[[modis_clumping_index.download]]
sha256 = "e4c766a93a673e5dc22540687ef5616416d65bb13a0f4a67789b95d49ccbb158"
url = "https://caltech.box.com/shared/static/ec2y3k5kqpl9wjvtsx3584wgkp5q8dyw.gz"

[bonan_richards_eqn]
git-tree-sha1 = "043f9354b961fd3ef6ac4cf71d0c99930e177a92"
[[bonan_richards_eqn.download]]
sha256 = "50f1739dfd8193742488f249bd1ba8a157dfc7c1d8a27392ba7edbe9b4c0db03"
url = "https://caltech.box.com/shared/static/4jcz9c1lp6rt750q28kx3qvihi8393tv.gz"
7 changes: 4 additions & 3 deletions experiments/standalone/Soil/richards_comparison.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ import ClimaUtilities.OutputPathGenerator: generate_output_path
import ClimaLand
import ClimaLand.Parameters as LP

clay_datapath, sand_datapath =
ClimaLand.Artifacts.richards_eqn_bonan_data_path()
bonan_data_folder = ClimaLand.Artifacts.richards_eqn_bonan_data_path()
clay_datapath = joinpath(bonan_data_folder, "bonan_data_clay.txt")
sand_datapath = joinpath(bonan_data_folder, "bonan_data_sand.txt")

context = ClimaComms.context()
device_suffix =
Expand Down Expand Up @@ -207,7 +208,7 @@ end
if FT == Float64 && context.device isa ClimaComms.CPUSingleThreaded
N = length(sol.t)
ϑ_l = parent(sol.u[N].soil.ϑ_l)
ds_bonan = readdlm(sand_datapath, ',')
ds_bonan = readdlm(sand_datapath)
bonan_moisture = reverse(ds_bonan[:, 1])
bonan_z = reverse(ds_bonan[:, 2]) ./ 100.0
@test sqrt.(mean((bonan_moisture .- ϑ_l) .^ 2.0)) < FT(1e-3)
Expand Down
28 changes: 3 additions & 25 deletions src/Artifacts.jl
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ end
Returns the file path for data created solving Richards equation
with G. Bonan's matlab code, found here:
https://github.com/gbonan/bonanmodeling/tree/master/sp_08_01
This folder contains two data files: bonan_data_clay.txt and
bonan_data_sand.txt.
The data files correspond to the clay and sand data set described in
that code and in G. Bonan's book,
Expand All @@ -162,31 +164,7 @@ Publisher: Cambridge University Press
Print publication year: 2019
"""
function richards_eqn_bonan_data_path(; context = nothing)
dir = joinpath(@__DIR__, "../")
bonan_clay_dataset = ArtifactWrapper(
dir,
"richards_clay_bonan_ref_soln",
ArtifactFile[ArtifactFile(
url = "https://caltech.box.com/shared/static/nk89znth59gcsdb65lnywnzjnuno3h6k.txt",
filename = "clay_bonan_sp801_22323.txt",
),],
)
clay_datapath = joinpath(
get_data_folder(bonan_clay_dataset),
"clay_bonan_sp801_22323.txt",
)

bonan_sand_dataset = ArtifactWrapper(
dir,
"richards_sand_bonan_ref_soln",
ArtifactFile[ArtifactFile(
url = "https://caltech.box.com/shared/static/2vk7bvyjah8xd5b7wxcqy72yfd2myjss.csv",
filename = "sand_bonan_sp801.csv",
),],
)
sand_datapath =
joinpath(get_data_folder(bonan_sand_dataset), "sand_bonan_sp801.csv")
return clay_datapath, sand_datapath
return @clima_artifact("bonan_richards_eqn", context)
end

"""
Expand Down

0 comments on commit 8c0a334

Please sign in to comment.