Skip to content

Outflows

CustomOutflows

Create a simple outflow timeseries for GLM.

Generates an outflow timeseries in m^3/second between a given start and end datetime. The timeseries can be updated in two ways: 1. Providing a dictionary with specific datetimes and their corresponding outflows. 2. Specifying a fixed outflow value between two datetimes. The outflow timeseries can be returned as a pandas DataFrame or exported to a CSV file.

Attributes:

Name Type Description
start_datetime Union[str, Timestamp, datetime]

The start datetime of the outflow timeseries. Must be of type Timestamp, datetime, or a valid datetime string.

end_datetime Union[str, Timestamp, datetime]

The end datetime of the outflow timeseries. Must be of type Timestamp, datetime, or a valid datetime string.

frequency str

Frequency of the outflow timeseries. Must be either '24h' (daily) or '1h' (hourly). Default is '24h'.

base_outflow Union[int, float]

Base flow of the outflow timeseries in m^3/day or m^3/hour depending on frequency. Default is 0.0.

Examples:

>>> from glmpy import outflows

Initialise a daily outflow timeseries with a base outflow of 0.0 m^3/day:

>>> outflows = outflows.CustomOutflows(
...     start_datetime="2020-01-01",
...     end_datetime="2020-01-10",
...     frequency="24h",
...     base_outflow=0.0
... )
Update the timeseries with a dictionary of specific dates and their
corresponding outflows in m^3/day:
>>> outflows_dict = {
...     "2020-01-02": 2, # 2m^3/day
...     "2020-01-03": 4, # 4m^3/day
...     "2020-01-04": 6 # 6m^3/day
... }
>>> outflows.set_on_datetime(outflows_dict)

Return and print the outflows timeseries as a pandas DataFrame. Note, the outflow units have been converted to m^3/second as expected by GLM:

>>> print(outflows.get_outflows())
        time      flow
0 2020-01-01  0.000000
1 2020-01-02  0.000023
2 2020-01-03  0.000046
3 2020-01-04  0.000069
4 2020-01-05  0.000000
5 2020-01-06  0.000000
6 2020-01-07  0.000000
7 2020-01-08  0.000000
8 2020-01-09  0.000000
9 2020-01-10  0.000000

Update the timeseries with a fixed outflow between two dates:

>>> outflows.set_over_datetime(
...     from_datetime="2020-01-05",
...     to_datetime = "2020-01-09",
...     outflow = 5 # 5m^3/day
... )

Return and print the outflows timeseries as a pandas DataFrame:

>>> print(outflows.get_outflows())
        time      flow
0 2020-01-01  0.000000
1 2020-01-02  0.000023
2 2020-01-03  0.000046
3 2020-01-04  0.000069
4 2020-01-05  0.000058
5 2020-01-06  0.000058
6 2020-01-07  0.000058
7 2020-01-08  0.000058
8 2020-01-09  0.000058
9 2020-01-10  0.000000

Write the outflows to a CSV without the index:

>>> outflows.write_outflows(file_path="outflows.csv")

get_outflows()

Get the outflow timeseries.

Returns the outflow timeseries as a pandas DataFrame.

Examples:

>>> from glmpy import outflows
>>> outflows = outflows.CustomOutflows(
...     start_datetime="2020-01-01",
...     end_datetime="2020-01-10",
...     frequency="24h",
...     base_outflow=0.0
... )
>>> outflows.get_outflows()

set_on_datetime(datetime_outflows)

Set the outflow volume for specific datetimes.

The outflow volume for specific datetimes can be set by providing a dictionary with datetimes as keys and outflow volumes as values. Outflow volumes will be treated as having the same units as the base outflow (m^3/day or m^3/hour depending on frequency).

Parameters:

Name Type Description Default
datetime_outflows Dict[Union[str, pd.Timestamp, dt.datetime],
required
Union

Dictionary with valid datetimes as keys and outflow volumes as values.

required

Examples:

>>> from glmpy import outflows
>>> outflows = outflows.CustomOutflows(
...     start_datetime="2020-01-01 00:00:00",
...     end_datetime="2020-01-01 10:00:00",
...     frequency="1h",
...     base_outflow=0.0
... )
>>> outflows_dict = {
...     "2020-01-01 01:00:00": 10,
...     "2020-01-01 03:00:00": 12,
...     "2020-01-01 05:00:00": 14
... }
>>> outflows.set_on_datetime(outflows_dict)
>>> print(outflows.get_outflows())
                  time      flow
0  2020-01-01 00:00:00  0.000000
1  2020-01-01 01:00:00  0.002778
2  2020-01-01 02:00:00  0.000000
3  2020-01-01 03:00:00  0.003333
4  2020-01-01 04:00:00  0.000000
5  2020-01-01 05:00:00  0.003889
6  2020-01-01 06:00:00  0.000000
7  2020-01-01 07:00:00  0.000000
8  2020-01-01 08:00:00  0.000000
9  2020-01-01 09:00:00  0.000000
10 2020-01-01 10:00:00  0.000000

set_over_datetime(from_datetime, to_datetime, outflow)

Set the outflow volume between two datetimes.

Outflow volumes between two datetimes can be set by providing a start datetime, end datetime, and an outflow volume. Outflows are updated on the start and end datetime.

Parameters:

Name Type Description Default
from_datetime Union[str, Timestamp, datetime]

The datetime to update the outflow timeseries from.

required
to_datetime Union[str, Timestamp, datetime]

The datetime to update the outflow timeseries to.

required
outflow Union[float, int]

The outflow volume to set between the from_datetime and to_datetime in m^3/day or m^3/hour (depending on frequency).

required

Examples:

>>> from glmpy import outflows
>>> outflows = outflows.CustomOutflows(
...     start_datetime="2020-01-01 00:00:00",
...     end_datetime="2020-01-01 10:00:00",
...     frequency="1h",
...     base_outflow=0.0
... )
>>> outflows.set_over_datetime(
...     from_datetime="2020-01-01 01:00:00",
...     to_datetime = "2020-01-01 09:00:00",
...     outflow = 5
... )
>>> print(outflows.get_outflows())
                  time      flow
0  2020-01-01 00:00:00  0.000000
1  2020-01-01 01:00:00  0.001389
2  2020-01-01 02:00:00  0.001389
3  2020-01-01 03:00:00  0.001389
4  2020-01-01 04:00:00  0.001389
5  2020-01-01 05:00:00  0.001389
6  2020-01-01 06:00:00  0.001389
7  2020-01-01 07:00:00  0.001389
8  2020-01-01 08:00:00  0.001389
9  2020-01-01 09:00:00  0.001389
10 2020-01-01 10:00:00  0.000000

write_outflows(file_path)

Write the outflow timeseries to a CSV file.

The outflow timeseries can be written to a CSV file by providing a path to the CSV file. The index of the DataFrame is not included in the CSV file.

Parameters:

Name Type Description Default
file_path str

Path to the CSV file to which the outflow timeseries will be written.

required

Examples:

>>> from glmpy import outflows
>>> outflows = outflows.CustomOutflows(
...     start_datetime="2020-01-01",
...     end_datetime="2020-01-10",
...     frequency="24h",
...     base_outflow=10
... )
>>> outflows.write_outflows(file_path="outflows.csv")