cross_sections.CrossSection

cross_sections.CrossSection(self, m1d_cross_section)

A cross section in MIKE 1D, uniquely identified by a location ID, chainage, and topo ID.

Parameters

Name Type Description Default
m1d_cross_section The MIKE 1D cross section object. required

Attributes

Name Type Description
location_id str(required) Location ID of the cross section.
chainage float(required) Chainage of the cross section.
topo_id str(required) Topo ID of the cross section.

Notes

Support is currently limited to open cross sections with raw data.

Examples

>>> from mikeio1d.cross_sections import CrossSection
>>> x = [0, 10, 20, 30, 40, 50]
>>> z = [0, 2, 3, 4, 3, 0]
>>> cs = CrossSection.from_xz(x, z, location_id="loc1", chainage=100, topo_id="topo1")

Methods

Name Description
from_xz Create an open cross section from xz data.
plot Plot the cross section.
recompute_processed Recompute the processed data.
set_marker Set a marker at the point nearest to the specified x, z coordinates.
unset_marker Remove the specified marker from the cross section.

from_xz

cross_sections.CrossSection.from_xz(x, z, location_id, chainage, topo_id, default_markers=True)

Create an open cross section from xz data.

Parameters

Name Type Description Default
x Iterable[float] The x coordinates of the cross section. required
z Iterable[float] The z coordinates of the cross section. required
location_id str Location ID of the cross section. required
chainage float Chainage of the cross section. required
topo_id str Topo ID of the cross section. required
default_markers bool If True, default markers will be added to the cross section. True

Returns

Type Description
CrossSection

plot

cross_sections.CrossSection.plot(ax=None, with_markers=True, with_marker_labels=True, **kwargs)

Plot the cross section.

Parameters

Name Type Description Default
ax matplotlib.axes.Axes The axes to plot to. If not provided, a new figure will be created. None
with_markers bool If True, markers will be plotted. True
with_marker_labels bool If True, marker labels will be plotted. Ignored if with_markers is False. True

Returns

Type Description
matplotlib.axes.Axes The axes that was plotted to.

recompute_processed

cross_sections.CrossSection.recompute_processed()

Recompute the processed data.

In most cases this is not necessary as it will be done automatically when the raw data changes. If processed_allow_recompute is set to False, then this will do nothing.

set_marker

cross_sections.CrossSection.set_marker(marker, x, z=None)

Set a marker at the point nearest to the specified x, z coordinates.

Note: if z is not provided, the nearest point in the x direction will be found.

Parameters

Name Type Description Default
marker int | Marker The marker to set. required
x float The x coordinate of the point. required
z float (default: None) The z coordinate of the point. None

Examples

>>> from mikeio1d.cross_sections import Marker
>>> cs.set_marker(Marker.LEFT_LEVEE_BANK, 10)
# The LEFT_LEVEE_BANK marker has been set at the point nearest to x=10.
>>> cs.set_marker(99, 10, 5)
# A user-defined marker (99) has been set at the point nearest to x=10, z=5.

unset_marker

cross_sections.CrossSection.unset_marker(marker)

Remove the specified marker from the cross section.

Parameters

Name Type Description Default
marker int | Marker The marker to remove. required

Examples

>>> cs.unset_marker(99)
# The user-defined marker (99) has been removed from the cross section.
>>> cs.unset_marker(Marker.LEFT_LEVEE_BANK)
# The LEFT_LEVEE_BANK marker has been removed from the cross section.