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 ICrossSection The MIKE 1D cross section object. required

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")

Attributes

Name Description
bottom_level Bottom level of the cross section.
chainage Chainage of the cross section.
coords Get the geographical coordinates of the cross section line.
geometry The geographical geometry of the cross section line.
height Height of the cross section.
interpolated Is the cross section interpolated? (i.e. not measured).
is_open Is the cross section open? (i.e. not closed).
location Location of the cross section (DHI.Mike1D.Generic.ZLocation object).
location_id Location ID of the cross section.
m1d_cross_section The DHI.Mike1D.CrossSectionModule.ICrossSection object that CrossSection wraps.
markers pandas.DataFrame: The markers of the cross section as a pandas DataFrame.
max_width Maximum width of the cross section.
min_water_depth Minimum water depth of the cross section.
number_of_processing_levels int: The number of levels used in the processed data.
processed pandas.DataFrame: The processed cross section data as a pandas DataFrame.
processed_allow_recompute bool: Whether the processed data can be recomputed (e.g. if the raw data has changed).
processing_levels tuple[float]: A tuple of the level elevations used in the processed data.
processing_levels_method int, ProcessLevelMethod: The method used to generate processing levels.
radius_type int, RadiusType: The type of hydraulic radius used in the cross section.
raw pandas.DataFrame: The raw cross section data as a pandas DataFrame.
resistance_distribution int, ResistanceDistribution: The distribution of resistance used in the cross section.
resistance_left_high_flow float: Resistance for the left high flow zone.
resistance_low_flow float: Resistance for the low flow zone.
resistance_right_high_flow float: Resistance for the right high flow zone.
resistance_type int, ResistanceType: The type of resistance used by the cross section.
topo_id Topo ID of the cross section.
zmax Maximum elevation of the cross section.
zmin Minimum elevation of the cross section.

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

Name Type Description
cross_section 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

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

recompute_processed

cross_sections.CrossSection.recompute_processed()

Recompute the processed data.

Notes

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.