pytuflow.DAT.section

Contents

pytuflow.DAT.section#

DAT.section(locations, data_types, time, averaging_method=None)#

Extracts section data for the given locations and data types.

The locations can be a list of x, y tuple points, or a Well Known Text (WKT) line string. It can also be a dictionary of key, line-string pairs where the key is the name that will be used in the column name in the resulting DataFrame.

The locations argument can also be a single GIS file path e.g. Shapefile or GPKG (but any format supported by GDAL is also supported). GPKG’s should follow the TUFLOW convention if specifying the layer name within the database database.gpkg >> layer. If the GIS layer has a field called name, label, or ID then this will be used as the column name in the resulting DataFrame.

The resulting DataFrame will use multi-index columns since the data is not guaranteed to have the same index. The level 1 index will be the label, and the level 2 index will be the data type. The offset will always be the first column within the level 2 index.

Parameters:
  • locations (list[Point] | str | PathLike) – The location to extract the section data for.

  • data_types (str | list[str]) – The data types to extract the section data for.

  • time (TimeLike) – The time to extract the section data for.

  • averaging_method (str, optional) –

    The depth-averaging method to use. Only applicable for 3D results. If None is provided for a 3D result, the current rendering method will be used.

    The averaging methods are:

    • 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>

    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.

Returns:

The section data.

Return type:

pd.DataFrame

Examples

Get the water level section data for a given line string defined as a list of points:

>>> mesh = ... # Assume mesh is a loaded Mesh result
>>> mesh.section([(293250, 6178030), (293500, 6178030)], 'water level', 1.5)
         line1
        offset water level
0     0.000000   42.724101
1     1.706732   42.723076
2     4.624017   42.722228
3     7.191697   42.722665
4    11.116369   42.723587
5    16.251266   42.723855
6    21.386370   42.723230
7    25.869978   42.722765
8    28.437221   42.722449
9    31.656245   42.721945
10   36.791135   42.721079

Get the bed level and max water level data using a shapefile to define the locations (both datasets are static and therefore the time argument won’t have any effect):

>>> mesh.section('path/to/shapefile.shp', ['bed level', 'max h'], -1)
       Line_1                                 Line_2
       offset  bed level max water level      offset  bed level max water level
0    0.000000  43.646312             NaN    0.000000  43.112894             NaN
1    0.145704  43.645835             NaN    2.213407  43.088104             NaN
2    2.801012  43.647998             NaN    6.926959  43.035811             NaN
3    7.819650  43.643313             NaN   11.926842  42.987500             NaN
4   12.838279  43.634620             NaN   16.926803  42.950000             NaN
5   17.856980  43.626645             NaN   21.926729  42.916000             NaN
6   22.875678  43.615949             NaN   26.926655  42.888000             NaN
7   25.941652  43.611225             NaN   31.926952  42.865499             NaN
8   28.451249  43.603039             NaN   36.926835  42.846001             NaN
9   32.913571  43.591435             NaN   41.926869  42.829500             NaN
10  37.932185  43.578406             NaN   46.926830  42.812500             NaN
11  42.950809  43.569102             NaN   51.926756  42.795000       42.443355
12  47.969530  43.577088             NaN   56.926682  42.777190       42.443967
13  52.988495  43.666201             NaN   61.926643  42.760000       42.444545
14  58.007149  43.773129             NaN   66.926940  42.744000       42.445528
15  63.026036  43.897195             NaN   71.926823  42.730500       42.447615
16  68.044737  43.612406             NaN   76.926857  42.719000       42.449872
17  73.063420  42.849014       42.834780   81.926818  42.708500       42.452022