Commit d4100465 authored by Laura LINDEPERG's avatar Laura LINDEPERG
Browse files

Information about q_timeseries quality

parent 56cbcad1
......@@ -3,10 +3,12 @@ import pandas as pd
class HydroClimaticFluxes(object):
def __init__(self, code, discharge_df=-1, safran_df=-1):
def __init__(self, code, discharge_df=-1, safran_df=-1, discharge_timeseries_quality = -1, Deleted_Hydro_Year = -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
def extract_discharge_timeseries(self, filepath, type_data='txt_file'):
if type_data == 'BanqueHydro':
......@@ -18,7 +20,11 @@ class HydroClimaticFluxes(object):
def keep_clean_HydroYear(self):
import read_BankHydro as readBH
self.discharge_timeseries = readBH.delete_HydroYear_withNan(self.discharge_timeseries)
q_timeseries, quality, removed_years = readBH.delete_HydroYear_withNan(self.discharge_timeseries)
self.discharge_timeseries = q_timeseries
self.discharge_timeseries_quality = quality
self.Deleted_Hydro_Year = removed_years
def extract_safran_variable(self, foldername, quantity_to_retrieve='Ptot'):
import netCDF4 as nc
......
......@@ -114,7 +114,10 @@ def delete_HydroYear_withNan(df_obs, NaNvalues_number=20):
# get yearly average with number of NaN values per year
df_obs_year = df_obs.resample('AS', on='HydroDate').sum()
Hydro_Year_to_Delete = df_obs_year[df_obs_year.NaN > NaNvalues_number ].index.year.values
Hydro_Year_to_Delete = df_obs_year[df_obs_year.NaN > NaNvalues_number].index.year.values
Hydro_Year_Information = df_obs_year['NaN']
Hydro_Year_Information.index = Hydro_Year_Information.index.year
if not Hydro_Year_to_Delete.any():
print('Not too much Nan Values per year. So no Hydrological Year have been deleted from datasets \n')
......@@ -125,4 +128,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
\ No newline at end of file
return df_obs, Hydro_Year_Information, Hydro_Year_to_Delete
\ 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