microbenthos.dataview package

Submodules

microbenthos.dataview.base module

class microbenthos.dataview.base.ModelData(store=None)[source]

Bases: object

Abstract Base Class that encapsulates the model data from a simulation, and provides a uniform interface to access elements in the nested hierarchy.

PATH_DEPTHS = '/domain/depths'
PATH_TIMES = '/time'
ENTRY_ENV = 'env'
ENTRY_EQUATIONS = 'equations'
ENTRY_MICROBES = 'microbes'
ENTRY_MICROBE_FEATURES = 'features'
ENTRY_IRRADIANCE = 'irradiance'
PATH_IRRADIANCE_CHANNELS = 'env/irradiance/channels'
times

numerical array of the model clock times

depths

numerical array of the domain depths

eqn_vars

Set of data paths for equation variables

eqn_processes

Set of data paths for equation process expressions

eqn_source_totals

Set of data paths for equation source totals

eqn_var_actual

Set of data paths for equation var actual density

eqn_var_expected

Set of data paths for equation var expected density

eqn_var_difference

Set of data paths var (expected - actual)

microbe_features

set of data paths for microbial features

irradiance_intensities

set of data paths for irradiance intensity channels

aliased_paths

mapping of aliased to real path

derived_paths

mapping of derived paths to its inputs and processor

property store

The backing data store

get_data(path, tidx=None)[source]

Get the data at the given path and time index

The path is first checked if it is in the aliased_paths or derived_paths, and if not the data is looked for in the store.

Parameters
  • path (str) – A dotted path to the data

  • tidx (int) – The index for the times

Returns

A PhysicalField of the data

abstract check_store(obj)[source]

Check if the given store is of the right type

Returns

bool – True if a valid store obj

abstract get_node(path)[source]

Return the node at the given path

Parameters

path (str) – A “/” separated path

Returns

The node in the nested data store

Raises

KeyError – if no such node exists

abstract read_data_from(path, tidx)[source]

Data read out method to be implemented by subclasses

Returns

a PhysicalField of the data

abstract read_metadata_from(path)[source]

Reads out the metadata for a given node in the model data

Returns

a dict of the metadata

update()[source]
update_domain_info()[source]

Read in the domain info and create the attributes times and depths.

update_equations()[source]

Update the information about the equation variables and sources in eqn_vars, eqn_source_totals and eqn_processes.

add_aliased_path(path, alias)[source]

Alias a given path

add_derived_data(path, inputs, processor)[source]

Add a path entry for derived data

This method is used to add a data path which will provide data based on the inputs and a callable processor, as processor(*inputs).

Parameters
  • path (str) – The new derived path

  • inputs (tuple) – Set of input paths for the calculation

  • processor (callable) – The callable that performs the calculation

Returns

PhysicalField – The output from the calculation

Raises
  • ValueError – if path exists in store

  • TypeError – if processor is not a callable

update_tracked()[source]

Update the information about the tracked history of the equation variables & sources

update_microbes()[source]

Update the microbial features from the model data into microbes_features

update_irradiance()[source]

Update the set of data paths for irradiance intensities in irradiance_intensities.

microbenthos.dataview.hdfstore module

class microbenthos.dataview.hdfstore.HDFModelData(store=None)[source]

Bases: microbenthos.dataview.base.ModelData

Class that encapsulates the model data stored in a HDF Group.

check_store(obj)[source]

Check if the given store is of the right type

Returns

bool – True if a valid store obj

get_node(path)[source]

Return the node at the given path

Parameters

path (str) – A “/” separated path

Returns

Group or Dataset stored at path

Raises

KeyError – if no such node exists

read_data_from(path, tidx=None)[source]

Read out the data in path (a Dataset) into a PhysicalField

If tidx is None, then no slicing of the dataset is done

read_metadata_from(path)[source]

Return a dict-like (AttributeManager) view of the metadata at path

microbenthos.dataview.plotter module

microbenthos.dataview.plotter.fexp(number)[source]
microbenthos.dataview.plotter.fman(number)[source]
microbenthos.dataview.plotter.frepr(number)[source]
microbenthos.dataview.plotter.flabel(number)[source]
class microbenthos.dataview.plotter.ModelPlotter(model=None, style=None, figsize=None, dpi=None, unit_env='mol/l', unit_microbes='mg/cm**3', unit_sources='mol/l/min', unit_process='mol/l/min', track_budget=False)[source]

Bases: object

property model
_create_figure(**kwargs)[source]

Create the figure based on the model data structure.

The following vs-depth axes are created by default:
  • Microbes (for microbial features & irradiance distribution)

  • Environment (for eqn variable distribution)

  • Sources (eqn source totals distribution)

  • Processes (eqn process expression distribution)

If track_budget is True and corresponding data is available in model, then the time_vars axes is created.

Returns:

property axes_all
property axes_depth_all
property axes_time_all
setup_model()[source]
_get_label(path)[source]

Create the artist label from the path :param path: A “/” nested path :type path: str

Returns

A string that can be used as the label

_init_artist_styles()[source]

Create the styles for the artists

Prepare color cycle and line styles so that entities from the same group get the same color

create_artists()[source]

Create the artists for the model plotter, and store it in artists

create_clock_artist()[source]
create_line_artists(data_paths, ax)[source]
update_legends(axes=None)[source]
update_artists(tidx)[source]

Update the data of the line artists for time point

Parameters

tidx (int) – The time index

draw()[source]

Draw the changes on to the canvas. This is meant to be called after each update_artists()

show(block=False)[source]
close()[source]

microbenthos.dataview.snapshot module

class microbenthos.dataview.snapshot.SnapshotModelData(store=None)[source]

Bases: microbenthos.dataview.base.ModelData

Class that encapsulates the model data stored in snapshot dict

check_store(obj)[source]

Check if the given store is of the right type

Returns

bool – True if a valid store obj

get_node(path)[source]

Return the node at the given path

Parameters

path (str) – A “/” separated path

Returns

The node in the nested data store

Raises

KeyError – if no such node exists

read_metadata_from(path)[source]

Reads out the metadata for a given node in the model data

Returns

a dict of the metadata

read_data_from(path, tidx=None)[source]

Get the data from the path in the snapshot

Parameters
  • path (str) – Input used for get_node()

  • tidx (None) – This is ignored, since a model snapshot only contains one timepoint

Returns

a PhysicalField of the data with units at the node

Module contents