Skip to content

Commit

Permalink
Update to Insolation v0.5.0 and apply API changes
Browse files Browse the repository at this point in the history
  • Loading branch information
valeriabarra committed May 16, 2023
1 parent ebbec89 commit 02fee8a
Show file tree
Hide file tree
Showing 15 changed files with 75 additions and 53 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ ClimaComms = "0.3, 0.4"
ClimaCore = "0.10"
ClimaCoreTempestRemap = "0.3.5, 0.3.6, 0.3.7"
DocStringExtensions = "0.8, 0.9"
Insolation = "0.3, 0.4"
Insolation = "0.3, 0.4, 0.5"
IntervalSets = "0.5, 0.6, 0.7"
JLD2 = "0.4"
NCDatasets = "0.11, 0.12"
Expand Down
13 changes: 9 additions & 4 deletions docs/tutorials/Bucket/bucket_tutorial.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
# ``

# ``
# G_{undersnow} = (R_n+ SHF + LHF)_{snow} - F_{intosnow}
# G_{undersnow} = (R_n+ SHF + LHF)_{snow} - F_{intosnow}
# ``

# ``
Expand Down Expand Up @@ -89,7 +89,7 @@
# Turbulent surface fluxes of sensible heat, latent heat, and water vapor
# (`SHF, LHF, E`) are computed using Monin-Obukhov theory; `SW↓` and `LW↓`
# are the downward fluxes in short and long wavelength bands. We use the same
# roughness lengths for snow and soil.
# roughness lengths for snow and soil.
# Note that with the exception of precipitation and downwelling radiation,
# all fluxes are defined
# such that positive is towards the atmosphere.
Expand Down Expand Up @@ -216,7 +216,12 @@ bucket_domain =
# Here we define the model drivers, starting with downward radiation.
SW_d = (t) -> eltype(t)(300);
LW_d = (t) -> eltype(t)(300);
bucket_rad = PrescribedRadiativeFluxes(FT, SW_d, LW_d; orbital_data=Insolation.OrbitalData());
bucket_rad = PrescribedRadiativeFluxes(
FT,
SW_d,
LW_d;
orbital_data = Insolation.OrbitalData(Insolation.datadir()),
);

# Prescribed atmospheric variables

Expand Down Expand Up @@ -267,7 +272,7 @@ ClimaLSM.auxiliary_vars(model)
p.bucket |> propertynames


# Next is to set initial conditions.
# Next is to set initial conditions.
Y.bucket.T .= FT(270);
Y.bucket.W .= FT(0.05);
Y.bucket.Ws .= FT(0.0);
Expand Down
2 changes: 1 addition & 1 deletion experiments/LSM/ozark/ozark_met_drivers_FLUXNET.jl
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ radiation = ClimaLSM.PrescribedRadiativeFluxes(
SW_IN_spline,
LW_IN_spline;
θs = zenith_angle,
orbital_data = Insolation.OrbitalData(),
orbital_data = Insolation.OrbitalData(Insolation.datadir()),
)

transpiration = DiagnosticTranspiration{FT}()
46 changes: 23 additions & 23 deletions experiments/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

julia_version = "1.8.5"
manifest_format = "2.0"
project_hash = "20a85d7704f440a4911503c3b3f770cd3502e33f"
project_hash = "10798c79f173aef69e4f91905c65279be50e9e83"

[[deps.AbstractFFTs]]
deps = ["ChainRulesCore", "LinearAlgebra"]
Expand All @@ -12,9 +12,9 @@ version = "1.3.1"

[[deps.Adapt]]
deps = ["LinearAlgebra", "Requires"]
git-tree-sha1 = "cc37d689f599e8df4f464b2fa3870ff7db7492ef"
git-tree-sha1 = "76289dc51920fdc6e0013c872ba9551d54961c24"
uuid = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
version = "3.6.1"
version = "3.6.2"

[[deps.ArgTools]]
uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f"
Expand Down Expand Up @@ -134,9 +134,9 @@ version = "0.1.2"

