From 85dc3b9b5cf837b43bccd7b7c34dadf63cd7c3b6 Mon Sep 17 00:00:00 2001
From: "jean.marcais" <jean.marcais@irstea.fr>
Date: Wed, 24 Mar 2021 10:23:30 +0100
Subject: [PATCH] modify netcdf extraction in for loop

---
 extract_HydroSig.py | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/extract_HydroSig.py b/extract_HydroSig.py
index 57829d1..78a2ae4 100644
--- a/extract_HydroSig.py
+++ b/extract_HydroSig.py
@@ -39,7 +39,14 @@ watershed_code = df_stations.loc[:,'Code']
 # Get a sample of them for test
 code_for_test = watershed_code.loc[1:10]
 
-
+# extract safran gpd
+from HydroClimaticFluxes import HydroClimaticFluxes
+HCF = HydroClimaticFluxes(code=-1)
+Ptot_gpd = HCF.extract_safran_variable(safran_foldername, 'Ptot')
+ET0_gpd = HCF.extract_safran_variable(safran_foldername, 'ET0')
+Tair_gpd = HCF.extract_safran_variable(safran_foldername, 'Tair')
+Snow_gpd = HCF.extract_safran_variable(safran_foldername, 'Snow')
+Rain_gpd = HCF.extract_safran_variable(safran_foldername, 'Rain')
 
 # *************************** Extract watersheds' properties ************************************
 
@@ -57,7 +64,11 @@ for i in code_for_test:
     watershed_i.extract_watershed_contour_from_filename(shp_contour_filepath, 'Code')
     watershed_i.extract_banquehydro_discharge_timeseries(banquehydro_foldername)
     # watershed_i.extract_SAFRAN_forcings(safran_foldername, safran_grid_shpfilename)
-    watershed_i.extract_SAFRAN_forcings(safran_foldername)
+    watershed_i.hydro_climatic_fluxes.intersect_safran_gpd_and_contour(Ptot_gpd, watershed_i.contour,'Ptot')
+    watershed_i.hydro_climatic_fluxes.intersect_safran_gpd_and_contour(ET0_gpd, watershed_i.contour, 'ET0')
+    watershed_i.hydro_climatic_fluxes.intersect_safran_gpd_and_contour(Tair_gpd, watershed_i.contour, 'Tair')
+    watershed_i.hydro_climatic_fluxes.intersect_safran_gpd_and_contour(Snow_gpd, watershed_i.contour, 'Snow')
+    watershed_i.hydro_climatic_fluxes.intersect_safran_gpd_and_contour(Rain_gpd, watershed_i.contour, 'Rain')
     watershed_i.extract_hydrological_signatures()
     watershed_i.extract_geologic_properties_from_filename(BDLisa_shp)
     watershed_i.geologic_properties.extract_average_age_geology(BRGM_geol_map, watershed_i.contour)
-- 
GitLab