deltametrics.cube.DataCube

class deltametrics.cube.DataCube(data, read=[], varset=None, stratigraphy_from=None)

DataCube object.

DataCube contains t-x-y information. It may have any number of attached attributes (grain size, mud frac, elevation).

__init__(data, read=[], varset=None, stratigraphy_from=None)

Initialize the BaseCube.

Parameters
  • data (str, dict) – If data is type str, the string points to a NetCDF or HDF5 file that can be read. Typically this is used to directly import files output from the pyDeltaRCM model. Alternatively, pass a dict with keys indicating variable names, and values with corresponding t-x-y ndarray of data.

  • read (bool, optional) – Which variables to read from dataset into memory. Special option for read=True to read all available variables into memory.

  • varset (VariableSet, optional) – Pass a ~deltametrics.plot.VariableSet instance if you wish to style this cube similarly to another cube. If no argument is supplied, a new default VariableSet instance is created.

  • stratigraphy_from (str, optional) – Pass a string that matches a variable name in the dataset to compute preservation and stratigraphy using that variable as elevation data. Typically, this is 'eta' in pyDeltaRCM model outputs. Stratigraphy can be computed on an existing data cube with the stratigraphy_from() method.

Methods

__init__(data[, read, varset, stratigraphy_from])

Initialize the BaseCube.

export_frozen_variable(var[, return_cube])

Export a cube with frozen values.

read(variables)

Read variable into memory.

register_plan(name, PlanInstance)

Register a planform to the cube.

register_section(name, SectionInstance[, …])

Register a section to the section_set().

show_cube(var[, t, x, y, ax])

Show the cube in a 3d axis.

show_plan(var[, t, ax, title, ticks, …])

Show planform image.

show_section(*args, **kwargs)

Show a section.

stratigraphy_from([variable, style])

Compute stratigraphy attributes.

Attributes

H

Number of elements, vertical (height) coordinate.

L

Number of elements, length coordinate.

T

Vertical mesh.

W

Number of elements, width coordinate.

X

x-direction mesh.

Y

y-direction mesh.

Z

Vertical mesh.

coords

List of coordinate names as strings.

data_path

Path connected to for file IO.

dataio

Data I/O handler.

meta

plan_set

Set of plan instances.

plans

Set of plan instances.

section_set

Set of section instances.

sections

Set of section instances.

shape

Number of elements in data (HxLxW).

t

time coordinate.

variables

List of variable names as strings.

varset

Variable styling for plotting.

x

x-direction coordinate.

y

y-direction coordinate.

z

Vertical coordinate.

H

Number of elements, vertical (height) coordinate.

L

Number of elements, length coordinate.

T

Vertical mesh.

W

Number of elements, width coordinate.

X

x-direction mesh.

Y

y-direction mesh.

Z

Vertical mesh.

__getitem__(var)

Return the variable.

Overload slicing operations for io to return a CubeVariable instance when slicing.

Parameters

var (str) – Which variable to slice.

Returns

CubeVariable – The instantiated CubeVariable.

Return type

~deltametrics.cube.CubeVariable

_connect_to_file(data_path)

Connect to file.

This method is used internally to send the data_path to the correct IO handler.

_read_meta_from_file()

Read metadata information from variables in file.

This method is used internally to gather some useful info for navigating the variable trees in the stored files.

coords

List of coordinate names as strings.

Type

list

data_path

Path connected to for file IO.

Returns a string if connected to file, or None if cube initialized from dict.

Type

str

dataio

Data I/O handler.

Type

BaseIO subclass

export_frozen_variable(var, return_cube=False)

Export a cube with frozen values.

Creates a H x L x W ndarray with values from variable var placed into the array. This method is particularly useful for inputs to operation that will repeatedly utilize the underlying data in computations. Access to underlying data is comparatively slow to data loaded in memory, because the Cube utilities are configured to read data off-disk as needed.

plan_set

Set of plan instances.

Type

dict

plans

Set of plan instances.

Alias to plan_set().

Type

dict

read(variables)

Read variable into memory.

Parameters

variables (list of str, str) – Which variables to read into memory.

register_plan(name, PlanInstance)

Register a planform to the cube.

register_section(name, SectionInstance, return_section=False)

Register a section to the section_set().

Connect a section to the cube.

Parameters
  • name (str) – The name to register the section.

  • SectionInstance (BaseSection subclass instance) – The section instance that will be registered.

  • return_section (bool) – Whether to return the section object.

Notes

When the API for instantiation of the different section types is settled, we should enable the ability to pass section kwargs to this method, and then instantiate the section internally. This avoids the user having to specify dm.section.StrikeSection(y=5) in the register_Section() call, and instead can do something like rcm8cube.register_section('trial', trace='strike', y=5).

section_set

Set of section instances.

Type

dict

sections

Set of section instances.

Alias to section_set().

Type

dict

shape

Number of elements in data (HxLxW).

show_cube(var, t=-1, x=-1, y=-1, ax=None)

Show the cube in a 3d axis.

3d visualization via pyvista.

Warning

Implementation is crude and should be revisited.

show_plan(var, t=-1, ax=None, title=None, ticks=False, colorbar_label=False)

Show planform image.

Warning

NEEDS TO BE PORTED OVER TO WRAP THE .show() METHOD OF PLAN!

show_section(*args, **kwargs)

Show a section.

Can be called by name if section is already registered, or pass a fresh section instance and it will be connected.

Wraps the Section’s show() method.

stratigraphy_from(variable='eta', style='mesh', **kwargs)

Compute stratigraphy attributes.

Parameters
  • variable (str, optional) – Which variable to use as elevation data for computing preservation. If no value is given for this parameter, we try to find a variable eta and use that for elevation data if it exists.

  • style (str, optional) – Which style of stratigraphy to compute, options are 'mesh' or 'boxy'. Additional keyword arguments are passed to stratigraphy attribute initializers.

t

time coordinate.

variables

List of variable names as strings.

Type

list

varset

Variable styling for plotting.

Can be set with cube.varset = VariableSetInstance where VariableSetInstance is a valid instance of VariableSet.

Type

VariableSet

x

x-direction coordinate.

y

y-direction coordinate.

z

Vertical coordinate.