Commit 0eb0d4c1 authored by Laura LINDEPERG's avatar Laura LINDEPERG
Browse files

Add bfi90

parent 114df9f9
......@@ -4,14 +4,15 @@ import read_TimeLoop as readT
class HydrologicalSignatures(object):
def __init__(self, q_mean=-1, bfi=-1, bf_magni=-1, tau_1=-1, tau_2=-1, tau_roques=-1,
def __init__(self, q_mean=-1, bfi_5=-1, bfi_90 = -1, bf_magni=-1, tau_1=-1, tau_2=-1, tau_roques=-1,
a_q=-1, b_q=-1, fdc_slope=-1, fdc_quantile90=-1, fdc_quantile10=-1, runoff_ratio=-1, aridity=-1):
""""
This method creates an object of the HydrologicalSignatures class. Instantiates attributes by default at -1.
"""
# general indices
self.q_mean = q_mean # average discharge over the relationships
self.bfi = bfi # Baseflow index
self.bfi_5 = bfi_5 # Baseflow index
self.bfi_90 = bfi_90
self.bf_magni = bf_magni
# recession indices
self.tau_1 = tau_1 # fast recession time in Horner (2020) methods
......@@ -36,7 +37,8 @@ class HydrologicalSignatures(object):
:return: directly instantiates the computed signatures in the object
"""
self.compute_q_mean(df_obs, column_name_discharge)
self.compute_baseflow_gustard(df_obs, column_name_discharge)
self.bfi_5 = self.compute_baseflow_gustard(df_obs, column_name_discharge)[0]
self.bfi_90 = self.compute_baseflow_gustard(df_obs, column_name_discharge, d=90)[0]
self.compute_bf_magni(df_obs, column_name_discharge)
self.recession_extraction(df_obs, column_name_discharge, min_duration=5, max_duration=30)
self.recession_extraction_roques_methods(df_obs)
......@@ -90,6 +92,7 @@ class HydrologicalSignatures(object):
self.q_mean = df_obs[column_name].mean()
return self.q_mean
def compute_baseflow_gustard(self, df_obs, column_name='Q', k=0.9, d=5):
"""
This method extracts the baseflow from a discharge time series with the Gustard method
......@@ -108,6 +111,7 @@ class HydrologicalSignatures(object):
bf_column_name = 'BF'
# Baseflow extraction for column_name values
df_obs[bf_column_name] = df_obs[column_name].groupby(np.arange(len(df_obs)) // d).transform('min')
minima_values = df_obs[bf_column_name][df_obs[column_name] == df_obs[bf_column_name]].values
index_pivotpoints = np.arange(len(df_obs))
......@@ -126,8 +130,8 @@ class HydrologicalSignatures(object):
df_obs[bf_column_name] = bf_gustard_obs
# get metric
self.bfi = df_obs[bf_column_name].mean() / df_obs[column_name].mean()
return self.bfi, df_obs
bfi = df_obs[bf_column_name].mean() / df_obs[column_name].mean()
return bfi, df_obs
def compute_bf_magni(self, df_obs, column_name='Q'):
"""
......@@ -136,13 +140,16 @@ class HydrologicalSignatures(object):
:param column_name: str corresponding to the name of the dataframe column where discharge time series is stored
:return: baseflow magnitude
"""
bfi, df_obs = self.compute_baseflow_gustard(df_obs, column_name) # la solution de la bricole...
bf_column_name = 'BF_obs'
if (column_name == 'Q') and (not ('BF_obs' in df_obs.columns)):
bf_column_name = 'BF_obs'
bfi, df_obs = HydrologicalSignatures.compute_baseflow_gustard(df_obs, column_name)
bfi, df_obs = self.compute_baseflow_gustard(df_obs, column_name)
if (column_name == 'Q_mod') and (not ('BF_mod' in df_obs.columns)):
bf_column_name = 'BF_mod'
bfi, df_obs = HydrologicalSignatures.compute_baseflow_gustard(df_obs, column_name)
bfi, df_obs = self.compute_baseflow_gustard(df_obs, column_name)
df_obs_daily_interannual_av = readT.get_daily_interannual_average(df_obs)
self.bf_magni = (df_obs_daily_interannual_av[bf_column_name].max() - df_obs_daily_interannual_av[
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment