Skip to content

Commit

Permalink
Merge pull request #487 from CliMA/ne/param_ext
Browse files Browse the repository at this point in the history
Add package extension for CLIMAParameters
  • Loading branch information
nefrathenrici authored Feb 9, 2024
2 parents 4411120 + 26e9ce6 commit e034827
Show file tree
Hide file tree
Showing 38 changed files with 82 additions and 107 deletions.
11 changes: 10 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
Flux = "587475ba-b771-5e3f-ad9e-33799f191a9c"
HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3"
Insolation = "e98cc03f-d57e-4e3c-b70c-8d51efe9e0d8"
IntervalSets = "8197267c-284f-5f27-9208-e0e47529a953"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
NCDatasets = "85f8d34a-cbdd-5861-8df4-14fed0d494ab"
Expand All @@ -27,10 +28,17 @@ SurfaceFluxes = "49b00bb7-8bd4-4f2b-b78c-51cd0450215f"
Thermodynamics = "b60c26fb-14c3-4610-9d3e-2d17fe7ff00c"
cuDNN = "02a925ec-e4fe-4b08-9a7e-0d78e3d38ccd"

[weakdeps]
CLIMAParameters = "6eacf6c3-8458-43b9-ae03-caf5306d3d53"

[extensions]
CreateParametersExt = "CLIMAParameters"

[compat]
Adapt = "3, 4"
ArtifactWrappers = "0.2"
CFTime = "0.1"
CLIMAParameters = "0.8.6"
CSV = "0.10"
CUDA = "5"
ClimaComms = "0.5.6"
Expand All @@ -41,6 +49,7 @@ Dates = "1"
DocStringExtensions = "0.8, 0.9"
Flux = "0.14"
HTTP = "1.10"
Insolation = "0.9"
IntervalSets = "0.5, 0.6, 0.7"
LinearAlgebra = "1"
NCDatasets = "0.11, 0.12, 0.13, 0.14"
Expand All @@ -50,4 +59,4 @@ StatsBase = "0.34"
SurfaceFluxes = "0.9.1"
Thermodynamics = "0.11"
cuDNN = "1"
julia = "1.8"
julia = "1.9"
24 changes: 8 additions & 16 deletions docs/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

julia_version = "1.10.0"
manifest_format = "2.0"
project_hash = "9eaabd4032c84b86a367881b74dc178d232181bd"
project_hash = "ffb8031716bba12797eb1035eef7ff545d303e9b"

[[deps.ADTypes]]
git-tree-sha1 = "41c37aa88889c171f1300ceac1313c06e891d245"
Expand Down Expand Up @@ -194,9 +194,9 @@ version = "0.1.2"

[[deps.CLIMAParameters]]
deps = ["DocStringExtensions", "TOML", "Test"]
git-tree-sha1 = "626a0dd920d1ed9285e74a430df6f110a5b962e0"
git-tree-sha1 = "cf4f5ee75576ae855eca7da064540ce40b9a04c1"
uuid = "6eacf6c3-8458-43b9-ae03-caf5306d3d53"
version = "0.8.4"
version = "0.8.6"

[[deps.CPUSummary]]
deps = ["CpuId", "IfElse", "PrecompileTools", "Static"]
Expand Down Expand Up @@ -290,10 +290,14 @@ uuid = "d934ef94-cdd4-4710-83d6-720549644b70"
version = "0.3.12"

[[deps.ClimaLand]]
deps = ["Adapt", "ArtifactWrappers", "CFTime", "CSV", "CUDA", "ClimaComms", "ClimaCore", "ClimaCoreTempestRemap", "DataFrames", "Dates", "DocStringExtensions", "Flux", "HTTP", "IntervalSets", "JLD2", "LinearAlgebra", "NCDatasets", "SciMLBase", "StaticArrays", "StatsBase", "SurfaceFluxes", "Thermodynamics", "cuDNN"]
deps = ["Adapt", "ArtifactWrappers", "CFTime", "CSV", "CUDA", "ClimaComms", "ClimaCore", "ClimaCoreTempestRemap", "DataFrames", "Dates", "DocStringExtensions", "Flux", "HTTP", "Insolation", "IntervalSets", "LinearAlgebra", "NCDatasets", "SciMLBase", "StaticArrays", "StatsBase", "SurfaceFluxes", "Thermodynamics", "cuDNN"]
path = ".."
uuid = "08f4d4ce-cf43-44bb-ad95-9d2d5f413532"
version = "0.8.0"
weakdeps = ["CLIMAParameters"]

[deps.ClimaLand.extensions]
CreateParametersExt = "CLIMAParameters"

[[deps.ClimaTimeSteppers]]
deps = ["CUDA", "ClimaComms", "Colors", "DataStructures", "DiffEqBase", "DiffEqCallbacks", "KernelAbstractions", "Krylov", "LinearAlgebra", "LinearOperators", "NVTX", "SciMLBase", "StaticArrays"]
Expand Down Expand Up @@ -645,12 +649,6 @@ git-tree-sha1 = "acebe244d53ee1b461970f8910c235b259e772ef"
uuid = "9aa1b823-49e4-5ca5-8b0f-3971ec8bab6a"
version = "0.3.2"

[[deps.FileIO]]
deps = ["Pkg", "Requires", "UUIDs"]
git-tree-sha1 = "c5c28c245101bd59154f649e19b038d15901b5dc"
uuid = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
version = "1.16.2"

[[deps.FilePathsBase]]
deps = ["Compat", "Dates", "Mmap", "Printf", "Test", "UUIDs"]
git-tree-sha1 = "9f00e42f8d99fdde64d40c8ea5d14269a2e2c1aa"
Expand Down Expand Up @@ -975,12 +973,6 @@ git-tree-sha1 = "a3f24677c21f5bbe9d2a714f95dcd58337fb2856"
uuid = "82899510-4779-5014-852e-03e436cf321d"
version = "1.0.0"

[[deps.JLD2]]
deps = ["FileIO", "MacroTools", "Mmap", "OrderedCollections", "Pkg", "PrecompileTools", "Printf", "Reexport", "Requires", "TranscodingStreams", "UUIDs"]
git-tree-sha1 = "7c0008f0b7622c6c0ee5c65cbc667b69f8a65672"
uuid = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
version = "0.4.45"

[[deps.JLFzf]]
deps = ["Pipe", "REPL", "Random", "fzf_jll"]
git-tree-sha1 = "a53ebe394b71470c7f97c2e7e170d51df21b17af"
Expand Down
1 change: 0 additions & 1 deletion docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ Thermodynamics = "b60c26fb-14c3-4610-9d3e-2d17fe7ff00c"
cuDNN = "02a925ec-e4fe-4b08-9a7e-0d78e3d38ccd"

[compat]
CLIMAParameters = "0.8.1"
CSV = "0.10"
ClimaTimeSteppers = "0.7"
DataFrames = "1.6"
Expand Down
3 changes: 1 addition & 2 deletions docs/tutorials/integrated/soil_canopy_tutorial.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,12 @@ using ClimaLand.Canopy
using ClimaLand.Canopy.PlantHydraulics
import ClimaLand
import ClimaLand.Parameters as LP
include(joinpath(pkgdir(ClimaLand), "parameters", "create_parameters.jl"));

# Define the floating point precision desired (64 or 32 bit), and get the
# parameter set holding constants used across CliMA Models:

const FT = Float32;
earth_param_set = create_lsm_parameters(FT);
earth_param_set = LP.LandParameters(FT);

# Setup the domain for the model:

Expand Down
4 changes: 2 additions & 2 deletions docs/tutorials/shared_utilities/driver_tutorial.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ using Dates
using Insolation # for computing zenith angle given lat, lon, time.
using ClimaLand
import ClimaLand.Parameters as LP
include(joinpath(pkgdir(ClimaLand), "parameters", "create_parameters.jl"));
import CLIMAParameters