[[deps.CLIMAParameters]]
deps = ["DocStringExtensions", "TOML", "Test"]
git-tree-sha1 = "8e805f83a13d1452e66e8baf04977e0df053238a"
git-tree-sha1 = "5b8fe32b112461953359a7b4cfea42d10058eee3"
uuid = "6eacf6c3-8458-43b9-ae03-caf5306d3d53"
version = "0.7.3"
version = "0.7.4"

[[deps.CPUSummary]]
deps = ["CpuId", "IfElse", "Static"]
Expand Down Expand Up @@ -310,9 +310,9 @@ uuid = "7445602f-e544-4518-8976-18f8e8ae6cdb"
version = "0.2.2"

[[deps.DataAPI]]
git-tree-sha1 = "e8119c1a33d267e16108be441a287a6981ba1630"
git-tree-sha1 = "8da84edb865b0b5b0100c0666a9bc9a0b71c553c"
uuid = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a"
version = "1.14.0"
version = "1.15.0"

[[deps.DataStructures]]
deps = ["Compat", "InteractiveUtils", "OrderedCollections"]
Expand Down Expand Up @@ -387,9 +387,9 @@ uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b"

[[deps.Distributions]]
deps = ["ChainRulesCore", "DensityInterface", "FillArrays", "LinearAlgebra", "PDMats", "Printf", "QuadGK", "Random", "SparseArrays", "SpecialFunctions", "Statistics", "StatsAPI", "StatsBase", "StatsFuns", "Test"]
git-tree-sha1 = "eead66061583b6807652281c0fbf291d7a9dc497"
git-tree-sha1 = "4f59fe4eb1308011bd33b390369cbad74e46eea4"
uuid = "31c24e10-a181-5473-b8eb-7969acd0382f"
version = "0.25.90"
version = "0.25.92"

[[deps.DocStringExtensions]]
deps = ["LibGit2"]
Expand Down Expand Up @@ -639,9 +639,9 @@ version = "1.12.2+2"

[[deps.HTTP]]
deps = ["Base64", "CodecZlib", "ConcurrentUtilities", "Dates", "Logging", "LoggingExtras", "MbedTLS", "NetworkOptions", "OpenSSL", "Random", "SimpleBufferStream", "Sockets", "URIs", "UUIDs"]
git-tree-sha1 = "ae9629d4485489d905e5da801eb314c2a2550cd7"
git-tree-sha1 = "41f7dfb2b20e7e8bf64f6b6fae98f4d2df027b06"
uuid = "cd3eb016-35fb-5094-929b-558a96fad6f3"
version = "1.9.0"
version = "1.9.4"

[[deps.HarfBuzz_jll]]
deps = ["Artifacts", "Cairo_jll", "Fontconfig_jll", "FreeType2_jll", "Glib_jll", "Graphite2_jll", "JLLWrappers", "Libdl", "Libffi_jll", "Pkg"]
Expand Down Expand Up @@ -673,9 +673,9 @@ version = "0.1.3"

[[deps.Insolation]]
deps = ["ArtifactWrappers", "Dates", "DelimitedFiles", "Interpolations"]
git-tree-sha1 = "6dc12da34ec01ff85424bb22889cff37d2aa3f10"
git-tree-sha1 = "44d6196470e8e74ad9d251fc9ecda2fbe21f67f6"
uuid = "e98cc03f-d57e-4e3c-b70c-8d51efe9e0d8"
version = "0.4.1"
version = "0.5.0"

