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

Hydrographs extraction

parent c2078f61
......@@ -3,12 +3,13 @@ import pandas as pd
class HydroClimaticFluxes(object):
def __init__(self, code, discharge_df=-1, safran_df=-1, discharge_timeseries_quality = -1, Deleted_Hydro_Year = -1):
def __init__(self, code, discharge_df=-1, safran_df=-1, discharge_timeseries_quality = -1, deleted_Hydro_Year = -1, entire_q_timeseries = -1):
self.code = code # identifier of the site (e.g. gauge number)
self.discharge_timeseries = discharge_df # dataframe containing discharge time series
self.safran_timeseries = safran_df # dataframe containing P, ET0 and Tair reanalysis over 1958 to present
self.discharge_timeseries_quality = discharge_timeseries_quality
self.Deleted_Hydro_Year = Deleted_Hydro_Year
self.deleted_Hydro_Year = deleted_Hydro_Year
self.entire_q_timeseries = entire_q_timeseries
def extract_discharge_timeseries(self, filepath, type_data='txt_file'):
if type_data == 'BanqueHydro':
......@@ -20,10 +21,11 @@ class HydroClimaticFluxes(object):
def keep_clean_HydroYear(self):
import read_BankHydro as readBH
q_timeseries, quality, removed_years = readBH.delete_HydroYear_withNan(self.discharge_timeseries)
q_timeseries, quality, removed_years, entire_timeseries = readBH.delete_HydroYear_withNan(self.discharge_timeseries)
self.discharge_timeseries = q_timeseries
self.discharge_timeseries_quality = quality
self.Deleted_Hydro_Year = removed_years
self.deleted_Hydro_Year = removed_years
self.entire_q_timeseries = entire_timeseries
def extract_safran_variable(self, foldername, quantity_to_retrieve='Ptot'):
......
......@@ -113,7 +113,9 @@ def delete_HydroYear_withNan(df_obs, NaNvalues_number=20):
df_obs['HydroYear'] = pd.DatetimeIndex(df_obs['HydroDate']).year
# get yearly average with number of NaN values per year
df_obs_year = df_obs.resample('AS', on='HydroDate').sum()
full_discharge_timeseries = pd.DataFrame(df_obs)
Hydro_Year_to_Delete = df_obs_year[df_obs_year.NaN > NaNvalues_number].index.year.values
Hydro_Year_Information = df_obs_year['NaN']
......@@ -128,4 +130,4 @@ def delete_HydroYear_withNan(df_obs, NaNvalues_number=20):
Q_mean_annual = df_obs['Q'].mean()
df_obs['Q'] = df_obs['Q'].fillna(Q_mean_annual)
return df_obs, Hydro_Year_Information, Hydro_Year_to_Delete
\ No newline at end of file
return df_obs, Hydro_Year_Information, Hydro_Year_to_Delete, full_discharge_timeseries
\ No newline at end of file
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