Skip to content

How-to: dimensions module

Calculating the morphometry parameters for simple water bodies

For simple water bodies, the dimensions module provides classes to easily calculate the H and A (height and surface area) parameters for the MorphometryBlock class, i.e., the &morphometry configuration block.

The InvertedTruncatedPyramid class can be used for pyramidal water bodies with a square/rectangular base while InvertedTruncatedCone is useful for circular water bodies.

Graphical representation of the InvertedTruncatedPyramid Graphical representation of the InvertedTruncatedPyramid

Graphical representation of the InvertedTruncatedCone Graphical representation of the InvertedTruncatedCone

from glmpy import dimensions

my_dimensions = dimensions.InvertedTruncatedSquarePyramid(
    height=6,
    surface_length=40,
    side_slope=1/3,
    num_vals=7,
    surface_elevation=0
)

Heights and surface areas can be then returned with the get_heights() and get_surface_areas() methods:

print(my_dimensions.get_heights())
print(my_dimensions.get_surface_areas())
[-6.0, -5.0, -4.0, -3.0, -2.0, -1.0, 0.0]
[16.0, 100.0, 256.0, 484.0, 784.0, 1156.0, 1600.0]

num_vals

Notice how the length of lists returned by get_heights() and get_surface_areas equals the num_vals attribute? num_vals can be used to increase or decrease the the number of H and A values calculated between the top and bottom of the water body.

Increasing num_vals:

my_dimensions = dimensions.InvertedTruncatedSquarePyramid(
    height=6,
    surface_length=40,
    side_slope=1/3,
    num_vals=9,
    surface_elevation=0
)
print(my_dimensions.get_heights())
print(my_dimensions.get_surface_areas())
[-6.0, -5.25, -4.5, -3.75, -3.0, -2.25, -1.5, -0.75, 0.0]
[16.0, 72.25, 169.0, 306.25, 484.0, 702.25, 961.0, 1260.25, 1600.0]

Decreasing num_vals:

my_dimensions = dimensions.InvertedTruncatedSquarePyramid(
    height=6,
    surface_length=40,
    side_slope=1/3,
    num_vals=4,
    surface_elevation=0
)
print(my_dimensions.get_heights())
print(my_dimensions.get_surface_areas())
[-6.0, -4.0, -2.0, 0.0]
[16.0, 256.0, 784.0, 1600.0]

surface_elevation

The elevation of the water body can be adjusted through the surface_elevation attribute.

Surface elevation of 100m:

my_dimensions = dimensions.InvertedTruncatedSquarePyramid(
    height=6,
    surface_length=40,
    side_slope=1/3,
    num_vals=7,
    surface_elevation=100
)
print(my_dimensions.get_heights())
[94.0, 95.0, 96.0, 97.0, 98.0, 99.0, 100.0]

Surface elevation of -100m:

my_dimensions = dimensions.InvertedTruncatedSquarePyramid(
    height=6,
    surface_length=40,
    side_slope=1/3,
    num_vals=7,
    surface_elevation=100
)
print(my_dimensions.get_heights())
[-106.0, -105.0, -104.0, -103.0, -102.0, -101.0, -100.0]

Invalid dimensions

If InvertedTruncatedSquarePyramid is initialised with invalid dimensions, glm-py will raise an error and tell you how to correct it:

my_dimensions = dimensions.InvertedTruncatedSquarePyramid(
    height=6,
    surface_length=1, # <-- invlaid surface_length
    side_slope=1/3,
    num_vals=7,
    surface_elevation=0
)
ValueError: Invalid combination of height, surface_length, and side_slope attributes. The calculated base_length of the water body is currently <= 0. base_length is calculated by (surface_length-(height/side_slope)*2). Adjust your input attributes to calculate a positive base_length value.

Constructing the &morphometry parameters

You can plug the lists returned by the get_heights() and get_surface_areas methods directly into the NMLMorphometry class from the nml module. Remember to set the bsn_vals attribute in NMLMorphometry to equal the num_vals attribute:

from glmpy import dimensions, nml

num_vals=7

my_dimensions = dimensions.InvertedTruncatedSquarePyramid(
    height=6,
    surface_length=40,
    side_slope=1/3,
    num_vals=num_vals,
    surface_elevation=0
)

morphometry = nml.NMLMorphometry(
    H=my_dimensions.get_heights(),
    A=my_dimensions.get_areas(),
    bsn_vals=num_vals
)