Skip to content

Commit 312022c

Browse files
committed
docstrings and cleanup [skip ci]
1 parent 3a03605 commit 312022c

File tree

10 files changed

+176
-30
lines changed

10 files changed

+176
-30
lines changed

docs/Manifest-v1.11.toml

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
julia_version = "1.11.6"
44
manifest_format = "2.0"
5-
project_hash = "db54675006462861514ee265bab28dd3115ca633"
5+
project_hash = "7a1797eba1307edb0c48ef7c65380e22175ed8c5"
66

77
[[deps.ADTypes]]
88
git-tree-sha1 = "7927b9af540ee964cc5d1b73293f1eb0b761a3a1"
@@ -371,6 +371,17 @@ weakdeps = ["SparseArrays"]
371371
[deps.ChainRulesCore.extensions]
372372
ChainRulesCoreSparseArraysExt = "SparseArrays"
373373

374+
[[deps.ClimaAnalysis]]
375+
deps = ["Artifacts", "Dates", "Interpolations", "NCDatasets", "NaNStatistics", "OrderedCollections", "Reexport", "Statistics", "Unitful"]
376+
git-tree-sha1 = "79279dce43bac22423b5d7b83fdf8209bf00a331"
377+
uuid = "29b5916a-a76c-4e73-9657-3c8fd22e65e6"
378+
version = "0.5.18"
379+
weakdeps = ["GeoMakie", "Makie"]
380+
381+
[deps.ClimaAnalysis.extensions]
382+
ClimaAnalysisGeoMakieExt = "GeoMakie"
383+
ClimaAnalysisMakieExt = "Makie"
384+
374385
[[deps.ClimaComms]]
375386
deps = ["Adapt", "Logging", "LoggingExtras"]
376387
git-tree-sha1 = "f3961fa943c1bbbc376af910cb98db67084dc642"
@@ -410,26 +421,13 @@ deps = ["ClimaComms", "ClimaCore", "ClimaDiagnostics", "ClimaParams", "ClimaTime
410421
path = ".."
411422
uuid = "08f4d4ce-cf43-44bb-ad95-9d2d5f413532"
412423
version = "0.17.2"
424+
weakdeps = ["BSON", "CSV", "CairoMakie", "ClimaAnalysis", "DataFrames", "DelimitedFiles", "Flux", "GeoMakie", "HTTP", "Poppler_jll", "Printf", "StatsBase"]
413425

414426
[deps.ClimaLand.extensions]
415427
FluxnetSimulationsExt = ["DelimitedFiles"]
416428
LandSimulationVisualizationExt = ["CairoMakie", "ClimaAnalysis", "GeoMakie", "Poppler_jll", "Printf", "StatsBase"]
417429
NeuralSnowExt = ["CSV", "DataFrames", "HTTP", "Flux", "StatsBase", "BSON"]
418430

419-
[deps.ClimaLand.weakdeps]
420-
BSON = "fbb218c0-5317-5bc6-957e-2ee96dd4b1f0"
421-
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
422-
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
423-
ClimaAnalysis = "29b5916a-a76c-4e73-9657-3c8fd22e65e6"
424-
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
425-
DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab"
426-
Flux = "587475ba-b771-5e3f-ad9e-33799f191a9c"
427-
GeoMakie = "db073c08-6b98-4ee5-b6a4-5efafb3259c6"
428-
HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3"
429-
Poppler_jll = "9c32591e-4766-534b-9725-b71a8799265b"
430-
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
431-
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
432-
433431
[[deps.ClimaLandSimulations]]
434432
deps = ["Bonito", "CairoMakie", "ClimaComms", "ClimaCore", "ClimaDiagnostics", "ClimaLand", "ClimaParams", "ClimaTimeSteppers", "ClimaUtilities", "DataFrames", "Dates", "DelimitedFiles", "Format", "HTTP", "Insolation", "Interpolations", "InverseFunctions", "JSON", "LaTeXStrings", "MutableArithmetics", "NLsolve", "PlotUtils", "RootSolvers", "SciMLBase", "StaticArrays", "Statistics", "StatsBase", "SurfaceFluxes", "Thermodynamics", "Unitful", "UnitfulMoles", "WGLMakie"]
435433
path = "../lib/ClimaLandSimulations"
@@ -2193,6 +2191,22 @@ git-tree-sha1 = "9b8215b1ee9e78a293f99797cd31375471b2bcae"
21932191
uuid = "77ba4419-2d1f-58cd-9bb1-8ffee604a2e3"
21942192
version = "1.1.3"
21952193

2194+
[[deps.NaNStatistics]]
2195+
deps = ["PrecompileTools", "Static", "StaticArrayInterface"]
2196+
git-tree-sha1 = "1d1d52981acffb4d6c30ba64ff927f12d378796a"
2197+
uuid = "b946abbf-3ea7-4610-9019-9858bfdeaf2d"
2198+
version = "0.6.53"
2199+
2200+
[deps.NaNStatistics.extensions]
2201+
NaNStatisticsDimensionalDataExt = "DimensionalData"
2202+
NaNStatisticsHwlocExt = "Hwloc"
2203+
NaNStatisticsUnitfulExt = "Unitful"
2204+
2205+
[deps.NaNStatistics.weakdeps]
2206+
DimensionalData = "0703355e-b756-11e9-17c0-8b28908087d0"
2207+
Hwloc = "0e44f5e4-bd66-52a0-8798-143a42290a1d"
2208+
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"
2209+
21962210
[[deps.NameResolution]]
21972211
deps = ["PrettyPrint"]
21982212
git-tree-sha1 = "1a0fa0e9613f46c9b8c11eee38ebb4f590013c5e"

docs/Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
33
BSON = "fbb218c0-5317-5bc6-957e-2ee96dd4b1f0"
44
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
55
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
6+
ClimaAnalysis = "29b5916a-a76c-4e73-9657-3c8fd22e65e6"
67
ClimaCore = "d414da3d-4745-48bb-8d80-42e94e092884"
78
ClimaDiagnostics = "1ecacbb8-0713-4841-9a07-eb5aa8a2d53f"
89
ClimaLand = "08f4d4ce-cf43-44bb-ad95-9d2d5f413532"

docs/list_tutorials.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ tutorials = [
4242
"For model developers" => [
4343
"Intro to standalone models" => "standalone/Usage/model_tutorial.jl",
4444
"Intro to multi-component models" => [
45-
"Blah" => "standalone/Usage/LSM_single_column_tutorial.jl",
45+
"Single column tutorial" => "standalone/Usage/LSM_single_column_tutorial.jl",
4646
"Adjusting boundary conditions for the soil" => "integrated/handling_soil_fluxes.jl",
4747
"Adjusting boundary conditions for the snow" => "integrated/handling_snow_fluxes.jl",
4848
],

docs/src/tutorials/integrated/snowy_land_fluxnet_tutorial.jl

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,15 @@ forcing = FluxnetSimulationsExt.prescribed_forcing_fluxnet(
5858
FT,
5959
);
6060
# LAI for the site - this uses our interface for working with MODIS data.
61-
(LAI, maxLAI) =
62-
FluxnetSimulationsExt.prescribed_LAI_fluxnet(site_ID, start_date);# eventually just get LAI
63-
61+
modis_lai_ncdata_path = ClimaLand.Artifacts.modis_lai_multiyear_paths(;
62+
start_date,
63+
end_date = stop_date,
64+
)
65+
LAI = ClimaLand.prescribed_lai_modis(
66+
modis_lai_ncdata_path,
67+
domain.space.surface,
68+
start_date,
69+
);
6470
# Setup the domain for the model:
6571
zmin = FT(-5) # in m
6672
zmax = FT(0) # in m

docs/src/tutorials/integrated/soil_canopy_fluxnet_tutorial.jl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,15 @@ forcing = FluxnetSimulationsExt.prescribed_forcing_fluxnet(
6565
FT,
6666
);
6767
# LAI for the site - this uses our interface for working with MODIS data.
68-
(LAI, maxLAI) =
69-
FluxnetSimulationsExt.prescribed_LAI_fluxnet(site_ID, start_date);# eventually just get LAI
68+
modis_lai_ncdata_path = ClimaLand.Artifacts.modis_lai_multiyear_paths(;
69+
start_date,
70+
end_date = stop_date,
71+
)
72+
LAI = ClimaLand.prescribed_lai_modis(
73+
modis_lai_ncdata_path,
74+
domain.space.surface,
75+
start_date,
76+
);
7077

7178
# Setup the domain for the model:
7279
zmin = FT(-2) # in m

ext/fluxnet_simulations/initial_conditions.jl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
"""
2+
make_set_fluxnet_initial_conditions(
3+
site_ID,
4+
start_date,
5+
hour_offset_from_UTC,
6+
model,
7+
)
8+
9+
Creates and returns a function `set_ic!(Y,p,t,model)` which
10+
updates `Y` in place with an estimated set of initial conditions
11+
based on the fluxnet observations at `site_ID` at the `start_date` in UTC,
12+
and the type of the `model`.
13+
In order to convert between local time and UTC, the hour offset from
14+
UTC is required.
15+
"""
116
function make_set_fluxnet_initial_conditions(
217
site_ID,
318
start_date,

ext/land_sim_vis/plotting_utils.jl

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,12 +322,30 @@ function make_ocean_masked_annual_timeseries(
322322
return nothing
323323
end
324324

325+
"""
326+
time_to_date(t::AbstractFloat, start_date)
325327
328+
Converts a time since the start_date (measured in seconds)
329+
to a date.
330+
"""
326331
function time_to_date(t::AbstractFloat, start_date)
327332
return start_date + Dates.Millisecond(round(1_000 * t))
328333
end
329334

335+
"""
336+
time_to_date(t::ITime, start_date)
337+
338+
Converts an ITime to a date using the epoch
339+
of the Itime, the counter, and the period (unit)
340+
of the counter.
341+
342+
Although the epoch can be different from the start_date,
343+
we usually think of the simulation time as relative to the start_date,
344+
and so we warn here if that is not the case
345+
"""
330346
function time_to_date(t::ITime, start_date)
347+
start_date != epoch &&
348+
@warn("$(start_date) is different from the simulation time epoch.")
331349
return t.epoch + t.counter * t.period
332350
end
333351

@@ -377,7 +395,7 @@ function make_diurnal_timeseries(
377395
diagnostics[1].output_writer,
378396
dn,
379397
)
380-
save_Δt = model_time[2] - model_time[1] # in seconds
398+
save_Δt = model_time[2] - model_time[1] # in seconds since the start_date. if model_time is an Itime, the epoch should be start_date
381399
model_dates = time_to_date.(model_time, start_date)
382400
spinup_idx = findfirst(spinup_date .<= model_dates)
383401
hour_of_day, model_diurnal_cycle = compute_diurnal_cycle(

src/integrated/land.jl

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,62 @@ struct LandModel{
9191
end
9292

9393
"""
94-
94+
LandModel{FT}(
95+
forcing,
96+
LAI,
97+
earth_param_set,
98+
domain::Union{ClimaLand.Domains.Column, ClimaLand.Domains.SphericalShell};
99+
soil = Soil.EnergyHydrology{FT}(
100+
domain,
101+
forcing,
102+
earth_param_set;
103+
prognostic_land_components = (:canopy, :snow, :soil, :soilco2),
104+
additional_sources = (ClimaLand.RootExtraction{FT}(),),
105+
runoff = ClimaLand.Soil.Runoff.SurfaceRunoff(),
106+
),
107+
soilco2 = Soil.Biogeochemistry.SoilCO2Model{FT}(
108+
domain,
109+
Soil.Biogeochemistry.SoilDrivers(
110+
Soil.Biogeochemistry.PrognosticMet(soil.parameters),
111+
PrescribedSoilOrganicCarbon{FT}(TimeVaryingInput((t) -> 5)),
112+
forcing.atmos,
113+
),
114+
),
115+
canopy = Canopy.CanopyModel{FT}(
116+
Domains.obtain_surface_domain(domain),
117+
(;
118+
atmos = forcing.atmos,
119+
radiation = forcing.radiation,
120+
ground = ClimaLand.PrognosticSoilConditions{FT}(),
121+
),
122+
LAI,
123+
earth_param_set;
124+
prognostic_land_components = (:canopy, :snow, :soil, :soilco2),
125+
),
126+
snow = Snow.SnowModel(
127+
FT,
128+
ClimaLand.Domains.obtain_surface_domain(domain),
129+
forcing,
130+
earth_param_set,
131+
Δt;
132+
prognostic_land_components = (:canopy, :snow, :soil, :soilco2),
133+
),
134+
) where {FT}
135+
136+
A convenience constructor for setting up the default LandModel,
137+
where all the parameterizations and parameter values are set to default values
138+
or passed in via the `earth_param_set`. The boundary conditions of all models
139+
correspond to `forcing` with the atmosphere, as specified by `forcing`, a NamedTuple
140+
of the form (;atmos, radiation), with `atmos` an AbstractAtmosphericDriver and `radiation`
141+
and AbstractRadiativeDriver. The leaf area index `LAI` must be provided (prescribed)
142+
as a TimeVaryingInput, and the domain must be a ClimaLand domain with a vertical extent.
143+
Finally, since the snow model requires the timestep, that is a required argument as well.
95144
"""
96145
function LandModel{FT}(
97146
forcing,
98147
LAI,
99148
earth_param_set,
100-
domain,
149+
domain::Union{ClimaLand.Domains.Column, ClimaLand.Domains.SphericalShell};
101150
Δt;
102151
soil = Soil.EnergyHydrology{FT}(
103152
domain,

src/integrated/soil_canopy_model.jl

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,53 @@ struct SoilCanopyModel{
7676
end
7777

7878
"""
79-
79+
SoilCanopyModel{FT}(
80+
forcing,
81+
LAI,
82+
earth_param_set,
83+
domain::Union{ClimaLand.Domains.Column, ClimaLand.Domains.SphericalShell};
84+
soil = Soil.EnergyHydrology{FT}(
85+
domain,
86+
forcing,
87+
earth_param_set;
88+
prognostic_land_components = (:canopy, :soil, :soilco2),
89+
additional_sources = (ClimaLand.RootExtraction{FT}(),),
90+
runoff = ClimaLand.Soil.Runoff.SurfaceRunoff(),
91+
),
92+
soilco2 = Soil.Biogeochemistry.SoilCO2Model{FT}(
93+
domain,
94+
Soil.Biogeochemistry.SoilDrivers(
95+
Soil.Biogeochemistry.PrognosticMet(soil.parameters),
96+
PrescribedSoilOrganicCarbon{FT}(TimeVaryingInput((t) -> 5)),
97+
forcing.atmos,
98+
),
99+
),
100+
canopy = Canopy.CanopyModel{FT}(
101+
Domains.obtain_surface_domain(domain),
102+
(;
103+
atmos = forcing.atmos,
104+
radiation = forcing.radiation,
105+
ground = ClimaLand.PrognosticSoilConditions{FT}(),
106+
),
107+
LAI,
108+
earth_param_set;
109+
prognostic_land_components = (:canopy, :soil, :soilco2),
110+
),
111+
) where {FT}
112+
113+
A convenience constructor for setting up the default SoilCanpyModel,
114+
where all the parameterizations and parameter values are set to default values
115+
or passed in via the `earth_param_set`. The boundary conditions of all models
116+
correspond to `forcing` with the atmosphere, as specified by `forcing`, a NamedTuple
117+
of the form (;atmos, radiation), with `atmos` an AbstractAtmosphericDriver and `radiation`
118+
and AbstractRadiativeDriver. The leaf area index `LAI` must be provided (prescribed)
119+
as a TimeVaryingInput, and the domain must be a ClimaLand domain with a vertical extent.
80120
"""
81121
function SoilCanopyModel{FT}(
82122
forcing,
83123
LAI,
84124
earth_param_set,
85-
domain;
125+
domain::Union{ClimaLand.Domains.Column, ClimaLand.Domains.SphericalShell};
86126
soil = Soil.EnergyHydrology{FT}(
87127
domain,
88128
forcing,

src/simulations/Simulations.jl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,6 @@ function solve!(landsim::LandSimulation)
215215
end
216216
end
217217

218-
function get_dt(landsim::LandSimulation)
219-
return landsim._integrator.dt
220-
end
221-
222218
"""
223219
ClimaComms.context(landsim::LandSimulation)
224220

0 commit comments

Comments
 (0)