pytuflow.FMTS.time_series

pytuflow.FMTS.time_series#

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

Returns a time-series DataFrame for the given location(s) and data type(s).

It’s possible to pass in a well known shorthand for the data type e.g. q for flow.

The location can also be a filter string, e.g. channel to extract the time-series values for all channels. The following filters are available for the FMTS class:

  • None: returns all locations

  • 1d: returns all locations (same as passing in None for locations)

  • node

The returned column names will be in the format obj/data_type/location e.g. channel/flow/FC01.1_R. The data_type name in the column heading will be identical to the data type name passed into the function e.g. if h is used instead of water level, then the return will be node/h/FC01.1_R.1.

Parameters:
  • locations (str | list[str]) – The location to extract the time series data for. If None is passed in, all locations will be returned for the given data_types.

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

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

Returns:

The time series data.

Return type:

pd.DataFrame

Examples

Extracting flow for a given channel.

>>> res = FMTS('path/to/result.zzn', dat='path/to/result.dat')
>>> res.time_series('ds2', 'q')
time      node/q/ds1
0.000000    0.920000
0.083333    0.910979
0.166667    0.886582
0.250000    0.929299
...              ...
2.666667   14.194231
2.750000   13.511795
2.833333   12.955027
2.916667   12.494930
3.000000   12.135681

Extracting all data types for a given location

>>> res.time_series('ds1', None)
          node/flow/ds1  node/water level/ds1  ...  node/mode/ds1  node/state/ds1
time                                           ...
0.000000       0.920000             36.493000  ...            0.0             0.0
0.083333       0.910979             36.525406  ...            0.0             0.0
0.166667       0.886582             36.516323  ...            0.0             0.0
0.250000       0.929299             36.524315  ...            0.0             0.0
0.333333       2.275538             36.745884  ...            0.0             0.0
...                 ...                   ...  ...            ...             ...
2.666667      14.194231             37.933880  ...            0.0             0.0
2.750000      13.511795             37.898212  ...            0.0             0.0
2.833333      12.955027             37.869987  ...            0.0             0.0
2.916667      12.494930             37.848312  ...            0.0             0.0
3.000000      12.135681             37.833549  ...            0.0             0.0

Extracting all flow results

>>> res.time_series(None, 'flow')
time      node/flow/FC01.36  node/flow/FC01.35  ...  node/flow/ds2_S  node/flow/FC01
0.000000               0.84           0.840000  ...         0.920000            0.92
0.083333               0.00           5.730267  ...         0.917122            0.00
0.166667               0.00           9.591267  ...         0.890924            0.00
0.250000               0.00           9.981448  ...         0.904744            0.00
0.333333               0.00          10.011658  ...         1.959577            0.00
...                     ...                ...  ...              ...             ...
2.666667               0.00          10.006260  ...        14.305518            0.00
2.750000               0.00          10.006241  ...        13.612213            0.00
2.833333               0.00          10.006139  ...        13.029665            0.00
2.916667               0.00          10.006124  ...        12.559101            0.00
3.000000               0.00          10.006373  ...        12.182993            0.00