Diagnostics

Diagnostics are separate objects (instances of subclasses of VerosDiagnostic) responsible for handling I/O, restart mechanics, and monitoring of the numerical solution. All available diagnostics are instantiated and added to a dictionary attribute Veros.diagnostics (with a key determined by their name attribute). Options for diagnostics may be set during the Veros.set_diagnostics() method:

class MyModelSetup(Veros):
    ...
    def set_diagnostics(self):
        self.diagnostics["averages"].output_variables = ["psi","u","v"]
        self.diagnostics["averages"].sampling_frequency = 3600.
        self.diagnostics["snapshot"].output_variables += ["du"]

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 veros.diagnostics.diagnostic.VerosDiagnostic(vs)[source]

Bases: object

Base class for diagnostics. Provides an interface and wrappers for common I/O.

Any diagnostic needs to implement the five interface methods and set some attributes.

name = None

Name that identifies the current diagnostic

initialize(vs)

Called at the end of setup. Use this to process user settings and handle setup.

diagnose(vs)

Called with frequency sampling_frequency.

output(vs)

Called with frequency output_frequency.

write_restart(vs)

Responsible for writing restart files.

read_restart(vs)

Responsible for reading restart files.

Available diagnostics

Currently, the following diagnostics are implemented and added to Veros.diagnostics:

Snapshot

class veros.diagnostics.snapshot.Snapshot(vs)[source]

Bases: veros.diagnostics.diagnostic.VerosDiagnostic

Writes snapshots of the current solution. Also reads and writes the main restart data required for restarting a Veros simulation.

output_path = '{identifier}.snapshot.nc'

File to write to. May contain format strings that are replaced with Veros attributes.

name = 'snapshot'
output_frequency = None

Frequency (in seconds) in which output is written.

output_variables = None

Variables to be written to output. Defaults to all Veros variables that have the attribute output.

restart_variables = None

Variables to be written to restart. Defaults to all Veros variables that have the attribute write_to_restart.

Averages

class veros.diagnostics.averages.Averages(vs)[source]

Bases: veros.diagnostics.diagnostic.VerosDiagnostic

Time average output diagnostic.

All registered variables are summed up when diagnose() is called, and averaged and output upon calling output().

name = 'averages'
output_path = '{identifier}.averages.nc'

File to write to. May contain format strings that are replaced with Veros attributes.

output_variables = None
output_frequency = None

Frequency (in seconds) in which output is written.

sampling_frequency = None

Frequency (in seconds) in which variables are accumulated.

CFL monitor

class veros.diagnostics.cfl_monitor.CFLMonitor(vs)[source]

Bases: veros.diagnostics.diagnostic.VerosDiagnostic

Diagnostic monitoring the maximum CFL number of the solution to detect instabilities.

Writes output to stdout (no binary output).

name = 'cfl_monitor'

Tracer monitor

class veros.diagnostics.tracer_monitor.TracerMonitor(vs)[source]

Bases: veros.diagnostics.diagnostic.VerosDiagnostic

Diagnostic monitoring global tracer contents / fluxes.

Writes output to stdout (no binary output).

name = 'tracer_monitor'
output_frequency = None

Frequency (in seconds) in which output is written.

Energy

class veros.diagnostics.energy.Energy(vs)[source]

Bases: veros.diagnostics.diagnostic.VerosDiagnostic

Diagnose globally averaged energy cycle. Also averages energy in time.

name = 'energy'
output_path = '{identifier}.energy.nc'

File to write to. May contain format strings that are replaced with Veros attributes.

output_frequency = None

Frequency (in seconds) in which output is written.

sampling_frequency = None

Frequency (in seconds) in which variables are accumulated.

Overturning

class veros.diagnostics.overturning.Overturning(vs)[source]

Bases: veros.diagnostics.diagnostic.VerosDiagnostic

Isopycnal overturning diagnostic. Computes and writes vertical streamfunctions (zonally averaged).

name = 'overturning'
output_path = '{identifier}.overturning.nc'

File to write to. May contain format strings that are replaced with Veros attributes.

output_frequency = None

Frequency (in seconds) in which output is written.

sampling_frequency = None

Frequency (in seconds) in which variables are accumulated.

p_ref = 2000.0

Reference pressure for isopycnals