NetCDFWriter#

class fridom.framework.modules.netcdf_writer.NetCDFWriter(write_trigger: ClockTrigger | None = None, restart_trigger: ClockTrigger | None = None, filename: str = 'snap', directory: str | None = None, get_variables: Callable | None = None)[source]#

Bases: Module

Writing model output to NetCDF files.

Parameters#

write_triggerfr.ClockTrigger, optional

The trigger that determines when the data should be written to the file. Default is None which means that the data will be written at every time step.

restart_triggerfr.ClockTrigger, optional

The trigger that determines when a new file should be created. Default is None which means that only one file will be created.

filenamestr, optional

The name of the file to write to. Default is “snap” (no directory).

directorystr, optional

The directory where the files should be stored. Default is “snapshots”.

get_variablescallable, (default: None)

A function that returns a list of scalar fields that should be written to the file. If None, all fields of the State object will be written. The function signature of get_variables is: get_variables(mz: ‘ModelState’) -> list[ScalarField]

__init__(write_trigger: ClockTrigger | None = None, restart_trigger: ClockTrigger | None = None, filename: str = 'snap', directory: str | None = None, get_variables: Callable | None = None) None[source]#

Methods

__init__([write_trigger, restart_trigger, ...])

disable()

Disable the module.

enable()

Enable the module.

is_enabled()

Whether the module is enabled or not.

reset()

Stop and start the module.

setup(mset[, setup_mode])

Set the module up.

start()

Start the module.

stop()

Stop the module.

update(mz)

Update the model state.

Attributes

add_timestamp

Whether a timestamp should be added to the filename.

diff_module

The differentiation module to be used by this module.

grid

The grid of the model settings.

info

Return a dictionary with information about the time stepper.

interp_module

The interpolation module to be used by this module.

is_setup

Whether the module is set up.

mset

The model settings.

name

required_halo

The required halo points for this module.

snap_slice

The slice of the grid that should be written to the file.

Examples using fridom.framework.modules.NetCDFWriter#

Barotropic Jet

Barotropic Jet

Convection and Closures

Convection and Closures

Internal Gravity Wave Maker

Internal Gravity Wave Maker

Multiple Wave Makers

Multiple Wave Makers

Rayleigh-Bénard Convection

Rayleigh-Bénard Convection

Rayleigh-Taylor Instability

Rayleigh-Taylor Instability

Single Internal Wave

Single Internal Wave

Symmetric Instability

Symmetric Instability

Tracers and Eddies

Tracers and Eddies

Reflecting Wave Package

Reflecting Wave Package

Barotropic Instability.

Barotropic Instability.

Equatorial Waves.

Equatorial Waves.
name = 'NetCDFWriter'#
start() None[source]#

Start the module.

Description#

This method is called at the beginning of the model run. Child classes that require a start method (for example to start an output writer) should overwrite this method. Make sure to decorate the method with the @module_method decorator.

stop() None[source]#

Stop the module.

Description#

This method is called by the model at the end of the model run or when the model is reset. Child classes that require a stop method (for example to close an output file) should overwrite this method. Make sure to decorate the method with the @module_method decorator.

update(mz: ModelState) ModelState[source]#

Update the model state.

Description#

This method is called by the model at each time step. Child classes should overwrite this method to update the module. Make sure to decorate the method with the @module_method decorator.

Parameters#

mzfr.ModelState

The model state at the current time step.

Returns#

fr.ModelState

The updated model state.

property snap_slice: tuple[slice, ...]#

The slice of the grid that should be written to the file.

log_level: str | int | None#
property add_timestamp: bool#

Whether a timestamp should be added to the filename.