# Process each dam # 10% exceedence, daily data #================================================# #=== Loop over each dam ===# for i in range(len(df_dam_info)): #=== Get dam info ===# lat = df_dam_info.ix[i, 'grid_lat'] lon = df_dam_info.ix[i, 'grid_lon'] dam_number = df_dam_info.ix[i, 'dam_number'] dam_name = df_dam_info.ix[i, 'dam_name'] print 'Processing dam {}...'.format(dam_number) #=== Extract RVIC flow for this dam location ===# s_rvic = da_rvic_to_consider.loc[:,lat,lon].to_series() #=== Determine max allowed flow ===# max_flow = my_functions.determine_max_flow_dam(s_rvic, cfg['OPTION']['exceedence']) #=== Save results in df ===# df_dam_info.ix[i,'max_flow_cfs'] = max_flow #================================================# # Save new dam info to file #================================================# df_dam_info['max_flow_cfs'] = df_dam_info['max_flow_cfs'].map(lambda x: '%.1f' % x) df_dam_info.to_csv(cfg['OUTPUT']['output_dam_info_new_path'], index=False)
else: TVA_path = os.path.join(TVA_daily_dir, "{}_{}.daily.1903_2013".format(lat, lon)) if os.path.isfile(TVA_path) == True: # if has TVA data flag = "TVA" s_TVA = my_functions.read_Lohmann_route_daily_output( os.path.join(TVA_daily_dir, "{}_{}.daily.1903_2013".format(lat, lon)) ) s = s_TVA # [cfs] # === Extract time after reservoir starts operating ===# s = s.truncate(before=dt.datetime(year_operated, 1, 1)) if len(s) == 0: # if no overlaping time flag = -1 # === If there is USGS or TVA data extracted, determine max allowed flow ===# if flag != -1: max_flow = my_functions.determine_max_flow_dam(s, exceedence) # === Save results in df ===# if flag != -1: df_dam_info.ix[i, "max_flow_cfs"] = max_flow else: print "Warning: dam {} does not have either USGS or TVA data!".format(dam_number) # ================================================# # Estimate max flow for dams without data # ================================================# print "Estimating max flow for dams without data..." # === Dam 16 - proportional to dam 11 based on drainage area ===# max_flow_dam11 = df_dam_info[df_dam_info["dam_number"] == 11]["max_flow_cfs"].values[0] max_flow_dam16 = max_flow_dam11 / 1571.0 * 2627.0 # areal proportional
#=== If doesn't have USGS data, but has TVA data ===# else: TVA_path = os.path.join(cfg['INPUT']['TVA_daily_dir'], '{}_{}.daily.1903_2013'.format(lat, lon)) if os.path.isfile(TVA_path)==True: # if has TVA data flag = 'TVA' s_TVA = my_functions.read_Lohmann_route_daily_output(\ os.path.join(cfg['INPUT']['TVA_daily_dir'], '{}_{}.daily.1903_2013'.format(lat, lon))) s = s_TVA # [cfs] #=== Extract time after reservoir starts operating ===# s = s.truncate(before=dt.datetime(year_operated,1,1)) if len(s)==0: # if no overlaping time flag = -1 #=== If there is USGS or TVA data extracted, determine max allowed flow ===# if flag!=-1: max_flow = my_functions.determine_max_flow_dam(s, cfg['OPTION']['exceedence']) #=== Save results in df ===# if flag!=-1: df_dam_info.ix[i,'max_flow_cfs'] = max_flow else: print 'Warning: dam {} does not have either USGS or TVA data!'.format(dam_number) #================================================# # Estimate max flow for dams without data #================================================# print 'Estimating max flow for dams without data...' #=== Dam 16 - proportional to dam 11 based on drainage area ===# max_flow_dam11 = df_dam_info[df_dam_info['dam_number']==11]['max_flow_cfs'].values[0] max_flow_dam16 = max_flow_dam11 / 1571.0 * 2627.0 # areal proportional
else: TVA_path = os.path.join(cfg['INPUT']['TVA_daily_dir'], '{}_{}.daily.1903_2013'.format(lat, lon)) if os.path.isfile(TVA_path) == True: # if has TVA data flag = 'TVA' s_TVA = my_functions.read_Lohmann_route_daily_output(\ os.path.join(cfg['INPUT']['TVA_daily_dir'], '{}_{}.daily.1903_2013'.format(lat, lon))) s = s_TVA # [cfs] #=== Extract time after reservoir starts operating ===# s = s.truncate(before=dt.datetime(year_operated, 1, 1)) if len(s) == 0: # if no overlaping time flag = -1 #=== If there is USGS or TVA data extracted, determine max allowed flow ===# if flag != -1: max_flow = my_functions.determine_max_flow_dam( s, cfg['OPTION']['exceedence']) #=== Save results in df ===# if flag != -1: df_dam_info.ix[i, 'max_flow_cfs'] = max_flow else: print 'Warning: dam {} does not have either USGS or TVA data!'.format( dam_number) #================================================# # Estimate max flow for dams without data #================================================# print 'Estimating max flow for dams without data...' #=== Dam 16 - proportional to dam 11 based on drainage area ===# max_flow_dam11 = df_dam_info[df_dam_info['dam_number'] ==
#=== If doesn't have USGS data, but has TVA data ===# else: TVA_path = os.path.join(TVA_daily_dir, '{}_{}.daily.1903_2013'.format(lat, lon)) if os.path.isfile(TVA_path)==True: # if has TVA data flag = 'TVA' s_TVA = my_functions.read_Lohmann_route_daily_output(\ os.path.join(TVA_daily_dir, '{}_{}.daily.1903_2013'.format(lat, lon))) s = s_TVA # [cfs] #=== Extract time after reservoir starts operating ===# s = s.truncate(before=dt.datetime(year_operated,1,1)) if len(s)==0: # if no overlaping time flag = -1 #=== If there is USGS or TVA data extracted, determine max allowed flow ===# if flag!=-1: max_flow = my_functions.determine_max_flow_dam(s, exceedence) #=== Save results in df ===# if flag!=-1: df_dam_info.ix[i,'max_flow_cfs'] = max_flow else: print 'Warning: dam {} does not have either USGS or TVA data!'.format(dam_number) #================================================# # Estimate max flow for dams without data #================================================# print 'Estimating max flow for dams without data...' #=== Dam 16 - proportional to dam 11 based on drainage area ===# max_flow_dam11 = df_dam_info[df_dam_info['dam_number']==11]['max_flow_cfs'].values[0] max_flow_dam16 = max_flow_dam11 / 1571.0 * 2627.0 # areal proportional