class StaticIntervalOutputWriter

StaticIntervalOutputWriter

class StaticIntervalOutputWriter(model, name='static-interval-output-writer', intervals=None, intervals_repeat=True, times=None, **generic_writer_kwargs)[source]

Bases: terrainbento.output_writers.generic_output_writer.GenericOutputWriter

Base class for new style output writers or converted old style output writers that want to use predetermined output intervals or times.

The derived class defines what is actually produced. This base class handles when output occurs (and interfacing with the model loop via GenericOutputWriter).

At minimum, derived classes must define run_one_step for generating the actual output. Calling register_output_filepath from the derived class allows for some optional file management features.

See constructor and GenericOutputWriter for more info.

__init__(model, name='static-interval-output-writer', intervals=None, intervals_repeat=True, times=None, **generic_writer_kwargs)[source]

A class for generating output at predetermined intervals or times.

Parameters
  • model (a terrainbento ErosionModel instance) –

  • name (string, optional) – The name of the output writer used when generating output filenames. Defaults to “static-interval-output-writer”.

  • intervals (float, int, list of floats, list of ints, optional) – A single float or int value indicates uniform intervals between output calls. A list of floats or ints indicates variable intervals between output times. Defaults to None which indicates that times will be used. If both intervals and times are None, will default to the producing one output at the end of the model run.

  • intervals_repeat (bool, optional) – Indicates whether a list of intervals should repeat until the end of the model run. Only has effect if intervals is a list. Has no effect for scalar intervals (which always repeat) or if times is provided instead of intervals. Default is True.

  • times (float, int, list of floats, list of ints, optional) – A single float or int value indicates only one output time. A list of floats or ints indicates multiple predetermined output times. Defaults to None which indicates that intervals will be used. If both intervals and times are None, will default to the one output at the end of the model run. The user must ensure that the times implied by times_iter align with the model timesteps used by the Clock. If a timestep is skipped a warning is raised and if more than five timesteps are skipped an error is raised.

  • generic_writer_kwargs (keyword args, optional) –

    Keyword arguments that will be passed directly to GenericOutputWriter. These include:

    • add_id : bool, defaults to True

    • save_first_timestep : bool, defaults to False

    • save_last_timestep : bool, defaults to True

    • output_dir : string, defaults to ‘./output’

    • verbose : bool, defaults to False

    Please see GenericOutputWriter for more detail.

Returns

StaticIntervalOutputWriter

Return type

object

Examples

StaticIntervalOutputWriter is a base class that should not be run by itself. It contains the machinery for easily creating the output times iterator, but does not define run_one_step. Please see the terrainbento tutorial for output examples.

run_one_step()[source]

The function which actually writes data to files (or screen).