swmm.pandas.Output.node_series

Output.node_series(node, attribute=('invert_depth', 'flooding_losses', 'total_inflow'), start=None, end=None, columns='attr', asframe=True)[source]

Get one or more time series for one or more node attributes. Specify series start index and end index to get desired time range.

Parameters
node: Union[int, str, Sequence[Union[int, str]], None]

The node index or name.

attribute: Union[int, str, Enum, Sequence[Union[int, str, Enum]], None],

The attribute index or name.

On of:

invert_depth, hydraulic_head, ponded_volume, lateral_inflow, total_inflow, flooding_losses.

defaults to: (‘invert_depth’,’flooding_losses’,’total_inflow’)

Can also input the integer index of the attribute you would like to pull or the actual enum from Output.node_attributes.

Setting to None indicates all attributes.

start: Union[str, int, datetime, None], optional

The start datetime or index of from which to return series, defaults to None.

Setting to None indicates simulation start.

end: Union[str, int, datetime, None], optional

The end datetime or index of from which to return series, defaults to None.

Setting to None indicates simulation end.

columns: Optional[str], optional

Decide whether or not to break out elements or attributes as columns. May be one of:

None: Return long-form data with one column for each data point

‘elem’: Return data with a column for each element. If more than one attribute are given, attribute names are added to the index.

‘attr’: Return data with a column for each attribute. If more than one element are given, element names are added to the index.

defaults to ‘attr’.

asframe: bool

A switch to return an indexed DataFrame. Set to False to get an array of values only, defaults to True.

Returns
Union[pd.DataFrame,np.ndarray]

A DataFrame or ndarray of attribute values in each column for requested date range and nodes.

Examples

Pull single time series for a single node

>>> from swmm.pandas import Output,test_out_path
>>> out = Output(test_out_path)
>>> out.node_series('JUNC2', 'invert_depth')
                     invert_depth
datetime
1900-01-01 00:05:00      0.334742
1900-01-01 00:10:00      0.509440
1900-01-01 00:15:00      0.562722
1900-01-01 00:20:00      0.602668
1900-01-01 00:25:00      0.631424
...                           ...
1900-01-01 23:40:00      0.766949
1900-01-01 23:45:00      0.766949
1900-01-01 23:50:00      0.766949
1900-01-01 23:55:00      0.766949
1900-01-02 00:00:00      0.766949
[288 rows x 1 columns]

Pull a wide-form dataframe for all parameters for a node

>>> out.node_series('JUNC2', out.node_attributes)
                   invert_depth  hydraulic_head  ponded_volume  lateral_inflow  total_inflow  flooding_losses  groundwater  pol_rainfall     sewage
datetime
1900-01-01 00:05:00      0.334742       -0.705258            0.0        0.185754      0.185785              0.0     3.935642      0.000000  95.884094
1900-01-01 00:10:00      0.509440       -0.530560            0.0        0.196764      0.197044              0.0     8.902034      0.000000  90.335831
1900-01-01 00:15:00      0.562722       -0.477278            0.0        0.198615      0.199436              0.0     9.038609      0.000000  89.253334
1900-01-01 00:20:00      0.602668       -0.437332            0.0        0.200802      0.202462              0.0     9.259741      0.000000  87.919571
1900-01-01 00:25:00      0.631424       -0.408576            0.0        0.203108      0.205802              0.0     9.523322      0.000000  86.492836
...                           ...             ...            ...             ...           ...              ...          ...           ...        ...
1900-01-01 23:40:00      0.766949       -0.273052            0.0        0.314470      0.352183              0.0    15.293419     39.303375  45.430920
1900-01-01 23:45:00      0.766949       -0.273052            0.0        0.314499      0.352183              0.0    15.313400     39.292118  45.430920
1900-01-01 23:50:00      0.766949       -0.273052            0.0        0.314530      0.352183              0.0    15.333243     39.281300  45.430920
1900-01-01 23:55:00      0.766949       -0.273052            0.0        0.314559      0.352183              0.0    15.352408     39.271194  45.430920
1900-01-02 00:00:00      0.766949       -0.273052            0.0        0.314590      0.352183              0.0    15.371475     39.261478  45.430920
[288 rows x 9 columns]

Pull a long-form dataframe of all nodes and attributes

>>> out.node_series('JUNC2', out.node_attributes, columns=None)
                                            result
datetime            element attribute
1900-01-01 00:05:00 JUNC1   invert_depth   0.002143
1900-01-01 00:10:00 JUNC1   invert_depth   0.010006
1900-01-01 00:15:00 JUNC1   invert_depth   0.017985
1900-01-01 00:20:00 JUNC1   invert_depth   0.025063
1900-01-01 00:25:00 JUNC1   invert_depth   0.031329
...                                             ...
1900-01-01 23:40:00 STOR1   sewage        51.502193
1900-01-01 23:45:00 STOR1   sewage        51.164684
1900-01-01 23:50:00 STOR1   sewage        50.905445
1900-01-01 23:55:00 STOR1   sewage        50.715385
1900-01-02 00:00:00 STOR1   sewage        50.574486
[23328 rows x 1 columns]

Pull flow timeseries and calculate the total flow volume for all nodes

>>> from swmm.pandas.constants import gal_per_cf
>>> df = out.node_series(out.nodes, ['lateral_inflow','total_inflow','flooding_losses'])
                             lateral_inflow  total_inflow  flooding_losses
datetime            element
1900-01-01 00:05:00 JUNC1          0.002362      0.002362              0.0
1900-01-01 00:10:00 JUNC1          0.005792      0.005792              0.0
1900-01-01 00:15:00 JUNC1          0.006524      0.006524              0.0
1900-01-01 00:20:00 JUNC1          0.007306      0.007306              0.0
1900-01-01 00:25:00 JUNC1          0.008039      0.008039              0.0
...                                     ...           ...              ...
1900-01-01 23:40:00 STOR1          0.000000      1.455056              0.0
1900-01-01 23:45:00 STOR1          0.000000      1.455056              0.0
1900-01-01 23:50:00 STOR1          0.000000      1.455056              0.0
1900-01-01 23:55:00 STOR1          0.000000      1.455056              0.0
1900-01-02 00:00:00 STOR1          0.000000      1.455056              0.0
[2592 rows x 3 columns]
#----------------------------------------------------------------------------
# group by element name and sum,
# then multiply by reporting timestep in seconds
# then convert to millions of gallons
>>> df.groupby('element').sum() * out.report * gal_per_cf / 1e6
        lateral_inflow  total_inflow  flooding_losses
element
JUNC1          0.101562      0.101898         0.000053
JUNC2          0.544891      0.857012         0.000000
JUNC3          0.000000      0.502078         0.080634
JUNC4          1.813826      2.096243         0.317929
JUNC5          0.000000      1.870291         0.073878
JUNC6          0.000000      1.701455         0.000000
OUT1           0.000000      1.698081         0.000000
OUT2           0.000000      0.575617         0.000000
STOR1          0.000000      1.862843         0.172482

Last update: Mar 31, 2022