Skip to content

Inflows

CatchmentRunoffInflows

Calculate runoff inflows from a catchment.

Generates an inflows timeseries by calculating catchment runoff from a pandas DataFrame of precipitation data. Requires a catchment area, a runoff coefficient or threshold, and a precipitation timeseries in either hourly or daily timesteps. Inflows are calculated at the same timestep as the precipitation data but in units of m^3/s. CatchmentRunoffInflows provides methods to return the calculated inflows timeseries as a pandas DataFrame or to write the timeseries to a CSV.

Attributes:

Name Type Description
met_data DataFrame

A pandas DataFrame of meteorological data.

precip_col str

Name of the column in the DataFrame containing precipitation data in m/day or m/hour.

date_time_col str

Name of the column in the DataFrame containing datetime data.

catchment_area Union[float, int]

Area of the catchment in square meters.

runoff_coef Union[float, None]

Runoff coefficient for the catchment. The fraction of rainfall that will result in runoff. Either runoff_coef or runoff_threshold must be provided.

runoff_threshold Union[float, None]

Runoff threshold for the catchment. The amount of rainfall in mm to generate runoff. Either runoff_coef or runoff_threshold must be provided.

Examples:

>>> from glmpy import inflows

Generate a daily timeseries of rainfall:

>>> daily_met_data = pd.DataFrame({
...     'Date': pd.date_range(
...         start='1997-01-01',
...         end='2004-12-31',
...         freq='24h'),
...     'Rain': 0.024 #m per day
... })

Calculate inflows with a 50% runoff coefficient and a 1000 m^2 catchment area:

>>> inflows_data = inflows.CatchmentRunoffInflows(
...     met_data = daily_met_data,
...     catchment_area = 1000,
...     runoff_coef = 0.5,
...     precip_col = 'Rain',
...     date_time_col = 'Date'
... )
>>> inflows_data.get_inflows()

Generate a hourly timeseries of rainfall:

>>> hourly_met_data = pd.DataFrame({
...     'Date': pd.date_range(
...         start='1997-01-01',
...         end='2004-12-31',
...         freq='1h'),
...     'Rain': 0.001
... })

Calculate inflows with a 50% runoff coefficient and a 1000 m^2 catchment area:

>>> inflows_data = inflows.CatchmentRunoffInflows(
...     met_data = hourly_met_data,
...     catchment_area = 1000,
...     runoff_coef = 0.5,
...     precip_col = 'Rain',
...     date_time_col = 'Date'
... )
>>> inflows_data.get_inflows()

get_inflows()

Get the inflows timeseries.

Returns a pandas dataframe of the calculated catchment runoff inflows.

Returns:

Name Type Description
inflows DataFrame

DataFrame of inflow data.

Examples:

>>> from glmpy import inflows
>>> import pandas as pd

Generate an hourly timeseries of rainfall:

>>> hourly_met_data = pd.DataFrame({
...     'Date': pd.date_range(
...         start='1997-01-01',
...         end='2004-12-31',
...         freq='1h'
...     ),
...     'Rain': 0.001
... })

Calculate inflows with a 50% runoff coefficient and a 1000 m^2 catchment area

>>> inflows_data = inflows.CatchmentRunoffInflows(
...     met_data = hourly_met_data,
...     catchment_area = 1000,
...     runoff_coef = 0.5,
...     precip_col = 'Rain',
...     date_time_col = 'Date'
... )

Call get_inflows() to return the inflows timeseries:

>>> inflows_data.get_inflows()

write_inflows(file_path)

Write the inflow timeseries to a CSV file.

Calculates catchment runoff inflows and writes the timeseries to a CSV.

Parameters:

Name Type Description Default
file_path str

Path to the output CSV file.

required

Examples:

>>> from glmpy import inflows
>>> import pandas as pd
>>> daily_met_data = pd.DataFrame({
...     'Date': pd.date_range(
...         start='1997-01-01',
...         end='2004-12-31',
...         freq='24h'),
...     'Rain': 0.024
... })
>>> inflows_data = inflows.CatchmentRunoffInflows(
...     met_data = daily_met_data,
...     catchment_area = 1000,
...     runoff_coef = 0.5,
...     precip_col = 'Rain',
...     date_time_col = 'Date'
... )

Call write_inflows to write the inflows timeseries to a CSV:

>>> inflows_data.write_inflows(file_path='runoff.csv')