geoglows.analyze
Functions which post process results from the streamflow data service into additional, useful products
- geoglows.analyze.gumbel1(rp: int, xbar: float, std: float) float [source]
Solves the Gumbel Type 1 distribution :param rp: return period (years) :param xbar: average of the dataset :param std: standard deviation of the dataset
- Returns:
solution to gumbel distribution
- Return type:
float
- geoglows.analyze.simple_forecast(ens: DataFrame) DataFrame [source]
Calculates the simple forecast from a dataframe of forecast ensembles
- Parameters:
ens – a dataframe of forecast ensembles
- Returns:
pandas DataFrame with datetime index and columns flow_uncertainty_upper, flow_median, flow_uncertainty_lower
- geoglows.analyze.forecast_stats(ens: DataFrame) DataFrame [source]
Calculates the statistics for a dataframe of forecast ensembles
- Parameters:
ens – a dataframe of forecast ensembles
- Returns:
pandas DataFrame with an index of datetime and columns min, max, mean, median, 25%, 75%
- geoglows.analyze.daily_averages(df: DataFrame) DataFrame [source]
Calculates the daily average of a dataframe with a datetime index
- Parameters:
df – a dataframe of retrospective simulation data
- Returns:
pandas DataFrame with an index of “%m/%d” dates for each day of the year
- geoglows.analyze.monthly_averages(df: DataFrame) DataFrame [source]
Calculates the monthly average of a dataframe with a datetime index
- Parameters:
df – a dataframe of retrospective simulation data
- Returns:
pandas DataFrame with an index of “%m” values for each month
- geoglows.analyze.annual_averages(df: DataFrame) DataFrame [source]
Calculates the annual average of a dataframe with a datetime index
- Parameters:
df – a dataframe of retrospective simulation data
- Returns:
pandas DataFrame with an index of “%Y” values for each year
- geoglows.analyze.daily_stats(df: DataFrame) DataFrame [source]
Calculates the statistics for a datafame given the day of year
- Parameters:
df – historical data to compute daily statistics from
- Returns:
dataframe with average, min, 25% values, median, 75% value and max value for each day of year
- Return type:
pd.DataFrame
- geoglows.analyze.daily_variance(df: DataFrame) DataFrame [source]
Calculate the daily standard deviation of a dataframe with a datetime index
- Parameters:
df – a dataframe of retrospective simulation data
- Returns:
pandas DataFrame with an index of “%m/%d” dates for each day of the year
- geoglows.analyze.daily_flow_anomaly(stats: DataFrame, day_avgs: DataFrame, daily: bool = True) DataFrame [source]
Compute the anomaly between the average forecasted flow and the daily average
- Parameters:
stats – the csv response from the ForecastStats data service
day_avgs – the csv response from the DailyAverages data service
daily – if true, aggregate the hourly forecast to a daily average before computing the anomaly
- Returns:
pandas DataFrame with a datetime index and a column labeled ‘anomaly_m^3/s’
- geoglows.analyze.return_periods(df: DataFrame, rps: int = (2, 5, 10, 25, 50, 100)) dict [source]
Solves the Gumbel Type-I distribution using the annual maximum flow from the historic simulation
- Parameters:
df – a dataframe of retrospective simulation data
rps – an integer or iterable of integer return period numbers to compute
- Returns:
dict with keys ‘max_simulated’ and ‘return_period_{year}’ for each year with float values to 2 decimals
- geoglows.analyze.low_return_periods(hist: DataFrame, rps: tuple = (2, 5, 10, 25, 50, 100)) dict [source]
Solves the Gumbel Type-I distribution using the annual minimum flow from the historic simulation
- Parameters:
hist – the csv response from the HistoricSimulation streamflow data service
rps – a tuple of integer return period numbers to compute
- Returns:
dictionary with keys labeled f’{return_period}_year’ and float values