gnome.outputters.memory_outputter¶
An outputter that stores in memory
This can be handy for tests, etc.
NOTE: not complete!
Classes¶
Base class for all outputters |
Module Contents¶
- class gnome.outputters.memory_outputter.MemoryOutputter(cache=None, on=True, output_timestep=None, output_zero_step=True, output_last_step=True, output_single_step=False, output_start_time=None, output_dir=None, surface_conc=None, *args, **kwargs)¶
Bases:
gnome.outputters.outputter.Outputter
Base class for all outputters Since this outputter doesn’t do anything, it’ll never be used as part of a gnome model. As such, it should never need to be serialized
Sets attributes for outputters, like output_timestep, cache, etc.
- Parameters:
cache – sets the cache object from which to read data. The model will automatically set this parameter.
output_timestep=None – If
None
output will be written every model time step. If set, then output is written every output_timestep starting from the model start time. If the output_timestep is less than the model timestep, an Warning will be raised at runtime.output_zero_step=True – If True then output for initial step (showing initial release conditions) is written regardless of
output_timestep
oroutput_single_step
output_last_step=True – If True then output for final step is written regardless of
output_timestep
oroutput_single_step
. This is potentially an extra output, if not aligned withoutput_timestep
.output_single_step=False – If
True
then output is written for only one step, the output_start_time, regardless ofoutput_timestep
.output_zero_step
andoutput_last_step
are still respected, set these to False if you want only one time step.output_start_time=None – Time to start outputting restults. If None it is set to the model start time
output_dir=None – Directory to dump output in, if it needs to do this.
surface_conc=None – Compute surface concentration Any non-empty string will compute (and output) the surface concentration. The contents of the string determine the algorithm used. “kde” is currently the only available option.
- arrays_to_output = ['mass', 'positions', 'age', 'status_codes']¶
- prepare_for_model_run(*args, **kwargs)¶
This method gets called by the model at the beginning of a new run. Do what you need to do to prepare.
- Parameters:
model_start_time (datetime.datetime object) – (Required) start time of the model run. NetCDF time units calculated with respect to this time.
spills (gnome.spill_container.SpillContainerPair object) – (Required) model.spills object (SpillContainerPair)
model_time_step (float seconds) – time step of the model – used to set timespans for some outputters
Optional argument - in case cache needs to be updated
- Parameters:
cache=None – Sets the cache object to be used for the data. If None, it will use the one already set up.
also added
**kwargs
since a derived class like NetCDFOutput could require additional variables.Note
base class doesn’t use model_start_time or spills, but multiple outputters need spills and netcdf needs model_start_time, so just set them here
- write_output(step_num, islast_step=False)¶
Save data at each output timestep
- Parameters:
step_num (int) – the model step number you want rendered.
islast_step (bool) – Default is False. Flag that indicates that step_num is last step. If ‘output_last_step’ is True then this is written out
Use super to call base class write_output method