pytuflow.GPKG1D.section

Contents

pytuflow.GPKG1D.section#

GPKG1D.section(locations, data_types, time, *args, **kwargs)#

Returns a long plot for the given location and data types at the given time. If one location is given, the long plot will connect the given location down to the outlet. If 2 locations are given, then the long plot will connect the two locations (they must be connectable). If more than 2 locations are given, multiple long plots will be produced (each long plot will be given a unique branch_id), however one channel must be a common downstream location and the other channels must be upstream of this location.

The order of the locations in the location parameter does not matter as both directions are checked, however it will be faster to include the upstream location first as this will be the first connection checked.

The returned DataFrame will have the following columns:

  • branch_id: The branch ID. If more than 2 pipes are provided, or the channels diverge at an intersection, then multiple branches will be returned. The same channel could be in multiple branches. The branch id starts at zero for the first branch, and increments by one for each additional branch.

  • channel: The channel ID.

  • node: The node ID.

  • offset: The offset along the long plot

  • [data_types]: The data types requested.

Parameters:
  • locations (str | list[str]) – The location to extract the section data for. Unlike other plotting methods, the location cannot be None.

  • data_types (str | list[str]) – The data type to extract the section data for. If None is passed in, all node data types will be returned.

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

Returns:

The section data.

Return type:

pd.DataFrame

Raises:

ValueError – Raised if no valid locations are provided or if data_types is not None but the provided data_types are all invalid. A value error is also raised if more than one location is provided and the locations are not connected.

Examples

Extracting a long plot from a given channel ds1 to the outlet at 1.0 hours:

>>> res = GPKG1D('path/to/output_swmm_ts.gpkg')
>>> res.section('ds1', ['bed', 'level', 'max level'], 1.)
    branch_id  channel       node  offset     bed    level  max level
0           0      ds1      ds1.1     0.0  35.950  38.7880    39.0671
6           0      ds1      ds1.2    30.2  35.900  38.6880    38.9963
1           0      ds2      ds1.2    30.2  35.900  38.6880    38.9963
7           0      ds2      ds2.2    88.8  35.320  38.1795    38.5785
2           0      ds3      ds2.2    88.8  35.320  38.1795    38.5785
8           0      ds3      ds3.2   190.0  34.292  37.1793    37.4158
3           0      ds4      ds3.2   190.0  34.292  37.1793    37.4158
9           0      ds4      ds4.2   301.6  33.189  35.6358    35.9533
4           0      ds5      ds4.2   301.6  33.189  35.6358    35.9533
10          0      ds5      ds5.2   492.7  31.260  33.9942    34.3672
5           0  ds_weir      ds5.2   492.7  32.580  33.9942    34.3672
11          0  ds_weir  ds_weir.2   508.9  32.580  32.9532    33.4118

Extracting a long plot between ds1 and ds4 at 1.0 hours:

>>> res.section(['ds1', 'ds4'], ['bed', 'level', 'max level'], 1.)
   branch_id channel   node  offset     bed    level  max level
0          0     ds1  ds1.1     0.0  35.950  38.7880    39.0671
4          0     ds1  ds1.2    30.2  35.900  38.6880    38.9963
1          0     ds2  ds1.2    30.2  35.900  38.6880    38.9963
5          0     ds2  ds2.2    88.8  35.320  38.1795    38.5785
2          0     ds3  ds2.2    88.8  35.320  38.1795    38.5785
6          0     ds3  ds3.2   190.0  34.292  37.1793    37.4158
3          0     ds4  ds3.2   190.0  34.292  37.1793    37.4158
7          0     ds4  ds4.2   301.6  33.189  35.6358    35.9533