Commit 056e2081 authored by Laura LINDEPERG's avatar Laura LINDEPERG
Browse files

Add watershed object backup with pickle module

parent 0ef1a7f9
......@@ -9,7 +9,7 @@ import geopandas as gpd
import pandas as pd
import seaborn as sns
from Watershed import Watershed
import pickle
computer = 'Laura'
......@@ -43,8 +43,10 @@ shp_watersheds = gpd.read_file(shp_watersheds_path)
# List of the stations'codes
watershed_code = shp_watersheds.loc[:,'Code']
# Get a sample of them for test
code_for_test = watershed_code.loc[0:2]
# code_for_test = watershed_code.loc[0:2]
# code_for_test = ['V1015810']
code_for_test = ['V2814020', 'V5045020', 'H4033010', 'S4214010']
# code_for_test = ['E6456510', 'A7642010']
# *************************** Extract watersheds' properties ************************************
......@@ -74,13 +76,23 @@ for i in code_for_test:
watershed_dict = watershed_i.to_dict()
# problematic_watersheds = problematic_watersheds.append(watershed_dict, ignore_index=True)
studied_watersheds = studied_watersheds.append(watershed_dict, ignore_index=True)
# save object using pickle
filename_i = 'C:/Users/laura.lindeperg/Documents/INRAE_2021/CODE/fhysa/Object_watershed/watershed_'+i
outfile_i = open(filename_i, 'wb')
pickle.dump(watershed_i, outfile_i)
outfile_i.close()
# And save it
# studied_watersheds.to_csv('613_stations_hydrosig_df.csv', index=False)
## Open stored watershed objects
# i = code_for_test[0]
# filename_i = 'watershed_'+i
# infile_i = open(filename_i, 'rb')
# my_watershed = pickle.load(infile_i)
# infile_i.close()
# df_v0 = pd.read_csv('4_stations_df_v0.csv')
......
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