deltametrics.cube.StratigraphyCube¶
- class deltametrics.cube.StratigraphyCube(data, read=[], varset=None, stratigraphy_from=None, sigma_dist=None, dz=None, z=None, nz=None)¶
StratigraphyCube object.
A cube of precomputed stratigraphy. This is a z-x-y matrix defining variables at specific voxel locations.
This is a special case of a cube.
- __init__(data, read=[], varset=None, stratigraphy_from=None, sigma_dist=None, dz=None, z=None, nz=None)¶
Initialize the StratigraphicCube.
Any instantiation pathway must configure
z
,H
,L
,W
, andstrata
.- 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 adict
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 forread=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.
Methods
__init__
(data[, read, varset, ...])Initialize the StratigraphicCube.
export_frozen_variable
(var[, return_cube])Export a cube with frozen values.
from_DataCube
(DataCubeInstance[, ...])Create from a DataCube.
quick_show
(var[, idx, axis])Convenient and quick way to show a slice of the cube by idx and axis.
read
(variables)Read variable into memory.
register_plan
(*args, **kwargs)wrapper, might not really need this.
register_planform
(name, PlanformInstance[, ...])Register a planform to the
planform_set
.register_section
(name, SectionInstance[, ...])Register a section to the
section_set
.show_cube
(var[, style, ve, ax])Show the cube in a 3D axis.
show_plan
(*args, **kwargs)Deprecated.
show_planform
(name, variable, **kwargs)Show a registered planform by name and variable.
show_section
(name, variable, **kwargs)Show a registered section by name and variable.
Attributes
Number of elements, vertical (height) coordinate.
Number of elements, length coordinate.
Number of elements, width coordinate.
Vertical mesh.
List of coordinate names as strings.
Path connected to for file IO.
Data I/O handler.
Coordinates along the first dimension of cube.
Coordinates along the second dimension of cube.
Coordinates along the third dimension of cube.
The limits of the dim1 by dim2 plane.
The extent, reversed up-down for special plotting.
A dummy variable of zeros with shape of extent.
meta
Set of planform instances.
Set of plan instances.
Set of section instances.
Set of section instances.
Number of elements in data (HxLxW).
Subsidence information.
Strata surfaces.
List of variable names as strings.
Variable styling for plotting.
Vertical coordinate.
- property H¶
Number of elements, vertical (height) coordinate.
- property L¶
Number of elements, length coordinate.
- property W¶
Number of elements, width coordinate.
- property Z¶
Vertical mesh.
- __getitem__(var)¶
Return the variable.
Overload slicing operations for io to return a
CubeVariable
instance when slicing, where the data have been placed into stratigraphic position.- Parameters:
var (
str
) – Which variable to slice.- Returns:
CubeVariable – The instantiated CubeVariable.
- Return type:
~deltametrics.cube.CubeVariable
- property coords¶
List of coordinate names as strings.
- Type:
list
- property data_path¶
Path connected to for file IO.
Returns a string if connected to file, or None if cube initialized from
dict
.- Type:
str
- property dim0_coords¶
Coordinates along the first dimension of cube.
- property dim1_coords¶
Coordinates along the second dimension of cube.
- property dim2_coords¶
Coordinates along the third dimension of cube.
- 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.
- property extent¶
The limits of the dim1 by dim2 plane.
Useful for plotting.
- property extent_flipud¶
The extent, reversed up-down for special plotting.
limits of the dim1 by dim2 plane,
- property extent_zeros¶
A dummy variable of zeros with shape of extent.
Returns an array of zeros with the shape of the cube.
- static from_DataCube(DataCubeInstance, stratigraphy_from='eta', sigma_dist=None, dz=None, z=None, nz=None)¶
Create from a DataCube.
Examples
Create a stratigraphy cube from the example
golf
:>>> golfcube = dm.sample_data.golf() >>> stratcube = dm.cube.StratigraphyCube.from_DataCube(golfcube, dz=0.05)
- Parameters:
DataCubeInstance (
DataCube
) – The DataCube instance to derive from for the new StratigraphyCube.stratigraphy_from (
str
, optional) – 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.**kwargs – Keyword arguments passed to stratigraphy initialization. Can include specification for vertical resolution in Boxy case, see
_determine_strat_coordinates
, as well as information about subsidence, see_adjust_elevation_by_subsidence
.
- Returns:
StratigraphyCubeInstance – The new StratigraphyCube instance.
- Return type:
- property planform_set¶
Set of planform instances.
- Type:
dict
- property planforms¶
Set of plan instances.
Alias to
plan_set()
.- Type:
dict
- quick_show(var, idx=-1, axis=0, **kwargs)¶
Convenient and quick way to show a slice of the cube by idx and axis.
Hint
If neither idx or axis is specified, a planform view of the last index is shown.
- Parameters:
var (
str
) – Which variable to show from the underlying dataset.idx (
int
, optional) – Which index along the axis to slice data from. Default value is-1
, the last index along axis.axis (
int
, optional) – Which axis of the underlying cube idx is specified for. Default value is0
, the first axis of the cube.**kwargs – Keyword arguments are passed to
show()
if axis is0
, otherwise passed toshow()
.
Examples
>>> golfcube = dm.sample_data.golf() >>> golfstrat = dm.cube.StratigraphyCube.from_DataCube( ... golfcube, dz=0.1) ... >>> fig, ax = plt.subplots(2, 1) >>> golfcube.quick_show('eta', ax=ax[0]) # a Planform (axis=0) >>> golfstrat.quick_show('eta', idx=100, axis=2, ax=ax[1]) # a DipSection >>> plt.show()
- read(variables)¶
Read variable into memory.
- Parameters:
variables (
list
ofstr
,str
) – Which variables to read into memory.
- register_plan(*args, **kwargs)¶
wrapper, might not really need this.
- register_planform(name, PlanformInstance, return_planform=False)¶
Register a planform to the
planform_set
.Connect a planform to the cube.
- Parameters:
name (
str
) – The name to register the Planform.PlanformInstance (
BasePlanform
subclass instance) – The planform instance that will be registered.return_planform (
bool
) – Whether to return the planform object.
- 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(distance=2000)
in theregister_section()
call, and instead can do something likegolf.register_section('trial', trace='strike', distance=2000)
.
- property section_set¶
Set of section instances.
- Type:
dict
- property sections¶
Set of section instances.
Alias to
section_set()
.- Type:
dict
- property shape¶
Number of elements in data (HxLxW).
- show_cube(var, style='mesh', ve=200, ax=None)¶
Show the cube in a 3D axis.
Important
requires pyvista package for 3d visualization.
- Parameters:
var (
str
) – Which variable to show from the underlying dataset.style (
str
, optional) – Style to show cube. Default is ‘mesh’, which gives a 3D volumetric view. Other supported option is ‘fence’, which gives a fence diagram with one slice in each cube dimension.ve (
float
) – Vertical exaggeration. Default is200
.ax (
Axes
object, optional) – A matplotlib Axes object to plot the section. Optional; if not provided, a call is made toplt.gca()
to get the current (or create a new) Axes object.
Examples
Note
The following code snippets are not set up to actually make the plots in the documentation.
>>> golfcube = dm.sample_data.golf() >>> golfstrat = dm.cube.StratigraphyCube.from_DataCube( ... golfcube, dz=0.1) ... >>> fig, ax = plt.subplots() >>> golfstrat.show_cube('eta', ax=ax)
>>> golfcube = dm.sample_data.golf() ... >>> fig, ax = plt.subplots() >>> golfcube.show_cube('velocity', style='fence', ax=ax)
- show_plan(*args, **kwargs)¶
Deprecated. Use
quick_show
orshow_planform
.Warning
Provides a legacy option to quickly show a planform, from before the Planform object was properly implemented. Will be removed in a future release.
- show_planform(name, variable, **kwargs)¶
Show a registered planform by name and variable.
Call a registered planform by name and variable.
- Parameters:
name (
str
) – The name of the registered planform.variable (
str
) – The varaible name to show.**kwargs – Keyword arguments passed to
show()
.
- show_section(name, variable, **kwargs)¶
Show a registered section by name and variable.
Call a registered section by name and variable.
- Parameters:
name (
str
) – The name of the registered section.variable (
str
) – The varaible name to show.**kwargs – Keyword arguments passed to
show()
.
- property sigma_dist¶
Subsidence information.
- property strata¶
Strata surfaces.
Elevation of stratal surfaces, matched to times in
time
.
- property variables¶
List of variable names as strings.
- Type:
list
- property varset¶
Variable styling for plotting.
Can be set with
cube.varset = VariableSetInstance
whereVariableSetInstance
is a valid instance ofVariableSet
.- Type:
- property z¶
Vertical coordinate.