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.AbstractOutputGroupType
AbstractOutputGroup

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.TimeMeanType
TimeMean{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_varFunction
get_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.save_diagnosticsFunction
save_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_diagnosticsFunction
function init_diagnostics(
    names::Tuple,
    space::CC.Spaces.AbstractSpace;
    save = TimeManager.EveryTimestep(),
    operations = (;),
    output_dir = "",
    name_tag = "",
)

Initializes diagnostics groups.

Diagnostics Internal Functions

ClimaCoupler.Diagnostics.iterate_operationsFunction
iterate_operations(cs::Interfacer.CoupledSimulation, dg::DiagnosticsGroup, diags::CC.Fields.FieldVector)

Applies iteratively all specified diagnostics operations.

ClimaCoupler.Diagnostics.operationFunction
operation(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_saveFunction
pre_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_saveFunction
post_save(::TimeMean, cs::Interfacer.CoupledSimulation, dg::DiagnosticsGroup)

Resets accumulating fields and counts after saving the diagnostics.

ClimaCoupler.Diagnostics.save_time_formatFunction
save_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).