gnome.outputters.weathering

Weathering Outputter

Module Contents

Classes

BaseMassBalanceOutputter

Base class for outputters that need to return results of the mass balance:

WeatheringOutput

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

class gnome.outputters.weathering.BaseMassBalanceOutputter(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 outputters that need to return results of the mass balance:

i.e. averaged properties of the LEs

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 or output_single_step

  • output_last_step=True – If True then output for final step is written regardless of output_timestep or output_single_step. This is potentially an extra output, if not aligned with output_timestep.

  • output_single_step=False – If True then output is written for only one step, the output_start_time, regardless of output_timestep. output_zero_step and output_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.

units
gather_mass_balance_data(step_num)
class gnome.outputters.weathering.WeatheringOutput(output_dir=None, **kwargs)

Bases: BaseMassBalanceOutputter

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

The output is the aggregation of properties for all LEs (aka Mass Balance) for a particular time step. There are a number of different things we would like to graph: - Evaporation - Dissolution - Dissipation - Biodegradation - ???

Parameters:

output_dir=None (str) – output directory for the json files. If not directory is provided, files will not be written.

other arguments as defined in the Outputter class

_schema
write_output(step_num, islast_step=False)

Weathering data is only output for forecast spill container, not the uncertain spill container. This is because Weathering has its own uncertainty and mixing the two was giving weird results. The cloned models that are modeling weathering uncertainty do not include the uncertain spill container.

output_to_file(json_content, step_num)
clean_output_files()

Cleans out the output dir

This should be implemented by subclasses that dump files.

Each outputter type dumps different types of files, and this should only clear out those.

See the OutputterFilenameMixin for a simple example.

__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.)