HydPy-WQ-Trapeze (multi-trapeze river profile submodel)

wq_trapeze is a stateless “two-way” submodel. It supports calculating properties like the wetted area for a given water depth and properties like the water depth for a given wetted area. See the documentation on the application model sw1d_channel, which shows the usage of “both ways” in practice. Here, we only aim to visualise how wq_trapeze combines multiple symmetric trapezes to a single cross-section profile via method plot().

The following test function helps us to use method plot() repeatedly and insert the generated figures into the online documentation:

>>> from matplotlib import pyplot
>>> from hydpy.core.testtools import save_autofig
>>> def plot(example=None, save=True, add_x_y=None, **kwargs):
...     derived.trapezeheights.update()
...     derived.slopewidths.update()
...     figure = model.plot(**kwargs)
...     if add_x_y is not None:
...         x, y = add_x_y
...         pyplot.plot([x, x], [y, 5.0], color=kwargs.get("color"), linestyle=":")
...         pyplot.plot([-x, -x], [y, 5.0], color=kwargs.get("color"), linestyle=":")
...     if example is not None:
...         save_autofig(f"wq_trapeze_{example}.png", figure=figure)

We start with a single trapeze:

>>> from hydpy.models.wq_trapeze import *
>>> parameterstep()
>>> nmbtrapezes(1)

Parameter BottomLevels does not affect the profile’s shape for a single trapeze. We set its value to one meter arbitrarily:

>>> bottomlevels(1.0)

With parameter BottomWidths larger than zero and parameter SideSlopes being zero, the single trapeze becomes a simple, infinitely high rectangle:

>>> bottomwidths(2.0)
>>> sideslopes(0.0)
>>> plot("rectangle")
_images/wq_trapeze_rectangle.png

Conversely, the single trapeze becomes a simple, infinitely high triangle:

>>> bottomwidths(0.0)
>>> sideslopes(2.0)
>>> plot("triangle")
_images/wq_trapeze_triangle.png

Set both values larger than zero to gain a “complete” trapeze:

>>> bottomwidths(2.0)
>>> sideslopes(2.0)
>>> plot("one_trapeze")
_images/wq_trapeze_one_trapeze.png

Next, we want to construct a more complex profile consisting of three trapezes:

>>> nmbtrapezes(3)

We must assign them increasing bottom levels (the bottom level of an upper trapeze defines the height of its lower neighbour):

>>> bottomlevels(1.0, 3.0, 4.0)

The following profile combines the three previously defined geometries:

>>> bottomwidths(2.0, 0.0, 2.0)
>>> sideslopes(0.0, 2.0, 2.0)
>>> plot("three_trapezes")
_images/wq_trapeze_three_trapezes.png

Note that each upper trapeze is stretched according to the width of its lower neighbour. The following example illustrates this more clearly by plotting each trapeze in a different colour:

>>> nmbtrapezes(1)
>>> bottomlevels(1.0)
>>> bottomwidths(2.0)
>>> sideslopes(0.0)
>>> plot(add_x_y=(1.0, 3.0), ymax=3.0, color="green", label="trapeze 1")
>>> bottomlevels(3.0)
>>> bottomwidths(2.0)
>>> sideslopes(2.0)
>>> plot(add_x_y=(3.0, 4.0), ymax=4.0, color="yellow", label="trapeze 2")
>>> bottomlevels(4.0)
>>> bottomwidths(8.0)
>>> sideslopes(2.0)
>>> plot("config_1", ymax=5.0, color="red", label="trapeze 3")
_images/wq_trapeze_config_1.png

In addition to the configuration options shown in the last example, one can pass True to the keyword argument label. Then, plot() tries to include the responsible element’s name into the legend, which is impossible in this example, so that “?” serves as a spare:

>>> plot("config_2", ymax=3.0, label=True)
_images/wq_trapeze_config_2.png

(Upon closer inspection, the last example also shows that plot() ignores too low ymax values silently.)

class hydpy.models.wq_trapeze.Model[source]

Bases: TrapezeModel, CrossSectionModel_V2

HydPy-WQ-Trapeze (multi-trapeze river profile submodel).

The following interface methods are available to main models using the defined model as a submodel:
The following “additional methods” might be called by one or more of the other methods or are meant to be directly called by the user:
DOCNAME: DocName = ('WQ-Trapeze', 'multi-trapeze river profile submodel')
REUSABLE_METHODS: ClassVar[tuple[type[ReusableMethod], ...]] = ()
cymodel: CyModelProtocol | None
parameters: parametertools.Parameters
sequences: sequencetools.Sequences
masks: masktools.Masks
class hydpy.models.wq_trapeze.ControlParameters(master: Parameters, cls_fastaccess: type[FastAccessParameter] | None = None, cymodel: CyModelProtocol | None = None)

Bases: SubParameters

Control parameters of model wq_trapeze.

The following classes are selected:
class hydpy.models.wq_trapeze.DerivedParameters(master: Parameters, cls_fastaccess: type[FastAccessParameter] | None = None, cymodel: CyModelProtocol | None = None)

Bases: SubParameters

Derived parameters of model wq_trapeze.

The following classes are selected:
class hydpy.models.wq_trapeze.FactorSequences(master: Sequences, cls_fastaccess: type[TypeFastAccess_co] | None = None, cymodel: CyModelProtocol | None = None)

Bases: FactorSequences

Factor sequences of model wq_trapeze.

The following classes are selected: