pytuflow.NCMesh.maximum

Contents

pytuflow.NCMesh.maximum#

NCMesh.maximum(data_types, averaging_method=None, split_vector_components=False)#

Returns the maximum values for the given data types.

Some formats store maximum values in the metadata (e.g. XMDF), if this is the case, the maximum values will be returned directly from the metadata. If the format does not store maximum values, the maximum values will be calculated from the data. In this case, the maximum and temporal datasets will be treated as separate. For example, if "depth" is requested as a data type, it will be calculated from the temporal depth data. If "max depth" is requested, it will be calculated from the maximum depth data.

If multiple data types are requested, a DataFrame will be returned with the data types as the index and the maximum values as the column. Vector results will return the magnitude of the vector.

Parameters:
  • data_types (str | list[str]) – The data types to return the maximum values for.

  • averaging_method (str, optional) –

    The depth-averaging method to use. Only applicable for 3D results. If set to None (the default), then the maximum will be calculated from all vertical levels. If a depth averaging method is used, then the maximum will be calculated from the depth-averaged data.

    The averaging methods are:

    • None

    • singlelevel

    • multilevel

    • depth

    • height

    • elevation

    • sigma

    The averaging method parameters can be adjusted by building them into the method string in a URI style format. The format is as follows:

    <method>?dir=<dir>&<value1>&<value2>

    The averaging method parameters can be adjusted by building them into the method string in a URI style format. The format is as follows:

    <method>?dir=<dir>&<value1>&<value2>

    Where

    • <method> is the averaging method name

    • <dir> is the direction, top or bottom (i.e. from top or from bottom) - only used by certain averaging methods

    • <value1>, <value2>… are the values to be used in the averaging method (the number required to be passed depends on the averaging method)

    e.g. 'singlelevel?dir=top&1' uses the single level averaging method and takes the first vertical layer from the top. Or 'sigma&0.1&0.9' uses the sigma averaging method and averages values located between the 10th and 90th water column depth.

  • split_vector_components (bool, optional) – Whether to split vector components into separate x and y values and calculate maximums for each component separately. Only applicable for vector data types. Components are calculated separately and do not necessarily represent a single point in space and time and magnitudes should not be calculated from the returned values. Components will be returned as a tuple i.e. [vec-x, vec-y].

Returns:

The maximum value(s) for the given data type(s).

Return type:

float | tuple[float, float] | pd.DataFrame

Examples

Get the maximum water level for a given mesh:

>>> mesh = ... # Assume mesh is a loaded Mesh result
>>> mesh.maximum('water level')
45.672345

Get the maximum velocity and depth for multiple data types:

>>> mesh.maximum(['vector velocity', 'depth'])
                  maximum
vector velocity  1.234567
depth            5.678901