Skip to content

Commit

Permalink
Remove t_start
Browse files Browse the repository at this point in the history
  • Loading branch information
Sbozzolo committed Sep 11, 2024
1 parent 1db54a8 commit 25a03bf
Show file tree
Hide file tree
Showing 16 changed files with 100 additions and 177 deletions.
11 changes: 5 additions & 6 deletions docs/src/diagnostics/developers_diagnostics.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Internally, this is done by using the [`ClimaDiagnostics.jl`](https://github.com
`add_diagnostic_variable!`, and dispatch off the type of land\_model to define how to compute a diagnostic (for example, surface temperature is computed in `p.bucket.T_sfc` in the bucket model).
- compute methods are defined in a separate file, for example, `bucket_compute_methods.jl`.
- `standard_diagnostic_frequencies.jl` defines standard functions to schedule diagnostics, for example, hourly average or monthly max, these functions are called on a list of diagnostic variables. As developers, we can add more standard functions that users may want to have access to easily in this file.
- `default_diagnostics.jl` defines default diagnostics functions to use on a model simulation. For example, `default_diagnostics(land_model::BucketModel, t_start; output_writer)`.
- `default_diagnostics.jl` defines default diagnostics functions to use on a model simulation. For example, `default_diagnostics(land_model::BucketModel, output_writer)`.
will return a `ScheduledDiagnostics` that computes hourly averages for all Bucket variables, along with their metadata, ready to be written on a NetCDF file when running a Bucket simulation.

The following section give more details on these functions, along with examples. As developers, we want to extand these functionality as ClimaLand progresses.
Expand Down Expand Up @@ -66,7 +66,7 @@ For each model, we define a function `default_diagnostics` which will define wha
on what schedule (for example, hourly average). For example,

```Julia
function default_diagnostics(land_model::BucketModel, t_start; output_writer)
function default_diagnostics(land_model::BucketModel{FT}; output_writer) where {FT}

define_diagnostics!(land_model)

Expand All @@ -87,7 +87,7 @@ function default_diagnostics(land_model::BucketModel, t_start; output_writer)
]

default_outputs =
hourly_averages(bucket_diagnostics...; output_writer, t_start)
hourly_averages(FT, bucket_diagnostics...; output_writer)
return [default_outputs...]
end
```
Expand All @@ -103,11 +103,10 @@ If `average_period = :hourly`, `default_outputs` calls `hourly_averages`, et cet
We defined some functions of diagnostic schedule that may often be used in `standard_diagnostic_frequencies.jl`, for example

```Julia
hourly_averages(short_names...; output_writer, t_start) = common_diagnostics(
60 * 60 * one(t_start),
hourly_averages(FT, short_names...; output_writer) = common_diagnostics(
60 * 60 * one(FT),
(+),
output_writer,
t_start,
short_names...;
pre_output_hook! = average_pre_output_hook!,
)
Expand Down
9 changes: 4 additions & 5 deletions docs/src/diagnostics/users_diagnostics.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ t0 = 0 # the starting time of your simulation

reference_date = DateTime(2024) # reference_date is the DateTime of your starting time

diags = ClimaLand.default_diagnostics(model, t0, reference_date; output_writer = nc_writer)
diags = ClimaLand.default_diagnostics(model, reference_date; output_writer = nc_writer)

diagnostic_handler =
ClimaDiagnostics.DiagnosticsHandler(diags, Y, p, t0; dt = Δt)
Expand Down Expand Up @@ -118,11 +118,10 @@ add_diagnostic_variable!(
### Define how to schedule your variables. For example, you want the seasonal maximum of your variables, where season is defined as 90 days.

```Julia
seasonal_maxs(short_names...; output_writer, t_start) = common_diagnostics(
90 * 24 * 60 * 60 * one(t_start),
seasonal_maxs(FT, short_names...; output_writer) = common_diagnostics(
90 * 24 * 60 * 60 * one(FT),
max,
output_writer,
t_start,
short_names...,
)
```
Expand All @@ -134,7 +133,7 @@ Now, you can call your schedule with your variables.
```Julia
my_custom_diagnostics = ["lhf", "bor"]

diags = seasonal_maxs(my_custom_diagnostics...; output_writer, t_start)
diags = seasonal_maxs(FT, my_custom_diagnostics...; output_writer)
```

### Analyze your simulation output
Expand Down
10 changes: 0 additions & 10 deletions experiments/benchmarks/land.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ function setup_prob(t0, tf, Δt; nelements = (101, 15))
subsurface_space = domain.space.subsurface

ref_time = DateTime(2021)
t_start = 0.0

# Forcing data
era5_artifact_path =
Expand All @@ -82,7 +81,6 @@ function setup_prob(t0, tf, Δt; nelements = (101, 15))
"rf",
surface_space;
reference_date = ref_time,
t_start,
regridder_type,
file_reader_kwargs = (; preprocess_func = (data) -> -data / 3600,),
)
Expand All @@ -92,7 +90,6 @@ function setup_prob(t0, tf, Δt; nelements = (101, 15))
"sf",
surface_space;
reference_date = ref_time,
t_start,
regridder_type,
file_reader_kwargs = (; preprocess_func = (data) -> -data / 3600,),
)
Expand All @@ -102,23 +99,20 @@ function setup_prob(t0, tf, Δt; nelements = (101, 15))
"ws",
surface_space;
reference_date = ref_time,
t_start,
regridder_type,
)
q_atmos = TimeVaryingInput(
joinpath(era5_artifact_path, "era5_2021_0.9x1.25_clima.nc"),
"q",
surface_space;
reference_date = ref_time,
t_start,
regridder_type,
)
P_atmos = TimeVaryingInput(
joinpath(era5_artifact_path, "era5_2021_0.9x1.25.nc"),
"sp",
surface_space;
reference_date = ref_time,
t_start,
regridder_type,
)

Expand All @@ -127,7 +121,6 @@ function setup_prob(t0, tf, Δt; nelements = (101, 15))
"t2m",
surface_space;
reference_date = ref_time,
t_start,
regridder_type,
)
h_atmos = FT(10)
Expand All @@ -150,7 +143,6 @@ function setup_prob(t0, tf, Δt; nelements = (101, 15))
"ssrd",
surface_space;
reference_date = ref_time,
t_start,
regridder_type,
file_reader_kwargs = (; preprocess_func = (data) -> data / 3600,),
)
Expand All @@ -159,7 +151,6 @@ function setup_prob(t0, tf, Δt; nelements = (101, 15))
"strd",
surface_space;
reference_date = ref_time,
t_start,
regridder_type,
file_reader_kwargs = (; preprocess_func = (data) -> data / 3600,),
)
Expand Down Expand Up @@ -493,7 +484,6 @@ function setup_prob(t0, tf, Δt; nelements = (101, 15))
"lai",
surface_space;
reference_date = ref_time,
t_start,
regridder_type,
file_reader_kwargs = (;
preprocess_func = (data) -> data > 0.05 ? data : 0.0,
Expand Down
2 changes: 0 additions & 2 deletions experiments/benchmarks/richards.jl
Original file line number Diff line number Diff line change
Expand Up @@ -196,14 +196,12 @@ function setup_prob(t0, tf, Δt; nelements = (101, 15))
# 1. Convert precipitation to be negative (as it is downwards)
# 2. Convert accumulations over an hour to a rate per second
ref_time = DateTime(2021)
t_start = 0.0
# Precipitation:
precip = TimeVaryingInput(
joinpath(era5_artifact_path, "era5_2021_0.9x1.25.nc"),
"tp",
surface_space;
reference_date = ref_time,
t_start,
regridder_type,
file_reader_kwargs = (; preprocess_func = (data) -> -data / 3600,),
)
Expand Down
11 changes: 0 additions & 11 deletions experiments/integrated/global/global_soil_canopy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ surface_space = domain.space.surface
subsurface_space = domain.space.subsurface

ref_time = DateTime(2021);
t_start = 0.0

# Forcing data
era5_artifact_path =
Expand All @@ -67,7 +66,6 @@ precip = TimeVaryingInput(
"rf",
surface_space;
reference_date = ref_time,
t_start,
regridder_type,
file_reader_kwargs = (; preprocess_func = (data) -> -data / 3600,),
)
Expand All @@ -77,7 +75,6 @@ snow_precip = TimeVaryingInput(
"sf",
surface_space;
reference_date = ref_time,
t_start,
regridder_type,
file_reader_kwargs = (; preprocess_func = (data) -> -data / 3600,),
)
Expand All @@ -87,23 +84,20 @@ u_atmos = TimeVaryingInput(
"ws",
surface_space;
reference_date = ref_time,
t_start,
regridder_type,
)
q_atmos = TimeVaryingInput(
joinpath(era5_artifact_path, "era5_2021_0.9x1.25_clima.nc"),
"q",
surface_space;
reference_date = ref_time,
t_start,
regridder_type,
)
P_atmos = TimeVaryingInput(
joinpath(era5_artifact_path, "era5_2021_0.9x1.25.nc"),
"sp",
surface_space;
reference_date = ref_time,
t_start,
regridder_type,
)

Expand All @@ -112,7 +106,6 @@ T_atmos = TimeVaryingInput(
"t2m",
surface_space;
reference_date = ref_time,
t_start,
regridder_type,
)
h_atmos = FT(10);
Expand All @@ -135,7 +128,6 @@ SW_d = TimeVaryingInput(
"ssrd",
surface_space;
reference_date = ref_time,
t_start,
regridder_type,
file_reader_kwargs = (; preprocess_func = (data) -> data / 3600,),
)
Expand All @@ -144,7 +136,6 @@ LW_d = TimeVaryingInput(
"strd",
surface_space;
reference_date = ref_time,
t_start,
regridder_type,
file_reader_kwargs = (; preprocess_func = (data) -> data / 3600,),
)
Expand Down Expand Up @@ -241,7 +232,6 @@ LAIfunction = TimeVaryingInput(
"lai",
surface_space;
reference_date = ref_time,
t_start,
regridder_type,
file_reader_kwargs = (;
preprocess_func = (data) -> data > 0.05 ? data : 0.0,
Expand Down Expand Up @@ -374,7 +364,6 @@ nc_writer = ClimaDiagnostics.Writers.NetCDFWriter(subsurface_space, output_dir)

diags = ClimaLand.default_diagnostics(
land,
t0,
ref_time;
output_writer = nc_writer,
average_period = :hourly,
Expand Down
11 changes: 0 additions & 11 deletions experiments/long_runs/land.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ function setup_prob(t0, tf, Δt; outdir = outdir, nelements = (101, 15))
subsurface_space = domain.space.subsurface

ref_time = DateTime(2021)
t_start = t0
# Forcing data
era5_artifact_path =
ClimaLand.Artifacts.era5_land_forcing_data2021_folder_path(; context) # Precipitation:
Expand All @@ -82,7 +81,6 @@ function setup_prob(t0, tf, Δt; outdir = outdir, nelements = (101, 15))
"rf",
surface_space;
reference_date = ref_time,
t_start,
regridder_type,
file_reader_kwargs = (; preprocess_func = (data) -> -data / 3600,),
)
Expand All @@ -92,7 +90,6 @@ function setup_prob(t0, tf, Δt; outdir = outdir, nelements = (101, 15))
"sf",
surface_space;
reference_date = ref_time,
t_start,
regridder_type,
file_reader_kwargs = (; preprocess_func = (data) -> -data / 3600,),
)
Expand All @@ -102,23 +99,20 @@ function setup_prob(t0, tf, Δt; outdir = outdir, nelements = (101, 15))
"ws",
surface_space;
reference_date = ref_time,
t_start,
regridder_type,
)
q_atmos = TimeVaryingInput(
joinpath(era5_artifact_path, "era5_2021_0.9x1.25_clima.nc"),
"q",
surface_space;
reference_date = ref_time,
t_start,
regridder_type,
)
P_atmos = TimeVaryingInput(
joinpath(era5_artifact_path, "era5_2021_0.9x1.25.nc"),
"sp",
surface_space;
reference_date = ref_time,
t_start,
regridder_type,
)

Expand All @@ -127,7 +121,6 @@ function setup_prob(t0, tf, Δt; outdir = outdir, nelements = (101, 15))
"t2m",
surface_space;
reference_date = ref_time,
t_start,
regridder_type,
)
h_atmos = FT(10)
Expand All @@ -150,7 +143,6 @@ function setup_prob(t0, tf, Δt; outdir = outdir, nelements = (101, 15))
"ssrd",
surface_space;
reference_date = ref_time,
t_start,
regridder_type,
file_reader_kwargs = (; preprocess_func = (data) -> data / 3600,),
)
Expand All @@ -159,7 +151,6 @@ function setup_prob(t0, tf, Δt; outdir = outdir, nelements = (101, 15))
"strd",
surface_space;
reference_date = ref_time,
t_start,
regridder_type,
file_reader_kwargs = (; preprocess_func = (data) -> data / 3600,),
)
Expand Down Expand Up @@ -494,7 +485,6 @@ function setup_prob(t0, tf, Δt; outdir = outdir, nelements = (101, 15))
"lai",
surface_space;
reference_date = ref_time,
t_start,
regridder_type,
file_reader_kwargs = (;
preprocess_func = (data) -> data > 0.05 ? data : 0.0,
Expand Down Expand Up @@ -620,7 +610,6 @@ function setup_prob(t0, tf, Δt; outdir = outdir, nelements = (101, 15))

diags = ClimaLand.default_diagnostics(
land,
t0,
ref_time;
output_writer = nc_writer,
output_vars = :short,
Expand Down
Loading

0 comments on commit 25a03bf

Please sign in to comment.