deltametrics.section.StrikeSection

class deltametrics.section.StrikeSection(*args, y=None, x=None, **kwargs)

Strike section object.

Section oriented along the delta strike (i.e., perpendicular to an inlet channel). Specify the location of the strike section with :obj`y` and x keyword parameter options.

Important

The y and x parameters must be specified as cell indices (not actual x and y coordinate values). This is a needed patch.

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.

  • y (int, optional) – The y location of the section. This is the distance to locate the section from the domain edge with a channel inlet. Defaults to 0 if no value is given.

  • x (int, optional) – The x limits for the section. Defaults to the full domain width. Specify as a two-element tuple or list of int, giving the lower and upper bounds of x values to span the section.

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

Returns

sectionStrikeSection 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

StrikeSection

Examples

To create a StrikeSection that is registered to a DataCube at specified y coordinate =10, and spans the entire model domain:

>>> rcm8cube = dm.sample_data.rcm8()
>>> rcm8cube.register_section('strike', dm.section.StrikeSection(y=10))
>>>
>>> # show the location and the "velocity" variable
>>> fig, ax = plt.subplots(2, 1, figsize=(8, 4))
>>> rcm8cube.show_plan('eta', t=-1, ax=ax[0], ticks=True)
>>> rcm8cube.sections['strike'].show_trace('r--', ax=ax[0])
>>> rcm8cube.sections['strike'].show('velocity', ax=ax[1])
>>> plt.show()

(png, hires.png)

../_images/deltametrics-section-StrikeSection-1.png

Similarly, create a StrikeSection that is registered to a StratigraphyCube at specified y coordinate =20, and spans only the left side of the model domain:

>>> rcm8cube = dm.sample_data.rcm8()
>>> sc8cube = dm.cube.StratigraphyCube.from_DataCube(rcm8cube)
>>> sc8cube.register_section('strike_half', dm.section.StrikeSection(y=20, x=[0, 120]))
>>>
>>> # show the location and the "velocity" variable
>>> fig, ax = plt.subplots(2, 1, figsize=(8, 4))
>>> rcm8cube.show_plan('eta', t=-1, ax=ax[0], ticks=True)
>>> sc8cube.sections['strike_half'].show_trace('r--', ax=ax[0])
>>> sc8cube.sections['strike_half'].show('velocity', ax=ax[1])
>>> plt.show()

(png, hires.png)

../_images/deltametrics-section-StrikeSection-2.png
__init__(*args, y=None, x=None, **kwargs)

Identify coordinates defining the section.

Parameters

CubeInstance (Cube subclass instance, optional) – Connect to this cube. No connection is made if cube is not provided.

Notes

If no arguments are passed, an empty section not connected to any cube is returned. This cube will will need to be manually connected to have any functionality (via the connect() method).

Methods

__init__(*args[, y, x])

Identify coordinates defining the section.

connect(CubeInstance[, name])

Connect this Section instance to a Cube instance.

show(SectionAttribute[, style, data, label, …])

Show the section.

show_trace(*args[, ax])

Plot section trace (x-y plane path).

Attributes

name

s

Along-section coordinate.

shape

Section shape.

strat_attr

Stratigraphic attributes data object.

trace

Coordinates of the section in the x-y plane.

variables

List of variables.

z

Up-section (vertical) coordinate.

__getitem__(var)

Get a slice of the section.

Slicing the section instance creates a SectionVariable instance from data for variable var.

Note

We only support slicing by string.

Parameters

var (str) – Which variable to slice.

Returns

SectionVariable – SectionVariable instance for variable var.

Return type

SectionVariable instance

_compute_section_attrs()

Compute attrs

Compute the along-section coordinate array from x-y pts pairs definining the section.

_compute_section_coords()

Calculate coordinates of the strike section.

connect(CubeInstance, name=None)

Connect this Section instance to a Cube instance.

s

Along-section coordinate.

shape

Section shape.

Simply a tuple equivalent to (len(z), len(s))

show(SectionAttribute, 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 mutuple 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) – Which attribute to show.

  • 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.

>>> rcm8cube = dm.sample_data.rcm8()
>>> rcm8cube.register_section('demo', dm.section.StrikeSection(y=5))
>>> rcm8cube.sections['demo'].show('velocity')

(png, hires.png)

../_images/section_demo_spacetime.png

Note that the last line above is functionally equivalent to rcm8cube.show_section('demo', 'velocity').

Example 2: Display a section, with “quick” stratigraphy, as the depth attribute, displaying several different section styles.

>>> rcm8cube = dm.sample_data.rcm8()
>>> rcm8cube.stratigraphy_from('eta')
>>> rcm8cube.register_section('demo', dm.section.StrikeSection(y=5))

>>> fig, ax = plt.subplots(4, 1, sharex=True, figsize=(6, 9))
>>> rcm8cube.sections['demo'].show('depth', data='spacetime',
...                                 ax=ax[0], label='spacetime')
>>> rcm8cube.sections['demo'].show('depth', data='preserved',
...                                ax=ax[1], label='preserved')
>>> rcm8cube.sections['demo'].show('depth', data='stratigraphy',
...                                ax=ax[2], label='quick stratigraphy')
>>> rcm8cube.sections['demo'].show('depth', style='lines', data='stratigraphy',
...                                ax=ax[3], label='quick stratigraphy')

(png, hires.png)

../_images/section_demo_quick_strat.png
show_trace(*args, ax=None, **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.

  • **kwargs – Passed to matplotlib plot().

strat_attr

Stratigraphic attributes data object.

Raises

NoStratigraphyError – If no stratigraphy information is found for the section.

trace

Coordinates of the section in the x-y plane.

variables

List of variables.

z

Up-section (vertical) coordinate.