Skip to content

Commit

Permalink
Tr/fix test warnings (#925)
Browse files Browse the repository at this point in the history
* Fix warnings in tests

Replace deprecated reference_date arg

The ClimaUtilities DataHandler, TimeVaryingInput, and EveryCalendarDtSchedule
function were called with reference_date as an argument, which is
deprecated. This commit replaces them with start_date, and replaces
other uses of reference_date as an arg to functions that pass the arg
to EveryCalendarDtSchedule.

Fix warning in test for unused type declaration

Update common_diagnostics example in docs

Annotate start date

* Bump ClimaUtilities compat

ClimaUtilities compat bumped from 0.1.16 to 0.1.17.
This allows call to detect_restart_file to allways use
the non-deprecated argument for style.
  • Loading branch information
imreddyTeja authored Nov 20, 2024
1 parent d3afe21 commit 8e915fc
Show file tree
Hide file tree
Showing 13 changed files with 135 additions and 153 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ ClimaComms = "0.6"
ClimaCore = "0.14.19"
ClimaDiagnostics = "0.2.10"
ClimaParams = "0.10.2"
ClimaUtilities = "0.1.16"
ClimaUtilities = "0.1.17"
DataFrames = "1.4"
Dates = "1"
DocStringExtensions = "0.9"
Expand Down
1 change: 1 addition & 0 deletions docs/src/diagnostics/developers_diagnostics.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ hourly_averages(FT, short_names...; output_writer) = common_diagnostics(
60 * 60 * one(FT),
(+),
output_writer,
nothing, # start_date
short_names...;
pre_output_hook! = average_pre_output_hook!,
)
Expand Down
1 change: 1 addition & 0 deletions docs/src/diagnostics/users_diagnostics.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ seasonal_maxs(FT, short_names...; output_writer) = common_diagnostics(
90 * 24 * 60 * 60 * one(FT),
max,
output_writer,
nothing, # start_date
short_names...,
)
```
Expand Down
2 changes: 1 addition & 1 deletion experiments/benchmarks/richards.jl
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ function setup_prob(t0, tf, Δt; nelements = (101, 15))
joinpath(era5_artifact_path, "era5_2021_0.9x1.25.nc"),
"tp",
surface_space;
reference_date = start_date,
start_date,
regridder_type,
file_reader_kwargs = (; preprocess_func = (data) -> -data / 3600,),
)
Expand Down
2 changes: 1 addition & 1 deletion experiments/standalone/Soil/richards_runoff.jl
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ precip = TimeVaryingInput(
joinpath(era5_artifact_path, "era5_2021_0.9x1.25.nc"),
"tp",
surface_space;
reference_date = start_date,
start_date,
regridder_type,
file_reader_kwargs = (; preprocess_func = (data) -> -data / 3600,),
)
Expand Down
62 changes: 23 additions & 39 deletions src/diagnostics/default_diagnostics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default_diagnostics
period,
reduction,
output_writer,
reference_date,
start_date,
short_names...;
pre_output_hook! = nothing,
)
Expand All @@ -25,15 +25,15 @@ function common_diagnostics(
period,
reduction,
output_writer,
reference_date,
start_date,
short_names...;
pre_output_hook! = nothing,
)
return vcat(
map(short_names) do short_name
output_schedule_func =
period isa Period ?
EveryCalendarDtSchedule(period; reference_date) :
EveryCalendarDtSchedule(period; start_date) :
EveryDtSchedule(period)
return ScheduledDiagnostic(
variable = get_diagnostic_variable(short_name),
Expand All @@ -52,7 +52,7 @@ include("standard_diagnostic_frequencies.jl")
# Bucket
function default_diagnostics(
land_model::BucketModel{FT},
reference_date;
start_date;
output_writer,
average_period = :daily,
) where {FT}
Expand Down Expand Up @@ -80,21 +80,17 @@ function default_diagnostics(
FT,
bucket_diagnostics...;
output_writer,
reference_date,
start_date,
)
elseif average_period == :daily
default_outputs = daily_averages(
FT,
bucket_diagnostics...;
output_writer,
reference_date,
)
default_outputs =
daily_averages(FT, bucket_diagnostics...; output_writer, start_date)
elseif average_period == :monthly
default_outputs = monthly_averages(
FT,
bucket_diagnostics...;
output_writer,
reference_date,
start_date,
)
end

Expand All @@ -104,7 +100,7 @@ end
# SoilCanopyModel
function default_diagnostics(
land_model::SoilCanopyModel{FT},
reference_date;
start_date;
output_writer,
output_vars = :long,
average_period = :daily,
Expand Down Expand Up @@ -200,21 +196,21 @@ function default_diagnostics(
FT,
soilcanopy_diagnostics...;
output_writer,
reference_date,
start_date,
)
elseif average_period == :daily
default_outputs = daily_averages(
FT,
soilcanopy_diagnostics...;
output_writer,
reference_date,
start_date,
)
elseif average_period == :monthly
default_outputs = monthly_averages(
FT,
soilcanopy_diagnostics...;
output_writer,
reference_date,
start_date,
)
end

Expand All @@ -225,7 +221,7 @@ end
# SoilModel
function default_diagnostics(
land_model::EnergyHydrology{FT},
reference_date;
start_date;
output_writer,
average_period = :daily,
) where {FT}
Expand All @@ -235,26 +231,14 @@ function default_diagnostics(
soil_diagnostics = ["swc", "si", "sie"]

if average_period == :hourly
default_outputs = hourly_averages(
FT,
soil_diagnostics...;
output_writer,
reference_date,
)
default_outputs =
hourly_averages(FT, soil_diagnostics...; output_writer, start_date)
elseif average_period == :daily
default_outputs = daily_averages(
FT,
soil_diagnostics...;
output_writer,
reference_date,
)
default_outputs =
daily_averages(FT, soil_diagnostics...; output_writer, start_date)
elseif average_period == :monthly
default_outputs = monthly_averages(
FT,
soil_diagnostics...;
output_writer,
reference_date,
)
default_outputs =
monthly_averages(FT, soil_diagnostics...; output_writer, start_date)
end

return [default_outputs...]
Expand All @@ -263,7 +247,7 @@ end
# Land Model
function default_diagnostics(
land_model::LandModel{FT},
reference_date;
start_date;
output_writer,
output_vars = :long,
average_period = :daily,
Expand Down Expand Up @@ -360,21 +344,21 @@ function default_diagnostics(
FT,
snowyland_diagnostics...;
output_writer,
reference_date,
start_date,
)
elseif average_period == :daily
default_outputs = daily_averages(
FT,
snowyland_diagnostics...;
output_writer,
reference_date,
start_date,
)
elseif average_period == :monthly
default_outputs = monthly_averages(
FT,
snowyland_diagnostics...;
output_writer,
reference_date,
start_date,
)
end
end
Loading

0 comments on commit 8e915fc

Please sign in to comment.