deltametrics.section.PathSection

class deltametrics.section.PathSection(*args, path=None, path_idx=None, **kwargs)

Path section object.

Create a Section along user-specified path. Specify the section location as an (N, 2) ndarray of dim1-dim2 pairs of coordinates that define the verticies of the path. All coordinates along the path will be included in the section.

(Source code, png, hires.png)

../_images/deltametrics-section-PathSection-1.png
Parameters:
  • *args (DataCube or StratigraphyCube) – The Cube object to link for underlying data. This option should be ommitted if using the register_section method of a Cube.

  • path (ndarray) – An (N, 2) ndarray specifying the dim1-dim2 pairs of coordinates in dimensional values, defining the verticies of the path to extract the section from. Mutually exclusive with path_idx.

  • path_idx (ndarray) – An (N, 2) ndarray specifying the dim1-dim2 pairs of coordinates in dimension indices, defining the verticies of the path to extract the section from. Mutually exclusive with path.

  • **kwargs – Keyword arguments are passed to BaseSection.__init__(). Supported options are name.

Returns:

sectionPathSection 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:

PathSection

Examples

Create a PathSection that is registered to a DataCube at specified coordinates:

(Source code)

../_images/deltametrics-section-PathSection-2_00.png

(png, hires.png)

../_images/deltametrics-section-PathSection-2_01.png

(png, hires.png)

__init__(*args, path=None, path_idx=None, **kwargs)

Instantiate.

Parameters:
  • path (ndarray) – An (N, 2) ndarray specifying the dim1-dim2 pairs of coordinates that define the verticies of the path to extract the section from.

  • note:: (..) – path must be supplied as a keyword argument.

Methods

__init__(*args[, path, path_idx])

Instantiate.

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

idx_trace

Alias for self.trace_idx.

length

Length of section in dimensional coordinates.

name

Section name.

path

Path of the PathSection.

s

Along-section coordinate.

shape

Section shape.

strat_attr

Stratigraphic attributes data object.

trace

Coordinates of the section in the dim1-dim2 plane.

trace_idx

Indices of section points in the dim1-dim2 plane.

variables

List of variables.

vertices

Vertices defining the path in dimensional coordinates.

z

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 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 path

Path of the PathSection.

Returns same as trace property.

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 to get_display_arrays or get_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. If label=True, the label name from the VariableSet 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. If label=True, the label name from the VariableSet 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 to plt.gca() to get the current (or create a new) Axes object.

Examples

Example 1: Display the velocity spacetime section of a DataCube.

(Source code)

../_images/deltametrics-section-PathSection-3_00.png

(png, hires.png)

../_images/deltametrics-section-PathSection-3_01.png

(png, hires.png)

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 to plt.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 is False.

  • **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 vertices

Vertices defining the path in dimensional coordinates.

property z

Up-section (vertical) coordinate.