# Assume the local_datetime array is read in from the data file.
local_datetime = DateTime(2013):Dates.Hour(1):DateTime(2013, 1, 7); # one week, hourly data
Expand Down Expand Up @@ -77,7 +77,7 @@ SW_d = TimeVaryingInput(seconds, SW_d);
# Finally, for many models we also need to specify the function
# for computing the zenith angle as a function of simulation time.
# To do so, we use the `Insolation` package as follows:
earth_param_set = create_lsm_parameters(Float64);
earth_param_set = LP.LandParameters(Float64);
insol_params = earth_param_set.insol_params # parameters of Earth's orbit required to compute the insolation
function zenith_angle(
t,
Expand Down
4 changes: 2 additions & 2 deletions docs/tutorials/standalone/Bucket/bucket_tutorial.jl
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ FT = Float32;
# additional parameters as described in the text above. These two sets
# are combined in the object `BucketModelParameters` as follows:
import ClimaLand
include(joinpath(pkgdir(ClimaLand), "parameters", "create_parameters.jl"));
earth_param_set = create_lsm_parameters(FT);
import ClimaLand.Parameters as LP
earth_param_set = LP.LandParameters(FT);

# Set up the model domain. At every surface coordinate point, we'll solve
# an ODE for `W` and `Ws`, and for every subsurface point, we solve for `T`.
Expand Down
3 changes: 1 addition & 2 deletions docs/tutorials/standalone/Canopy/canopy_tutorial.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,12 @@ using ClimaLand.Canopy
using ClimaLand.Canopy.PlantHydraulics
import ClimaLand
import ClimaLand.Parameters as LP
include(joinpath(pkgdir(ClimaLand), "parameters", "create_parameters.jl"));

# Define the floating point precision desired (64 or 32 bit), and get the
# parameter set holding constants used across CliMA Models:

const FT = Float32;
earth_param_set = create_lsm_parameters(FT);
earth_param_set = LP.LandParameters(FT);

# # Setup the Canopy Model

Expand Down
3 changes: 1 addition & 2 deletions docs/tutorials/standalone/Soil/freezing_front.jl
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,12 @@ using ClimaLand.Soil

import ClimaLand
import ClimaLand.Parameters as LP
include(joinpath(pkgdir(ClimaLand), "parameters", "create_parameters.jl"));

# # Preliminary set-up

# Choose a floating point precision, and get the parameter set, which holds constants used across CliMA models:
FT = Float32
earth_param_set = create_lsm_parameters(FT);
earth_param_set = LP.LandParameters(FT);

# Set the values of other parameters required by the model:
ν = FT(0.535)
Expand Down
3 changes: 1 addition & 2 deletions docs/tutorials/standalone/Soil/richards_equation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,10 @@ using ClimaLand.Soil

import ClimaLand
import ClimaLand.Parameters as LP
include(joinpath(pkgdir(ClimaLand), "parameters", "create_parameters.jl"));

# - Define the float type desired (`Float64` or `Float32`), and get the parameter set, which holds constants used across CliMA models:
const FT = Float32;
earth_param_set = create_lsm_parameters(FT);
earth_param_set = LP.LandParameters(FT);

# # Set up the soil model

Expand Down
3 changes: 1 addition & 2 deletions docs/tutorials/standalone/Soil/soil_energy_hydrology.jl
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,10 @@ using ClimaLand.Soil

import ClimaLand
import ClimaLand.Parameters as LP
include(joinpath(pkgdir(ClimaLand), "parameters", "create_parameters.jl"));

# Choose a floating point precision, and get the parameter set, which holds constants used across CliMA models:
FT = Float32
earth_param_set = create_lsm_parameters(FT);
earth_param_set = LP.LandParameters(FT);


# # Create the model
Expand Down
18 changes: 8 additions & 10 deletions experiments/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

julia_version = "1.10.0"
manifest_format = "2.0"
project_hash = "4be5566bbe2d99a9c79b8e2be092ee5f6f0fee2a"
project_hash = "766ddd77d85a70c8ca84c25cf4974c14a23f5ff0"

[[deps.ADTypes]]
git-tree-sha1 = "41c37aa88889c171f1300ceac1313c06e891d245"
Expand Down Expand Up @@ -218,9 +218,9 @@ version = "0.1.2"

[[deps.CLIMAParameters]]
deps = ["DocStringExtensions", "TOML", "Test"]
git-tree-sha1 = "626a0dd920d1ed9285e74a430df6f110a5b962e0"
git-tree-sha1 = "cf4f5ee75576ae855eca7da064540ce40b9a04c1"
uuid = "6eacf6c3-8458-43b9-ae03-caf5306d3d53"
version = "0.8.4"
version = "0.8.6"

[[deps.CPUSummary]]
deps = ["CpuId", "IfElse", "PrecompileTools", "Static"]
Expand Down Expand Up @@ -347,10 +347,14 @@ uuid = "d934ef94-cdd4-4710-83d6-720549644b70"
version = "0.3.12"

[[deps.ClimaLand]]
deps = ["Adapt", "ArtifactWrappers", "CFTime", "CSV", "CUDA", "ClimaComms", "ClimaCore", "ClimaCoreTempestRemap", "DataFrames", "Dates", "DocStringExtensions", "Flux", "HTTP", "IntervalSets", "JLD2", "LinearAlgebra", "NCDatasets", "SciMLBase", "StaticArrays", "StatsBase", "SurfaceFluxes", "Thermodynamics", "cuDNN"]
deps = ["Adapt", "ArtifactWrappers", "CFTime", "CSV", "CUDA", "ClimaComms", "ClimaCore", "ClimaCoreTempestRemap", "DataFrames", "Dates", "DocStringExtensions", "Flux", "HTTP", "Insolation", "IntervalSets", "LinearAlgebra", "NCDatasets", "SciMLBase", "StaticArrays", "StatsBase", "SurfaceFluxes", "Thermodynamics", "cuDNN"]
path = ".."
uuid = "08f4d4ce-cf43-44bb-ad95-9d2d5f413532"
version = "0.8.0"
weakdeps = ["CLIMAParameters"]

[deps.ClimaLand.extensions]
CreateParametersExt = "CLIMAParameters"

[[deps.ClimaTimeSteppers]]
deps = ["CUDA", "ClimaComms", "Colors", "DataStructures", "DiffEqBase", "DiffEqCallbacks", "KernelAbstractions", "Krylov", "LinearAlgebra", "LinearOperators", "NVTX", "SciMLBase", "StaticArrays"]
Expand Down Expand Up @@ -1193,12 +1197,6 @@ git-tree-sha1 = "a3f24677c21f5bbe9d2a714f95dcd58337fb2856"
uuid = "82899510-4779-5014-852e-03e436cf321d"
version = "1.0.0"

[[deps.JLD2]]
deps = ["FileIO", "MacroTools", "Mmap", "OrderedCollections", "Pkg", "PrecompileTools", "Printf", "Reexport", "Requires", "TranscodingStreams", "UUIDs"]
git-tree-sha1 = "7c0008f0b7622c6c0ee5c65cbc667b69f8a65672"
uuid = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
version = "0.4.45"

[[deps.JLFzf]]
deps = ["Pipe", "REPL", "Random", "fzf_jll"]
git-tree-sha1 = "a53ebe394b71470c7f97c2e7e170d51df21b17af"
Expand Down
1 change: 0 additions & 1 deletion experiments/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ SurfaceFluxes = "49b00bb7-8bd4-4f2b-b78c-51cd0450215f"
Thermodynamics = "b60c26fb-14c3-4610-9d3e-2d17fe7ff00c"

[compat]
CLIMAParameters = "0.8"
ClimaTimeSteppers = "0.7"
Insolation = "0.9"
Statistics = "1"
3 changes: 1 addition & 2 deletions experiments/integrated/fluxnet/run_fluxnet.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ using ClimaLand.Canopy
using ClimaLand.Canopy.PlantHydraulics
import ClimaLand
import ClimaLand.Parameters as LP
include(joinpath(pkgdir(ClimaLand), "parameters", "create_parameters.jl"))
const FT = Float64
earth_param_set = create_lsm_parameters(FT)
earth_param_set = LP.LandParameters(FT)
climaland_dir = pkgdir(ClimaLand)

include(joinpath(climaland_dir, "experiments/integrated/fluxnet/data_tools.jl"))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import SciMLBase
import ClimaTimeSteppers as CTS
using ClimaCore
import CLIMAParameters as CP
using Plots
using Statistics
using Dates
Expand All @@ -14,13 +13,14 @@ using ClimaLand.Canopy
using ClimaLand.Canopy.PlantHydraulics
import ClimaLand
import ClimaLand.Parameters as LP
import CLIMAParameters

climaland_dir = pkgdir(ClimaLand)
include(joinpath(climaland_dir, "parameters", "create_parameters.jl"))

for float_type in (Float32, Float64)
# Make these global so we can use them in other ozark files
global FT = float_type
global earth_param_set = create_lsm_parameters(FT)
global earth_param_set = LP.LandParameters(FT)
global site_ID = "US-MOz"

# Utility functions for reading in and filling fluxnet data
Expand Down
4 changes: 2 additions & 2 deletions experiments/standalone/Biogeochemistry/experiment.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ using ClimaLand.Soil.Biogeochemistry: MicrobeProduction
using Dates

import ClimaLand.Parameters as LP
include(joinpath(pkgdir(ClimaLand), "parameters", "create_parameters.jl"))
import CLIMAParameters

# Define simulation times
t0 = Float64(0)
tf = Float64(10000)
dt = Float64(10)

for (FT, tf) in ((Float32, 2 * dt), (Float64, tf))
earth_param_set = create_lsm_parameters(FT)
earth_param_set = LP.LandParameters(FT)

# Make soil model args
ν = FT(0.556)
Expand Down
6 changes: 3 additions & 3 deletions experiments/standalone/Bucket/global_bucket.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ using Statistics
import ClimaTimeSteppers as CTS
using ClimaCore
using ClimaCore: Remapping, Geometry
import CLIMAParameters as CP
import ClimaComms
import ClimaLand
include(joinpath(pkgdir(ClimaLand), "parameters", "create_parameters.jl"));
import ClimaLand.Parameters as LP
import CLIMAParameters
using ClimaLand.Bucket: BucketModel, BucketModelParameters, BulkAlbedoFunction
using ClimaLand.Domains: coordinates, Column
using ClimaLand:
Expand Down Expand Up @@ -38,7 +38,7 @@ end
anim_plots = false
FT = Float64;
context = ClimaComms.context()
earth_param_set = create_lsm_parameters(FT);
earth_param_set = LP.LandParameters(FT);
outdir = joinpath(pkgdir(ClimaLand), "experiments/standalone/Bucket/artifacts")
!ispath(outdir) && mkpath(outdir)

Expand Down
4 changes: 1 addition & 3 deletions experiments/standalone/Soil/evaporation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,13 @@ import ClimaLand
import ClimaLand.Parameters as LP
import SurfaceFluxes.Parameters as SFP

include(joinpath(pkgdir(ClimaLand), "parameters", "create_parameters.jl"))

# Define simulation times
t0 = Float64(0)
tf = Float64(24 * 3600 * 13)
dt = Float64(2)

for (FT, tf) in ((Float32, 2 * dt), (Float64, tf))
earth_param_set = create_lsm_parameters(FT)
earth_param_set = LP.LandParameters(FT)
thermo_params = LP.thermodynamic_parameters(earth_param_set)
# Coarse sand experiment described in Figures 7 and 8a
# of Lehmann, Assouline, Or (Phys Rev E 77, 2008)
Expand Down
1 change: 0 additions & 1 deletion experiments/standalone/Soil/richards_comparison.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ using ClimaLand.Soil
import ClimaLand
import ClimaLand.Parameters as LP

include(joinpath(pkgdir(ClimaLand), "parameters", "create_parameters.jl"))

# Read in reference solutions from artifacts
bonan_clay_dataset = ArtifactWrapper(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
module CreateParametersExt

import ClimaLand.Parameters.LandParameters
import Thermodynamics.Parameters.ThermodynamicsParameters
import Insolation.Parameters.InsolationParameters
import SurfaceFluxes.Parameters.SurfaceFluxesParameters
import SurfaceFluxes.UniversalFunctions as UF
import CLIMAParameters as CP

create_lsm_parameters(::Type{FT}) where {FT <: AbstractFloat} =
LandParameters(::Type{FT}) where {FT <: AbstractFloat} =
LandParameters(CP.create_toml_dict(FT))

function LandParameters(toml_dict::CP.AbstractTOMLDict)
Expand Down Expand Up @@ -48,3 +50,5 @@ function LandParameters(toml_dict::CP.AbstractTOMLDict)
insol_params,
)
end

end
Loading

0 comments on commit e034827

Please sign in to comment.