deltametrics.section.DipSection¶
- class deltametrics.section.DipSection(*args, distance=None, distance_idx=None, length=None, x=None, y=None, **kwargs)¶
Dip section object.
Section oriented parallel to the dim1 axis. Specify the location of the dip section with
distance
andlength
ordistance_idx
andlength
keyword parameters.Hint
Either
distance
ordistance_idx
must be specified.- Parameters:
*args (
DataCube
or StratigraphyCube) – The Cube object to link for underlying data. This option should be ommitted if using theregister_section
method of a Cube.distance (
float
, optional) – Distance in `dim2` coordinates from the dim2 lower domain edge to place the section. The section location will be interpolated to the nearest grid cell. Mutually exclusive with distance_idx.distance_idx (
int
, optional) – Distance in cell indices from the dim2 lower domain edge to place the section. Mutually exclusive with distance.length (
tuple
orlist
of int or float, optional) – A two-element tuple specifying the bounding points of the section in the dim1 axis. Values are treated as cell indices ifdistance_idx
is given and as dim1 coordinates ifdistance
is given. If no value is supplied, the section is drawn across the entire dim1 axis (i.e., across the whole domain). Note that when indicies are given, the end point of length is treated as inclusive (e.g., (10, 20) results in a 21-cell section).x (
int
, optional, deprecated) – The number of cells in from the dim2 lower domain edge. If used, the value is internally coerced todistance_idx
.y (
int
, optional, deprecated) – The limits of the section. Defaults to the full dim1 domain length. Specify as a two-element tuple or list of int, giving the lower and upper bounds of indices to span the section.**kwargs – Keyword arguments are passed to BaseSection.__init__(). Supported options are name.
- Returns:
section – DipSection object with specified parameters. The section is automatically connected to the underlying Cube data source if the
register_section
method of a Cube is used to set up the section, or the Cube is passed as the first positional argument during instantiation.- Return type:
Examples
Create a DipSection that is registered to a DataCube at specified distance in dim2 coordinates, and spans the entire model domain:
>>> golfcube = dm.sample_data.golf() >>> golfcube.register_section('dip', dm.section.DipSection(distance=3500))
>>> # show the location and the "sandfrac" variable >>> fig, ax = plt.subplots(2, 1, figsize=(8, 4)) >>> golfcube.quick_show('eta', idx=-1, ax=ax[0], ticks=True) >>> golfcube.sections['dip'].show_trace('r--', ax=ax[0]) >>> golfcube.sections['dip'].show('sandfrac', ax=ax[1]) >>> plt.show()
Create a DipSection that is registered to a DataCube at specified distance_idx index
=75
, and spans the entire model domain:>>> golfcube = dm.sample_data.golf() >>> golfcube.register_section('dip75', dm.section.DipSection(distance_idx=75))
>>> # show the location and the "sandfrac" variable >>> fig, ax = plt.subplots(2, 1, figsize=(8, 4)) >>> golfcube.quick_show('eta', idx=-1, ax=ax[0], ticks=True) >>> golfcube.sections['dip75'].show_trace('r--', ax=ax[0]) >>> golfcube.sections['dip75'].show('sandfrac', ax=ax[1]) >>> plt.show()
Create a DipSection that is registered to a StratigraphyCube at specified distance in dim2 coordinates, and spans only a range in the middle of the domain:
>>> golfcube = dm.sample_data.golf() >>> golfstrat = dm.cube.StratigraphyCube.from_DataCube(golfcube, dz=0.1) >>> golfstrat.register_section( ... 'dip_part', dm.section.DipSection(distance=4000, length=(500, 1500)))
>>> # show the location and the "velocity" variable >>> fig, ax = plt.subplots(2, 1, figsize=(8, 4)) >>> golfcube.quick_show('eta', idx=-1, ax=ax[0], ticks=True) >>> golfstrat.sections['dip_part'].show_trace('r--', ax=ax[0]) >>> golfstrat.sections['dip_part'].show('velocity', ax=ax[1]) >>> plt.show()
- __init__(*args, distance=None, distance_idx=None, length=None, x=None, y=None, **kwargs)¶
Initialization for the LineSection.
The LineSection is the base class for Strike and Dip sections, as these share identical input arguments, and processing steps, but differ in which direction the line is drawn.
Note
the RadialSection does not subclass LineSection.
Methods
__init__
(*args[, distance, distance_idx, ...])Initialization for the LineSection.
connect
(InputInstance[, name])Connect this Section instance to a Cube instance.
show
(*args[, style, data, label, colorbar, ...])Show the section.
show_trace
(*args[, ax, autoscale])Plot section trace (x-y plane path).
Attributes
Distance of section from reference edge, in perpendicular-reference coordinates.
Distance of section from from reference edge, in perpendicular-reference indices.
Alias for self.trace_idx.
Length of section in dimensional coordinates.
Section name.
Along-section coordinate.
Section shape.
Stratigraphic attributes data object.
Coordinates of the section in the dim1-dim2 plane.
Indices of section points in the dim1-dim2 plane.
List of variables.
Deprecated.
Deprecated.
Up-section (vertical) coordinate.
- __getitem__(var)¶
Get a slice of the section.
Slicing the section instance creates an xarray DataArray instance from data, for variable
var
and maintaining the data coordinates.Note
We only support slicing by string.
- Parameters:
var (
str
) – Which variable to slice.- Returns:
data – The underlying data returned as an xarray DataArray, maintaining coordinates.
- Return type:
DataArray
- connect(InputInstance, name=None)¶
Connect this Section instance to a Cube instance.
- property distance¶
Distance of section from reference edge, in perpendicular-reference coordinates.
- property distance_idx¶
Distance of section from from reference edge, in perpendicular-reference indices.
- property idx_trace¶
Alias for self.trace_idx.
- property length¶
Length of section in dimensional coordinates.
- property name¶
Section name.
Helpful to differentiate multiple Section objects.
- property s¶
Along-section coordinate.
- property shape¶
Section shape.
Simply a tuple equivalent to
(len(z), len(s))
- show(*args, style='shaded', data=None, label=False, colorbar=True, colorbar_label=False, ax=None)¶
Show the section.
Method enumerates convenient routines for visualizing sections of data and stratigraphy. Includes support for multiple data style and multiple data choices as well.
Note
The colors for style=’lines’ are determined from the left-end edge node, and colors for the style=’shaded’ mesh are determined from the lower-left-end edge node of the quad.
- Parameters:
SectionAttribute (
str
,SectionVariableInstance
) – Which attribute to show. Can be a string for a named Cube attribute, or any arbitrary data. Additionally, pass no arguments and the first variable in the underlying data source list will be used.style (
str
, optional) – What style to display the section with. Choices are ‘mesh’ or ‘line’.data (
str
, optional) – Argument passed toget_display_arrays
orget_display_lines
. Supported options are ‘spacetime’, ‘preserved’, and ‘stratigraphy’. Default is to display full spacetime plot for section generated from a DataCube, and stratigraphy for a StratigraphyCube section.label (
bool
, str, optional) – Display a label of the variable name on the plot. Default is False, display nothing. Iflabel=True
, the label name from theVariableSet
is used. Other arguments are attempted to coerce to str, and the literal is diplayed.colorbar (
bool
, optional) – Whether a colorbar is appended to the axis.colorbar_label (
bool
, str, optional) – Display a label of the variable name along the colorbar. Default is False, display nothing. Iflabel=True
, the label name from theVariableSet
is used. Other arguments are attempted to coerce to str, and the literal is diplayed.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
Example 1: Display the velocity spacetime section of a DataCube.
>>> golfcube = dm.sample_data.golf() >>> golfcube.register_section( ... 'demo', dm.section.StrikeSection(distance_idx=5)) >>> golfcube.sections['demo'].show('velocity')
Note that the last line above is functionally equivalent to
golfcube.show_section('demo', 'velocity')
.Example 2: Display a section, with “quick” stratigraphy, as the depth attribute, displaying several different section styles.
>>> golfcube = dm.sample_data.golf() >>> golfcube.stratigraphy_from('eta') >>> golfcube.register_section( ... 'demo', dm.section.StrikeSection(distance=250)) >>> fig, ax = plt.subplots(4, 1, sharex=True, figsize=(6, 9)) >>> golfcube.sections['demo'].show('depth', data='spacetime', ... ax=ax[0], label='spacetime') >>> golfcube.sections['demo'].show('depth', data='preserved', ... ax=ax[1], label='preserved') >>> golfcube.sections['demo'].show('depth', data='stratigraphy', ... ax=ax[2], label='quick stratigraphy') >>> golfcube.sections['demo'].show('depth', style='lines', data='stratigraphy', ... ax=ax[3], label='quick stratigraphy') # noqa: E501
- show_trace(*args, ax=None, autoscale=False, **kwargs)¶
Plot section trace (x-y plane path).
Plot the section trace (
trace
) onto an x-y planview.- Parameters:
*args – Passed to matplotlib
plot()
.ax (
Axes
object, optional) – A matplotlib Axes object to plot the trace. Optional; if not provided, a call is made toplt.gca()
to get the current (or create a new) Axes object.autoscale (
bool
) – Whether to rescale the axis based on the limits of the section. Manipulates the matplotlib autoscale attribute. Default isFalse
.**kwargs – Passed to matplotlib
plot()
.
- property strat_attr¶
Stratigraphic attributes data object.
- Raises:
NoStratigraphyError – If no stratigraphy information is found for the section.
- property trace¶
Coordinates of the section in the dim1-dim2 plane.
Note
stack of [dim2, dim1].
- property trace_idx¶
Indices of section points in the dim1-dim2 plane.
- property variables¶
List of variables.
- property x¶
Deprecated. Use
distance_idx
.Start and end indices of section.
- property y¶
Deprecated. Use
length_idx
.
- property z¶
Up-section (vertical) coordinate.