#incorporated the option for a stats type such as daily max per year or season

#also fixed a bug with the server script
Development1
tinoheimhuber 7 years ago
parent d907d640f8
commit adad360de9

@ -30,10 +30,11 @@ Base_period_start = '1986-01-01'
Base_period_end = '2005-01-01' #use last day that's not included in period as < is used for subsetting
Estuary = 'Nadgee' # 'Belongil'
Clim_var_type = "*" # '*' will create pdf for all variables in folder
Clim_var_type = "tasmean*" # '*' will create pdf for all variables in folder
Present_Day_Clim_Var = 'Wind' #MaxT, MinT, Rainfall, ET
Clim_var_type = "pracc*" # '*' will create pdf for all variables in folder
Present_Day_Clim_Var = 'Rainfall' #MaxT, MinT, Rainfall, ET Wind
present_day_plot = 'yes'
Version = "V1"
Version = "V2"
Stats = 'dailymax' #maximum takes the annual max Precipitation instead of the sum
#####################################----------------------------------
#set directory path for output files
@ -45,7 +46,7 @@ if not os.path.exists(output_directory):
print("output directory folder didn't exist and was generated")
print('-------------------------------------------')
print('-------------------')
Clim_Var_CSVs = glob.glob('./Output/' + Estuary + '/' + Estuary + '_' + Clim_var_type + '*')
Clim_Var_CSVs = glob.glob('./Output/' + Estuary + '/' + Estuary + '_' + Clim_var_type[:-1] + '_' + Stats + '*')
#read CSV file
clim_var_csv_path = Clim_Var_CSVs[0]
Filename = os.path.basename(os.path.normpath(clim_var_csv_path))
@ -99,14 +100,14 @@ else:
#create seasonal sums etc.
if (Clim_var_type == 'pracc' or Clim_var_type == 'evspsblmean' or Clim_var_type == 'potevpmean'
or Clim_var_type == 'pr1Hmaxtstep' or Clim_var_type == 'wss1Hmaxtstep'):
Present_day_df_annual = Present_day_df.resample('A').sum()
Present_day_df_annual = Present_day_df_annual.replace(0, np.nan)
Present_day_df_monthly = Present_day_df.resample('M').sum()
Present_day_df_monthly = Present_day_df_monthly.replace(0, np.nan)
Present_day_df_weekly = Present_day_df.resample('W').sum()
Present_day_df_weekly = Present_day_df_weekly.replace(0, np.nan)
Fdf_Seas_means = Present_day_df.resample('Q-NOV').sum() #seasonal means
Fdf_Seas_means = Fdf_Seas_means.replace(0, np.nan)
if Stats == 'dailymax':
Present_day_df_annual = Present_day_df.resample('A').max()
Present_day_df_annual = Present_day_df_annual.replace(0, np.nan)
else:
Present_day_df_annual = Present_day_df.resample('A').sum()
Present_day_df_annual = Present_day_df_annual.replace(0, np.nan)
Fdf_Seas_means = Present_day_df.resample('Q-NOV').sum() #seasonal means
Fdf_Seas_means = Fdf_Seas_means.replace(0, np.nan)
else:
Present_day_df_annual = Present_day_df.resample('A').mean()
Present_day_df_monthly = Present_day_df.resample('M').mean()
@ -205,7 +206,7 @@ for temp in times:
print(i)
plt.show()
out_file_name = Estuary + '_' + Clim_var_type + '_CC_prio_plot' + Version + '.png'
out_file_name = Estuary + '_' + Clim_var_type + '_' + Stats + '_' + '_CC_prio_plot' + Version + '.png'
out_path = output_directory + '/' + out_file_name
fig.savefig(out_path)

@ -77,7 +77,7 @@ for NC_Period in NC_Periods:
print f.variables
print
for varname in f.variables:
print varname,' -> ',shape(f.variables[varname])
print varname,' -> ',np.shape(f.variables[varname])
print '---------------------------------------------------------'
# Based on the desired inputs, this finds the nearest grid centerpoint index (x,y) in the *.nc file
dist_x=np.abs(f.variables['lon'][:,:]-float(mylon))

