|
|
|
@ -48,21 +48,25 @@ for Est in Estuaries:
|
|
|
|
|
Base_period_start = '1970-01-01' #Start of interval for base period of climate variability
|
|
|
|
|
Base_period_DELTA_start = '1990-01-01' #Start of interval used for calculating mean and SD for base period (Delta base period)
|
|
|
|
|
Base_period_end = '2009-01-01' #use last day that's not included in period as < is used for subsetting
|
|
|
|
|
Clim_var_type = 'tasmean' #Name of climate variable in NARCLIM models '*' will create pdf for all variables in folder
|
|
|
|
|
Clim_var_type = 'pracc' #Name of climate variable in NARCLIM models '*' will create pdf for all variables in folder
|
|
|
|
|
Stats = 'maxdaily' #'maxdaily' #maximum takes the annual max Precipitation instead of the sum
|
|
|
|
|
|
|
|
|
|
PD_Datasource = 'SILO' #Source for present day climate data (historic time series) can be either: 'Station' or 'SILO'
|
|
|
|
|
SILO_Clim_var = ['max_temp'] #select the SILO clim variable to be used for base period. - see silo.py for detailed descriptions
|
|
|
|
|
SILO_Clim_var = ['daily_rain'] #select the SILO clim variable to be used for base period. - see silo.py for detailed descriptions
|
|
|
|
|
Location = 'Estuary' # pick locaiton for extracting the SILO data can be: Estuary, Catchment, or Ocean
|
|
|
|
|
|
|
|
|
|
presentdaybar = False #include a bar for present day variability in the plots?
|
|
|
|
|
present_day_plot = 'no' #save a time series of present day
|
|
|
|
|
Version = "V1"
|
|
|
|
|
Stats = 'mean' #'maxdaily' #maximum takes the annual max Precipitation instead of the sum
|
|
|
|
|
present_day_plot = 'yes' #save a time series of present day
|
|
|
|
|
Allin1_delta_plot = 'no'
|
|
|
|
|
Version = "V4"
|
|
|
|
|
ALPHA_figs = 0 #Set alpha of figure background (0 makes everything around the plot panel transparent)
|
|
|
|
|
font = {'family' : 'sans-serif',
|
|
|
|
|
'weight' : 'normal',
|
|
|
|
|
'size' : 14}
|
|
|
|
|
matplotlib.rc('font', **font) #size of axis labels
|
|
|
|
|
#==========================================================#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#==========================================================#
|
|
|
|
|
#set directory path for output files
|
|
|
|
|
output_directory = 'Output/' + Case_Study_Name + '/' + Estuary + '/' + '/Clim_Deviation_Plots/'
|
|
|
|
@ -190,6 +194,8 @@ for Est in Estuaries:
|
|
|
|
|
times = ['annual', 'DJF', 'MAM', 'JJA','SON']
|
|
|
|
|
fig = plt.figure(figsize=(14,8))
|
|
|
|
|
delta_all_df = pd.DataFrame()
|
|
|
|
|
Combined_Delta_df = pd.DataFrame()
|
|
|
|
|
Combined_Med_df = pd.DataFrame()
|
|
|
|
|
i=1
|
|
|
|
|
for temp in times:
|
|
|
|
|
#temp = 'annual'
|
|
|
|
@ -197,20 +203,22 @@ for Est in Estuaries:
|
|
|
|
|
if temp == 'annual':
|
|
|
|
|
Ensemble_Delta_df = Ensemble_Delta_full_df.iloc[:,range(0,2)]
|
|
|
|
|
Present_Day_ref_df = Present_day_df_annual
|
|
|
|
|
Column_names = ['near', 'far']
|
|
|
|
|
else:
|
|
|
|
|
Ensemble_Delta_df = Ensemble_Delta_full_df.filter(regex= temp)
|
|
|
|
|
Ensemble_Delta_df.columns = ['near', 'far']
|
|
|
|
|
if temp == 'DJF':
|
|
|
|
|
Mean_df = Fdf_Seas_means[Fdf_Seas_means.index.quarter==1]
|
|
|
|
|
Column_names = ['DJF_near', 'DJF_far']
|
|
|
|
|
Column_names = ['DJF_near', 'DJF_far']
|
|
|
|
|
if temp == 'MAM':
|
|
|
|
|
Mean_df = Fdf_Seas_means[Fdf_Seas_means.index.quarter==2]
|
|
|
|
|
Column_names = ['MAM_near', 'MAM_far']
|
|
|
|
|
Column_names = ['MAM_near', 'MAM_far']
|
|
|
|
|
if temp == 'JJA':
|
|
|
|
|
Mean_df = Fdf_Seas_means[Fdf_Seas_means.index.quarter==3]
|
|
|
|
|
Column_names = ['JJA_near', 'JJA_far']
|
|
|
|
|
Column_names = ['JJA_near', 'JJA_far']
|
|
|
|
|
if temp == 'SON':
|
|
|
|
|
Mean_df = Fdf_Seas_means[Fdf_Seas_means.index.quarter==4]
|
|
|
|
|
Column_names = ['SON_near', 'SON_far']
|
|
|
|
|
Present_Day_ref_df = Mean_df
|
|
|
|
|
#Subset to present day variability period
|
|
|
|
|
Present_Day_ref_df = pd.DataFrame(Present_Day_ref_df.loc[(Present_Day_ref_df.index >= Base_period_start) & (Present_Day_ref_df.index <= Base_period_end)])
|
|
|
|
@ -290,7 +298,7 @@ for Est in Estuaries:
|
|
|
|
|
tick.set_rotation(0)
|
|
|
|
|
fig.tight_layout()
|
|
|
|
|
fig.patch.set_alpha(ALPHA_figs)
|
|
|
|
|
plt.set_facecolor('g')
|
|
|
|
|
#plt.set_facecolor('g')
|
|
|
|
|
|
|
|
|
|
if temp == 'annual':
|
|
|
|
|
ax=plt.subplot(2,2,1)
|
|
|
|
@ -315,15 +323,47 @@ for Est in Estuaries:
|
|
|
|
|
i=i+4
|
|
|
|
|
else:
|
|
|
|
|
i=i+1
|
|
|
|
|
#create a data frame that contains all of the delta bars
|
|
|
|
|
Plot_in_df_tp.index = Column_names
|
|
|
|
|
Plot_in_df_tp['-2std'] = Plot_in_df_tp['-2std'] - Present_Day_Mean
|
|
|
|
|
Combined_Delta_df = pd.concat([Combined_Delta_df, Plot_in_df_tp], axis=0)
|
|
|
|
|
|
|
|
|
|
#plt.show()
|
|
|
|
|
if presentdaybar == False:
|
|
|
|
|
out_file_name = Estuary + '_' + Clim_var_type + '_' + Stats + '_' + PD_Datasource + '_' + SILO_Clim_var[0] + Version + '_' + '_NPDB.png'
|
|
|
|
|
out_file_name = Estuary + '_' + Clim_var_type + '_' + Stats + '_' + PD_Datasource + '_' + SILO_Clim_var[0] + '_' + Version + '_' + '_NPDB.png'
|
|
|
|
|
else:
|
|
|
|
|
out_file_name = Estuary + '_' + Clim_var_type + '_' + Stats + '_' + PD_Datasource + '_' + SILO_Clim_var[0] + Version + '_' + '2.png'
|
|
|
|
|
out_file_name = Estuary + '_' + Clim_var_type + '_' + Stats + '_' + PD_Datasource + '_' + SILO_Clim_var[0] + '_' + Version + '_' + '2.png'
|
|
|
|
|
out_path = output_directory + '/' + out_file_name
|
|
|
|
|
fig.savefig(out_path)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if Allin1_delta_plot == 'yes':
|
|
|
|
|
fig = plt.figure(figsize=(14,8))
|
|
|
|
|
ax = fig.add_subplot(2, 2, 1)
|
|
|
|
|
Plot_in_df_tp = pd.DataFrame(Combined_Delta_df)
|
|
|
|
|
Bottom = int(Plot_in_df_tp.stack().min(axis=None,skipna=True)) - 1
|
|
|
|
|
Plot_in_df_tp = Plot_in_df_tp - Bottom
|
|
|
|
|
Plot_in_df = Plot_in_df_tp.transpose()
|
|
|
|
|
uni_colors = ['none', 'cornflowerblue', 'cornflowerblue','cornflowerblue','cornflowerblue']
|
|
|
|
|
Plot_in_df_tp.plot.bar(stacked=True, color=uni_colors, edgecolor='none', legend=False, width=0.5,ax=ax, bottom=Bottom)
|
|
|
|
|
plt.plot(Plot_in_df_tp['Med'], linestyle="", markersize=23,
|
|
|
|
|
marker="_", color='darkblue', label="Median")
|
|
|
|
|
z = plt.axhline(float(0), linestyle='--', color='red', alpha=.5)
|
|
|
|
|
z.set_zorder(-1)
|
|
|
|
|
#plt.ylim(xmin, xmax)
|
|
|
|
|
plt.title(Clim_var_type + ' All Delstas ' + Stats)
|
|
|
|
|
ax.grid(False)
|
|
|
|
|
for tick in ax.get_xticklabels():
|
|
|
|
|
tick.set_rotation(90)
|
|
|
|
|
fig.tight_layout()
|
|
|
|
|
fig.patch.set_alpha(ALPHA_figs)
|
|
|
|
|
#plt.show()
|
|
|
|
|
#export plot to png
|
|
|
|
|
out_file_name = Estuary + '_' + Clim_var_type + '_' + Stats + '_' + Base_period_start + '_' + Base_period_end + '_' + Version + '_All_Deltas_In1.png'
|
|
|
|
|
out_path = output_directory + '/' + out_file_name
|
|
|
|
|
fig.savefig(out_path)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if present_day_plot == 'yes':
|
|
|
|
|
#print present day climate data
|
|
|
|
|
fig = plt.figure(figsize=(5,4))
|
|
|
|
@ -350,7 +390,7 @@ for Est in Estuaries:
|
|
|
|
|
fig.patch.set_alpha(0)
|
|
|
|
|
plt.ylim(13, xmax)
|
|
|
|
|
#export plot to png
|
|
|
|
|
out_file_name = Estuary + '_' + Clim_var_type + '_' + Stats + '_' + Base_period_start + '_' + Base_period_end + Version + 'Present_Day_Period.png'
|
|
|
|
|
out_file_name = Estuary + '_' + Clim_var_type + '_' + Stats + '_' + Base_period_start + '_' + Base_period_end + '_' + Version + 'Present_Day_Period.png'
|
|
|
|
|
out_path = output_directory + '/' + out_file_name
|
|
|
|
|
fig.savefig(out_path)
|
|
|
|
|
# use transparent=True if you want the whole figure with a transparent background
|
|
|
|
|