pytuflow.NCGrid.time_series

pytuflow.NCGrid.time_series#

NCGrid.time_series(locations, data_types, time_fmt='relative', **kwargs)#

Extracts time-series data for the given locations and data types.

The locations can be a single point in the form of a tuple (x, y) or in the Well Known Text (WKT) format. It can also be a list of points, or a dictionary of points where the key 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 returned DataFrame will use a single time index and the column names will be in the form of: label/data_type e.g. pnt1/water level.

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

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

  • time_fmt (str, optional) – The format for the time values. Options are relative or absolute.

Returns:

The time series data.

Return type:

pd.DataFrame

Examples

Get the water level time-series data for a given point defined in a shapefile:

>>> grid = ... # Assume grid is a loaded grid result instance
>>> grid.time_series('/path/to/point.shp', 'water level')
time     water level/pnt1
0.00000               NaN
0.08333               NaN
0.16670               NaN
0.25000               NaN
0.33330         44.125675
0.41670         44.642513
0.50000         45.672554
0.58330         46.877666