pytuflow.TPC.time_series#
- TPC.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.
qforflow.The location can be an ID or filter string, e.g.
channelto extract the maximum values for all channels. An ID can be used alongside a filter string since there can be duplicate IDs across domains e.g.test/channel- wheretestis the name andchannelis an additional filter. Note, the order does not matter, but it doesn’t work very well if your ID has a ‘/’ or has the same name as a filter string (e.g. calling a po line ‘line’).The following filters are available for the
TPCclass:Domain filters:
1d2d(orpo)rl(or0d)
Geometry filters:
nodechannelpoint- (for 2d and rl domains only - usenodefor 1d domain)line- (for 2d and rl domains only - usechannelfor 1d domain)polygon(orregion)
Combine filters:
[filter1]/[filter2]/...: (use/to delim).
The returned column names will be in the format
obj/data_type/locatione.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. ifhis used instead ofwater level, then the return will benode/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 = TPC('path/to/file.tpc') >>> res.time_series('ds1', 'q') Time (h) channel/q/ds1 0.000000 0.000 0.016667 0.000 ... ... 2.983334 8.670 3.000000 8.391
Extracting all data types for a given location
>>> res.time_series('ds1', None) Time (h) channel/Flow/ds1 channel/Velocity/ds1 0.000000 0.000 0.000 0.016667 0.000 0.000 ... ... ... 2.983334 8.670 1.348 3.000000 8.391 1.333
Extracting all
flowresults>>> res.time_series(None, 'flow') Time (h) channel/flow/ds1 ... channel/flow/FC_weir1 0.000000 0.000 ... 0.0 0.016667 0.000 ... 0.0 ... ... ... ... 2.983334 8.670 ... 0.0 3.000000 8.391 ... 0.0