Diagnostics¶
Diagnostics are separate objects (instances of subclasses of RogerDiagnostic
)
responsible for handling I/O, restart mechanics, and monitoring of the numerical
solution. All available diagnostics are instantiated and added to a dictionary
attribute RogerState.diagnostics
(with a key determined by their name attribute).
Options for diagnostics may be set during the RogerSetup.set_diagnostics()
method:
Output aggregated to daily:
class MyModelSetup(RogerSetup):
...
def set_diagnostics(self, state):
diagnostics = state.diagnostics
diagnostics['rate'].output_variables = ['transp', 'q_ss']
diagnostics['rate'].sampling_frequency = 1
diagnostics['rate'].output_frequency = 24 * 60 * 60
Output aggregated to hourly:
class MyModelSetup(RogerSetup):
...
def set_diagnostics(self, state):
diagnostics = state.diagnostics
diagnostics['rate'].output_variables = ['transp', 'q_ss']
diagnostics['rate'].sampling_frequency = 1
diagnostics['rate'].output_frequency = 60 * 60
Output aggregated to 10 minutes:
class MyModelSetup(RogerSetup):
...
def set_diagnostics(self, state):
diagnostics = state.diagnostics
diagnostics['rate'].output_variables = ['transp', 'q_ss']
diagnostics['rate'].sampling_frequency = 1
diagnostics['rate'].output_frequency = 10 * 60
Please not, that within the adaptive-time stepping greater time steps than provided output_frequency will not be downscaled (e.g. from daily to hourly).
Base class¶
This class implements some common logic for all diagnostics. This makes it easy to write your own diagnostics: Just derive from this class, and implement the virtual functions.
- class roger.diagnostics.base.RogerDiagnostic(state)[source]¶
Bases:
object
Base class for diagnostics. Provides an interface and wrappers for common I/O.
Any diagnostic needs to implement the 9 interface methods and set some attributes.
- name = None¶
Name that identifies the current diagnostic
Available diagnostics¶
Currently, the following diagnostics are implemented and added to
RogerState.diagnostics
:
Snapshot¶
- class roger.diagnostics.snapshot.Snapshot(state)[source]¶
Bases:
RogerDiagnostic
Writes snapshots of the current solution. Also reads and writes the main restart data required for restarting a Roger simulation.
- output_path = '{identifier}.snapshot.nc'¶
File to write to. May contain format strings that are replaced with Roger attributes.
- name = 'snapshot'¶
- output_frequency = None¶
Frequency (in seconds) in which output is written.
Average¶
- class roger.diagnostics.average.Average(state)[source]¶
Bases:
RogerDiagnostic
Average output diagnostic.
All registered variables are summed up when
diagnose()
is called, and averaged and output upon callingoutput()
.- name = 'average'¶
- output_path = '{identifier}.average.nc'¶
File to write to. May contain format strings that are replaced with Roger attributes.
- output_frequency = None¶
Frequency (in seconds) in which output is written.
- sampling_frequency = None¶
Frequency (in seconds) in which variables are accumulated.
- output_variables = None¶
Iterable containing all variables to be averaged. Changes have no effect after
initialize
has been called.
Minimum¶
- class roger.diagnostics.minimum.Minimum(state)[source]¶
Bases:
RogerDiagnostic
Minimum output diagnostic.
All registered variables are stacked when
diagnose()
is called, and returns minimum and output upon callingoutput()
.- name = 'minimum'¶
- output_path = '{identifier}.minimum.nc'¶
File to write to. May contain format strings that are replaced with Roger attributes.
- output_frequency = None¶
Frequency (in seconds) in which output is written.
- sampling_frequency = None¶
Frequency (in seconds) in which variables are accumulated.
- output_variables = None¶
Iterable containing all variables to be minimumd. Changes have no effect after
initialize
has been called.
Maximum¶
- class roger.diagnostics.maximum.Maximum(state)[source]¶
Bases:
RogerDiagnostic
Maximum output diagnostic.
All registered variables are stacked when
diagnose()
is called, and returns maximum and output upon callingoutput()
.- name = 'maximum'¶
- output_path = '{identifier}.maximum.nc'¶
File to write to. May contain format strings that are replaced with Roger attributes.
- output_frequency = None¶
Frequency (in seconds) in which output is written.
- sampling_frequency = None¶
Frequency (in seconds) in which variables are accumulated.
- output_variables = None¶
Iterable containing all variables to be maximumd. Changes have no effect after
initialize
has been called.
Rate¶
- class roger.diagnostics.rate.Rate(state)[source]¶
Bases:
RogerDiagnostic
Rate output diagnostic.
All registered variables are summed up when
diagnose()
is called, and output upon callingoutput()
.- name = 'rate'¶
- output_frequency = None¶
Frequency (in hours) in which output is written.
- sampling_frequency = None¶
Frequency (in hours) in which variables are accumulated.
- output_variables = None¶
Iterable containing all variables to be averaged. Changes have no effect after
initialize
has been called.
Collect¶
- class roger.diagnostics.collect.Collect(state)[source]¶
Bases:
RogerDiagnostic
Collect output diagnostic.
All registered variables are collected when
diagnose()
is called, and collected upon callingoutput()
.- name = 'collect'¶
- output_path = '{identifier}.collect.nc'¶
File to write to. May contain format strings that are replaced with Roger attributes.
- output_frequency = None¶
Frequency (in seconds) in which output is written.
- sampling_frequency = None¶
Frequency (in seconds) in which variables are accumulated.
- output_variables = None¶
Iterable containing all variables to be volumed. Changes have no effect after
initialize
has been called.
Constant¶
- class roger.diagnostics.constant.Constant(state)[source]¶
Bases:
RogerDiagnostic
Constant output diagnostic.
All registered variables are collected when
diagnose()
is called, and written upon callingoutput()
at beginning of simulation.- name = 'constant'¶
- output_path = '{identifier}.constant.nc'¶
File to write to. May contain format strings that are replaced with Roger attributes.
- output_frequency = None¶
Frequency (in seconds) in which output is written.
- sampling_frequency = None¶
Frequency (in seconds) in which variables are accumulated.
- output_variables = None¶
Iterable containing all variables to be volumed. Changes have no effect after
initialize
has been called.
Water monitor¶
- class roger.diagnostics.water_monitor.WaterMonitor(state)[source]¶
Bases:
RogerDiagnostic
Diagnostic monitoring of water storage.
Writes output to stdout (no binary output).
- name = 'water_monitor'¶
Name that identifies the current diagnostic
- output_frequency = None¶
Tracer monitor¶
- class roger.diagnostics.tracer_monitor.TracerMonitor(state)[source]¶
Bases:
RogerDiagnostic
Diagnostic monitoring tracer contents / fluxes.
Writes output to stdout (no binary output).
- name = 'tracer_monitor'¶
Name that identifies the current diagnostic
- output_frequency = None¶