Diagnostics
This module contains functions for defining, gathering and outputting model diagnostics from the Coupler.
Note that ClimaCoupler.Diagnostics
is deployed online (i.e., as the model runs), working with cached model data (usually) on the model grid. This does not include offline post-processing (i.e., manipulating saved model output after the model is run, such as regridding data to the latitude-longitude grid). See ClimaCoupler.PostProcessor
for offline model data treatment.
Diagnostics API
ClimaCoupler.Diagnostics.AbstractOutputGroup
— TypeAbstractOutputGroup
Abstract type for ClimaCoupler's output diagnostics groups. Each diagnostic group should contain fields that are of the same type and size, so the extended methods for the group's operation functions work in the same way for all the fields.
ClimaCoupler.Diagnostics.DiagnosticsGroup
— TypeDiagnosticsGroup{S, NTO <: NamedTuple}
Defines a concrete diagnostics group type with fields field_vector
, operations
, save
, output_dir
and name_tag
.
ClimaCoupler.Diagnostics.AbstractDiagnosticsOperations
— TypeAbstractDiagnosticsOperations
Abstract type for operations to be performed on ClimaCoupler's diagnostics.
ClimaCoupler.Diagnostics.TimeMean
— TypeTimeMean{C}
Defines a concrete operation type for time-averaged diagnostics. The counter ct
is used to accumulate the sum of the diagnostics.
ClimaCoupler.Diagnostics.get_var
— Functionget_var(cs::Interfacer.CoupledSimulation, x)
Defines variable extraction from the coupler simulation. User specific diagnostics should extend this function in the experiments folder.
Example:
getvar(cs, ::Val{:Tsfc}) = cs.fields.T_S
ClimaCoupler.Diagnostics.accumulate_diagnostics!
— Functionaccumulate_diagnostics!(cs::Interfacer.CoupledSimulation)
Accumulates user-defined diagnostics listed in the in the field_vector
of each dg
.
ClimaCoupler.Diagnostics.save_diagnostics
— Functionsave_diagnostics(cs::Interfacer.CoupledSimulation)
save_diagnostics(cs::Interfacer.CoupledSimulation, dg::DiagnosticsGroup, output_dir::String)
Saves all entries in dg
in separate HDF5 files per variable in output_dir
.
ClimaCoupler.Diagnostics.init_diagnostics
— Functionfunction init_diagnostics(
names::Tuple,
space::CC.Spaces.AbstractSpace;
save = TimeManager.EveryTimestep(),
operations = (;),
output_dir = "",
name_tag = "",
)
Initializes diagnostics groups.
Diagnostics Internal Functions
ClimaCoupler.Diagnostics.collect_diags
— Functioncollect_diags(cs::Interfacer.CoupledSimulation, dg::DiagnosticsGroup)
Collects diagnostics in diags names.
ClimaCoupler.Diagnostics.iterate_operations
— Functioniterate_operations(cs::Interfacer.CoupledSimulation, dg::DiagnosticsGroup, diags::CC.Fields.FieldVector)
Applies iteratively all specified diagnostics operations.
ClimaCoupler.Diagnostics.operation
— Functionoperation(cs::Interfacer.CoupledSimulation, dg::DiagnosticsGroup, new_diags::CC.Fields.FieldVector, ::TimeMean)
Accumulates in time all entries in new_diags
and saves the result in dg.field_vector
, while increasing the dg.ct
counter.
operation(cs::Interfacer.CoupledSimulation, dg::DiagnosticsGroup, new_diags::CC.Fields.FieldVector, ::Nothing)
Accumulates in time all entries in new_diags
and saves the result in dg.field_vector
, while increasing the dg.ct
counter.
ClimaCoupler.Diagnostics.pre_save
— Functionpre_save(::TimeMean, cs::Interfacer.CoupledSimulation, dg::DiagnosticsGroup)
Divides the accumulated sum by 'ct' to form the mean, before saving the diagnostics.
pre_save(::Nothing, cs::Interfacer.CoupledSimulation, dg::DiagnosticsGroup
Collects variables and performs all specified operations before saving the snapshot diagnostics.
ClimaCoupler.Diagnostics.post_save
— Functionpost_save(::TimeMean, cs::Interfacer.CoupledSimulation, dg::DiagnosticsGroup)
Resets accumulating fields and counts after saving the diagnostics.
ClimaCoupler.Diagnostics.save_time_format
— Functionsave_time_format(date::Dates.DateTime, ::TimeManager.Monthly)
Converts the DateTime date
to the conventional Unix format (seconds elapsed since 00:00:00 UTC on 1 January 1970).