@ -27,9 +27,10 @@ os.chdir('C:/Users/z5025317/OneDrive - UNSW/WRL_Postdoc_Manual_Backup/WRL_Postdo
Base_period_start = '1990-01-01'
Base_period_end = '2080-01-01' #use last day that's not included in period as < is used for subsetting
Estuary = 'Nadgee' # 'Belongil'
Clim_var_type = "tasmean*" # '*' will create pdf for all variables in folder "pracc*|tasmax*"
Clim_var_type = "pracc*" # '*' will create pdf for all variables in folder "pracc*|tasmax*"
plot_pdf = 'yes'
delta_csv = 'no'
delta_csv = 'yes'
Stats = 'dailymax'
#####################################----------------------------------
#
#set directory path for output files
@ -69,14 +70,24 @@ for clim_var_csv_path in Clim_Var_CSVs:
#Aggregate daily df to annual time series
if (Clim_var_type == 'pracc' or Clim_var_type == 'evspsblmean' or Clim_var_type == 'potevpmean'
or Clim_var_type == 'pr1Hmaxtstep' or Clim_var_type == 'wss1Hmaxtstep'):
Fdf_1900_2080_annual = Fdf_1900_2080.resample('A').sum()
Fdf_1900_2080_annual = Fdf_1900_2080_annual.replace(0, np.nan)
Fdf_1900_2080_monthly = Fdf_1900_2080.resample('M').sum()
Fdf_1900_2080_monthly = Fdf_1900_2080_monthly.replace(0, np.nan)
Fdf_1900_2080_weekly = Fdf_1900_2080.resample('W').sum()
Fdf_1900_2080_weekly = Fdf_1900_2080_weekly.replace(0, np.nan)
Fdf_Seas_means = Fdf_1900_2080.resample('Q-NOV').sum() #seasonal means
Fdf_Seas_means = Fdf_Seas_means.replace(0, np.nan)
if(Stats == 'maxdaily'):
Fdf_1900_2080_annual = Fdf_1900_2080.resample('A').max()
Fdf_1900_2080_annual = Fdf_1900_2080_annual.replace(0, np.nan)
Fdf_1900_2080_monthly = Fdf_1900_2080.resample('M').max()
Fdf_1900_2080_monthly = Fdf_1900_2080_monthly.replace(0, np.nan)
Fdf_1900_2080_weekly = Fdf_1900_2080.resample('W').max()
Fdf_1900_2080_weekly = Fdf_1900_2080_weekly.replace(0, np.nan)
Fdf_Seas_means = Fdf_1900_2080.resample('Q-NOV').max() #seasonal means
Fdf_Seas_means = Fdf_Seas_means.replace(0, np.nan)
else:
Fdf_1900_2080_annual = Fdf_1900_2080.resample('A').sum()
Fdf_1900_2080_annual = Fdf_1900_2080_annual.replace(0, np.nan)
Fdf_1900_2080_monthly = Fdf_1900_2080.resample('M').sum()
Fdf_1900_2080_monthly = Fdf_1900_2080_monthly.replace(0, np.nan)
Fdf_1900_2080_weekly = Fdf_1900_2080.resample('W').sum()
Fdf_1900_2080_weekly = Fdf_1900_2080_weekly.replace(0, np.nan)
Fdf_Seas_means = Fdf_1900_2080.resample('Q-NOV').sum() #seasonal means
Fdf_Seas_means = Fdf_Seas_means.replace(0, np.nan)
else:
Fdf_1900_2080_annual = Fdf_1900_2080.resample('A').mean()
Fdf_1900_2080_monthly = Fdf_1900_2080.resample('M').mean()
@ -183,7 +194,7 @@ for clim_var_csv_path in Clim_Var_CSVs:
delta_all_df = pd.concat([delta_all_df, delta_df], axis=1)
if delta_csv == 'yes':
out_file_name = Estuary + '_' + Clim_var_type + '_NARCliM_ensemble_changes.csv'
out_file_name = Estuary + '_' + Clim_var_type + '_' + Stats + '_NARCliM_ensemble_changes.csv'
out_path = output_directory + '/' + out_file_name
delta_all_df.to_csv(out_path)
@ -214,7 +225,7 @@ for clim_var_csv_path in Clim_Var_CSVs:
#plt.cm.Paired(np.arange(len(Fdf_1900_2080_means)))
#write the key plots to a single pdf document
pdf_out_file_name = Clim_var_type + '_start_' + Base_period_start + '_NARCliM_summary_9.pdf'
pdf_out_file_name = Clim_var_type + '_start_' + Base_period_start + '_NARCliM_summary_10.pdf'
pdf_out_path = output_directory +'/' + pdf_out_file_name
#open pdf and add the plots
with PdfPages(pdf_out_path) as pdf:

Loading…
Cancel
Save