gnome.outputters.binary

Binary Outputter For use in Gnome Analyst

Module Contents

Classes

BinaryOutput

class that outputs GNOME trajectory results on a time step by time step basis

Attributes

le_dtype

le_dtype

header_dtype

header_dtype

gnome.outputters.binary.le_dtype
gnome.outputters.binary.le_dtype
gnome.outputters.binary.header_dtype
gnome.outputters.binary.header_dtype
class gnome.outputters.binary.BinaryOutput(filename, zip_output=True, **kwargs)

Bases: gnome.outputters.outputter.OutputterFilenameMixin, gnome.outputters.outputter.Outputter

class that outputs GNOME trajectory results on a time step by time step basis this is the format output by desktop GNOME for use in Gnome Analyst

Parameters:
  • filename (str) – full path and basename of the zip file

  • zip_output=True – whether to zip up the output binary files

other arguments as defined in the Outputter class

_schema
prepare_for_model_run(model_start_time, spills, uncertain=False, **kwargs)
prepare_for_model_run(model_start_time,
cache=None,
uncertain=False,
spills=None,
**kwargs)

Reset file_num and uncertainty

This must be done in prepare_for_model_run because if model _state changes, it is rewound and re-run from the beginning.

If there are existing output files, they are deleted here.

This takes more than standard ‘cache’ argument. Some of these are required arguments - they contain None for defaults because non-default argument cannot follow default argument. Since cache is already 2nd positional argument for Renderer object, the required non-default arguments must be defined following ‘cache’.

If uncertainty is on, then SpillContainerPair object contains identical _data_arrays in both certain and uncertain SpillContainer’s, the data itself is different, but they contain the same type of data arrays. If uncertain, then data arrays for uncertain spill container are written to separate files.

Note

Does not take any other input arguments; however, to keep the interface the same for all outputters, define kwargs in case future outputters require different arguments.

write_output(step_num, islast_step=False)

Write data from time step to binary file

output_to_file(filename, sc)

dump a timestep’s data into binary files for Gnome Analyst

_zip_binary_files(num_files)
clean_output_files()

deletes output files that may be around

called by prepare_for_model_run

here in case it needs to be called from elsewhere

__getstate__()

This is to support pickle.dumps() inside the uncertainty model subprocesses. We need to be able to pickle our weathering outputters so that our uncertainty subprocesses can send them back to the parent process through a message queue. And the cache attribute (specifically, the ElementCache.lock attribute) can not be pickled, and instead produces a RuntimeError.

(Note: The __setstate__() probably doesn’t need to recreate the

ElementCache since it will be created inside the Model.setup_model_run() function.)