[[deps.IntelOpenMP_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
Expand Down Expand Up @@ -1145,10 +1145,10 @@ uuid = "d96e819e-fc66-5662-9728-84c9c7592b0a"
version = "0.12.3"

[[deps.Parsers]]
deps = ["Dates", "SnoopPrecompile"]
git-tree-sha1 = "478ac6c952fddd4399e71d4779797c538d0ff2bf"
deps = ["Dates", "PrecompileTools", "UUIDs"]
git-tree-sha1 = "a5aef8d4a6e8d81f171b2bd4be5265b01384c74c"
uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0"
version = "2.5.8"
version = "2.5.10"

[[deps.Pipe]]
git-tree-sha1 = "6842804e7867b115ca9de748a0cf6b364523c16d"
Expand Down Expand Up @@ -1186,9 +1186,9 @@ version = "1.3.5"

[[deps.Plots]]
deps = ["Base64", "Contour", "Dates", "Downloads", "FFMPEG", "FixedPointNumbers", "GR", "JLFzf", "JSON", "LaTeXStrings", "Latexify", "LinearAlgebra", "Measures", "NaNMath", "Pkg", "PlotThemes", "PlotUtils", "PrecompileTools", "Preferences", "Printf", "REPL", "Random", "RecipesBase", "RecipesPipeline", "Reexport", "RelocatableFolders", "Requires", "Scratch", "Showoff", "SparseArrays", "Statistics", "StatsBase", "UUIDs", "UnicodeFun", "Unzip"]
git-tree-sha1 = "6c7f47fd112001fc95ea1569c2757dffd9e81328"
git-tree-sha1 = "d03ef538114b38f89d66776f2d8fdc0280f90621"
uuid = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
version = "1.38.11"
version = "1.38.12"

[[deps.Polyester]]
deps = ["ArrayInterface", "BitTwiddlingConvenienceFunctions", "CPUSummary", "IfElse", "ManualMemory", "PolyesterWeave", "Requires", "Static", "StrideArraysCore", "ThreadingUtilities"]
Expand Down Expand Up @@ -1340,10 +1340,10 @@ uuid = "7181ea78-2dcb-4de3-ab41-2b8ab5a31e74"
version = "0.3.5"

[[deps.Rotations]]
deps = ["LinearAlgebra", "Quaternions", "Random", "StaticArrays", "Statistics"]
git-tree-sha1 = "72a6abdcd088764878b473102df7c09bbc0548de"
deps = ["LinearAlgebra", "Quaternions", "Random", "StaticArrays"]
git-tree-sha1 = "54ccb4dbab4b1f69beb255a2c0ca5f65a9c82f08"
uuid = "6038ab10-8711-5258-84ad-4b1120ba62dc"
version = "1.4.0"
version = "1.5.1"

[[deps.SHA]]
uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce"
Expand Down Expand Up @@ -1441,9 +1441,9 @@ version = "0.7.8"

[[deps.StaticArrays]]
deps = ["LinearAlgebra", "Random", "StaticArraysCore", "Statistics"]
git-tree-sha1 = "c262c8e978048c2b095be1672c9bee55b4619521"
git-tree-sha1 = "8982b3607a212b070a5e46eea83eb62b4744ae12"
uuid = "90137ffa-7385-5640-81b9-e52037218182"
version = "1.5.24"
version = "1.5.25"

[[deps.StaticArraysCore]]
git-tree-sha1 = "6b7ba252635a5eff6a0b0664a41ee140a1c9e72a"
Expand Down
2 changes: 1 addition & 1 deletion experiments/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ Thermodynamics = "b60c26fb-14c3-4610-9d3e-2d17fe7ff00c"

[compat]
ClimaCore = "0.10"
Insolation = "0.3, 0.4"
Insolation = "0.3, 0.4, 0.5"
SciMLBase = "<1.51"
julia = "1.8"
7 changes: 6 additions & 1 deletion experiments/Standalone/Soil/evaporation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,12 @@ z_0b = 1e-5

SW_d = (t) -> eltype(t)(0)
LW_d = (t) -> eltype(t)(301.15^4 * 5.67e-8)
radiation = PrescribedRadiativeFluxes(FT, SW_d, LW_d; orbital_data=Insolation.OrbitalData())
radiation = PrescribedRadiativeFluxes(
FT,
SW_d,
LW_d;
orbital_data = Insolation.OrbitalData(Insolation.datadir()),
)
# Atmos
T_air = 301.15
rh = 0.38
Expand Down
13 changes: 10 additions & 3 deletions src/SharedUtilities/drivers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ end
) where {FT <: AbstractFloat}
Computes the turbulent surface flux terms at the ground for a standalone simulation,
including turbulent energy fluxes as well as the water vapor flux
including turbulent energy fluxes as well as the water vapor flux
(in units of m^3/m^2/s of water).
Positive fluxes indicate flow from the ground to the atmosphere.
Expand Down Expand Up @@ -240,14 +240,21 @@ end
Container for the prescribed radiation functions needed to drive land models in standalone mode.
$(DocStringExtensions.FIELDS)
"""
struct PrescribedRadiativeFluxes{FT, SW, LW, T} <: AbstractRadiativeDrivers{FT}
struct PrescribedRadiativeFluxes{FT, SW, LW, T, OD} <:
AbstractRadiativeDrivers{FT}
"Downward shortwave radiation function of time (W/m^2): positive indicates towards surface"
SW_d::SW
"Downward longwave radiation function of time (W/m^2): positive indicates towards surface"
LW_d::LW
"Sun zenith angle, in radians"
θs::T
function PrescribedRadiativeFluxes(FT, SW_d, LW_d; θs = nothing, orbital_data)
function PrescribedRadiativeFluxes(
FT,
SW_d,
LW_d;
θs = nothing,
orbital_data,
)
args = (SW_d, LW_d, θs, orbital_data)
@assert !isnothing(orbital_data)
return new{FT, typeof.(args)...}(args...)
Expand Down
24 changes: 12 additions & 12 deletions src/Vegetation/Canopy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ end
"""
CanopyModel{FT, RM, PM, SM, PHM, A, R, PS, D} <: AbstractModel{FT}
The model struct for the canopy, which contains
The model struct for the canopy, which contains
- the canopy model domain (a point for site-level simulations, or
an extended surface (plane/spherical surface) for regional or global simulations.
- subcomponent model type for radiative transfer. This is of type
`AbstractRadiationModel` and currently only the `BeerLambertModel` is
`AbstractRadiationModel` and currently only the `BeerLambertModel` is
supported.
- subcomponent model type for photosynthesis. This is of type
`AbstractPhotosynthesisModel`, and currently only the `FarquharModel`
Expand All @@ -74,10 +74,10 @@ prognostically solves Richards equation in the plant is available.
- canopy model parameters, which include parameters that are shared
between canopy model components or those needed to compute boundary
fluxes.
- The atmospheric conditions, which are either prescribed
- The atmospheric conditions, which are either prescribed
(of type `PrescribedAtmosphere`) or computed via a coupled simulation
(of type `CoupledAtmosphere`).
- The radiative flux conditions, which are either prescribed
- The radiative flux conditions, which are either prescribed
(of type `PrescribedRadiativeFluxes`) or computed via a coupled simulation
(of type `CoupledRadiativeFluxes`).
Expand Down Expand Up @@ -318,7 +318,7 @@ is better for performance as it saves looping over the state vector
multiple times.
The other sub-components rely heavily on each other,
so the version of the `CanopyModel` with these subcomponents
so the version of the `CanopyModel` with these subcomponents
has a single update_aux! function, given here.
"""
function ClimaLSM.make_update_aux(
Expand Down Expand Up @@ -448,7 +448,7 @@ end
"""
make_rhs(canopy::CanopyModel)
Creates and returns the rhs! for the `CanopyModel`.
Creates and returns the rhs! for the `CanopyModel`.
This allows for prognostic variables in each canopy component.
"""
Expand Down Expand Up @@ -476,7 +476,7 @@ end
Computes canopy transpiration using Monin-Obukhov Surface Theory,
the prescribed atmospheric conditions, and the canopy conductance.
Please note that in the future the SurfaceFluxes.jl code will compute
Please note that in the future the SurfaceFluxes.jl code will compute
fluxes taking into account the canopy conductance, so that
what is returned by `surface_fluxes` is correct. At present, it does not,
so we are adjusting for it after the fact here in both ET and LHF.
Expand Down Expand Up @@ -520,7 +520,7 @@ end
"""
ClimaLSM.surface_temperature(model::CanopyModel, Y, p, t)
A helper function which returns the surface temperature for the canopy
A helper function which returns the surface temperature for the canopy
model, which is stored in the aux state.
"""
function ClimaLSM.surface_temperature(model::CanopyModel, Y, p, t)
Expand All @@ -530,7 +530,7 @@ end
"""
ClimaLSM.surface_height(model::CanopyModel, Y, _...)
A helper function which returns the surface height for the canopy
A helper function which returns the surface height for the canopy
model, which is stored in the parameter struct.
"""
function ClimaLSM.surface_height(model::CanopyModel, _...)
Expand All @@ -540,7 +540,7 @@ end
"""
ClimaLSM.surface_specific_humidity(model::CanopyModel, Y, p)
A helper function which returns the surface specific humidity for the canopy
A helper function which returns the surface specific humidity for the canopy
model, which is stored in the aux state.
"""
function ClimaLSM.surface_specific_humidity(
Expand All @@ -562,8 +562,8 @@ end

"""
ClimaLSM.surface_air_density(model::CanopyModel, Y, p)
A helper function which computes and returns the surface air density for the canopy
A helper function which computes and returns the surface air density for the canopy
model.
"""
function ClimaLSM.surface_air_density(
Expand Down
2 changes: 1 addition & 1 deletion test/Bucket/albedo_map_bucket.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ include(joinpath(pkgdir(ClimaLSM), "parameters", "create_parameters.jl"))
npolynomial = 2,
),
]
orbital_data=Insolation.OrbitalData()
orbital_data = Insolation.OrbitalData(Insolation.datadir())


for bucket_domain in bucket_domains
Expand Down
2 changes: 1 addition & 1 deletion test/Bucket/snow_bucket_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ bucket_domains = [
),
]
init_temp(z::FT, value::FT) where {FT} = FT(value)
orbital_data = Insolation.OrbitalData()
orbital_data = Insolation.OrbitalData(Insolation.datadir())
for bucket_domain in bucket_domains

@testset "Conservation of water and energy" begin
Expand Down
2 changes: 1 addition & 1 deletion test/Bucket/soil_bucket_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ bucket_domains = [
npolynomial = 1,
),
]
orbital_data=Insolation.OrbitalData()
orbital_data = Insolation.OrbitalData(Insolation.datadir())
init_temp(z::FT, value::FT) where {FT} = FT(value)
for bucket_domain in bucket_domains
@testset "Zero flux RHS" begin
Expand Down
2 changes: 1 addition & 1 deletion test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Thermodynamics = "b60c26fb-14c3-4610-9d3e-2d17fe7ff00c"
CLIMAParameters = "0.7"
ClimaComms = "0.3, 0.4"
ClimaCore = "0.10"
Insolation = "0.3, 0.4"
Insolation = "0.3, 0.4, 0.5"
NLsolve = "4.5"
StaticArrays = "1.5"
SurfaceFluxes = "0.5, 0.6"
Expand Down
7 changes: 6 additions & 1 deletion test/Soil/climate_drivers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,12 @@ include(joinpath(pkgdir(ClimaLSM), "parameters", "create_parameters.jl"))
# Radiation
SW_d = (t) -> eltype(t)(500)
LW_d = (t) -> eltype(t)(5.67e-8 * 280.0^4.0)
radiation = PrescribedRadiativeFluxes(FT, SW_d, LW_d; orbital_data=Insolation.OrbitalData())
radiation = PrescribedRadiativeFluxes(
FT,
SW_d,
LW_d;
orbital_data = Insolation.OrbitalData(Insolation.datadir()),
)
# Atmos
precip = (t) -> eltype(t)(1e-8)
T_atmos = (t) -> eltype(t)(285.0)
Expand Down
2 changes: 1 addition & 1 deletion test/Vegetation/canopy_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ include(joinpath(pkgdir(ClimaLSM), "parameters", "create_parameters.jl"))
shortwave_radiation,
longwave_radiation;
θs = zenith_angle,
orbital_data = Insolation.OrbitalData(),
orbital_data = Insolation.OrbitalData(Insolation.datadir()),
)

# Plant Hydraulics
Expand Down
Loading

0 comments on commit 02fee8a

Please sign in to comment.