|
|
|
@ -49,21 +49,24 @@ for Est in Estuaries:
|
|
|
|
|
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 = '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
|
|
|
|
|
Stats = 'days_h_30' #'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 = ['daily_rain'] #select the SILO clim variable to be used for base period. - see silo.py for detailed descriptions
|
|
|
|
|
PD_Datasource = 'Station' #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
|
|
|
|
|
Location = 'Estuary' # pick locaiton for extracting the SILO data can be: Estuary, Catchment, or Ocean
|
|
|
|
|
|
|
|
|
|
Main_Plot = 'yes'
|
|
|
|
|
presentdaybar = False #include a bar for present day variability in the plots?
|
|
|
|
|
present_day_plot = 'yes' #save a time series of present day
|
|
|
|
|
Allin1_delta_plot = 'no'
|
|
|
|
|
Version = "V4"
|
|
|
|
|
present_day_plot = 'no' #save a time series of present day
|
|
|
|
|
Allin1_delta_plot = 'yes'
|
|
|
|
|
Median_markers = 'no' #plot the median horizontal lines on top of the delta range in the allin1 plot?
|
|
|
|
|
Figure_headings = 'no'
|
|
|
|
|
Version = "V1"
|
|
|
|
|
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
|
|
|
|
|
'size' : 14} #size of axis labels
|
|
|
|
|
matplotlib.rc('font', **font)
|
|
|
|
|
#==========================================================#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -144,6 +147,8 @@ for Est in Estuaries:
|
|
|
|
|
#for tasmean, observed min and max T need to be converted into mean T
|
|
|
|
|
elif Clim_var_type == 'tasmean':
|
|
|
|
|
[minplotDelta, maxplotDelta]=[0.2,1]
|
|
|
|
|
elif Clim_var_type == 'sstmean':
|
|
|
|
|
[minplotDelta, maxplotDelta]=[40,40]
|
|
|
|
|
elif Clim_var_type == 'tasmax':
|
|
|
|
|
[minplotDelta, maxplotDelta]=[1,2]
|
|
|
|
|
elif Clim_var_type == 'wssmean' or Clim_var_type == 'wss1Hmaxtstep':
|
|
|
|
@ -203,22 +208,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']
|
|
|
|
|
Column_names = ['Annual_near', 'Annual_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 = ['Summer_near', 'Summer_far']
|
|
|
|
|
if temp == 'MAM':
|
|
|
|
|
Mean_df = Fdf_Seas_means[Fdf_Seas_means.index.quarter==2]
|
|
|
|
|
Column_names = ['MAM_near', 'MAM_far']
|
|
|
|
|
Column_names = ['Autumn_near', 'Autumn_far']
|
|
|
|
|
if temp == 'JJA':
|
|
|
|
|
Mean_df = Fdf_Seas_means[Fdf_Seas_means.index.quarter==3]
|
|
|
|
|
Column_names = ['JJA_near', 'JJA_far']
|
|
|
|
|
Column_names = ['Winter_near', 'Winter_far']
|
|
|
|
|
if temp == 'SON':
|
|
|
|
|
Mean_df = Fdf_Seas_means[Fdf_Seas_means.index.quarter==4]
|
|
|
|
|
Column_names = ['SON_near', 'SON_far']
|
|
|
|
|
Column_names = ['Spring_near', 'Spring_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)])
|
|
|
|
@ -279,7 +284,7 @@ for Est in Estuaries:
|
|
|
|
|
Plot_in_df3['near future'] = df.iloc[1,0]
|
|
|
|
|
Plot_in_df3['far future'] = df.iloc[0,0]
|
|
|
|
|
Plot_in_df3 = Plot_in_df3.transpose()
|
|
|
|
|
plt.plot(Plot_in_df3['Med'], linestyle="", markersize=52,
|
|
|
|
|
plt.plot(Plot_in_df3['Med'], linestyle="", markersize=45,
|
|
|
|
|
marker="_", color='darkblue', label="Median")
|
|
|
|
|
z = plt.axhline(float(Present_Day_Mean-2*Present_Day_SD), linestyle='-', color='black', alpha=.5)
|
|
|
|
|
z.set_zorder(-1)
|
|
|
|
@ -291,7 +296,9 @@ for Est in Estuaries:
|
|
|
|
|
z.set_zorder(-1)
|
|
|
|
|
z = plt.axhline(float(Present_Day_Mean), linestyle='--', color='red', alpha=.5)
|
|
|
|
|
z.set_zorder(-1)
|
|
|
|
|
plt.ylim(xmin, xmax)
|
|
|
|
|
#plt.ylim(xmin, xmax)
|
|
|
|
|
plt.ylim(10, 140)
|
|
|
|
|
if Figure_headings == 'yes':
|
|
|
|
|
plt.title(Clim_var_type + ' ' + temp )
|
|
|
|
|
ax.grid(False)
|
|
|
|
|
for tick in ax.get_xticklabels():
|
|
|
|
@ -314,10 +321,12 @@ for Est in Estuaries:
|
|
|
|
|
z = plt.axhline(float(Present_Day_Mean), linestyle='--', color='red', alpha=.5)
|
|
|
|
|
z.set_zorder(-1)
|
|
|
|
|
#fig.patch.set_facecolor('deepskyblue')
|
|
|
|
|
plt.ylim(0, 40)
|
|
|
|
|
fig.tight_layout()
|
|
|
|
|
fig.patch.set_alpha(ALPHA_figs)
|
|
|
|
|
if Figure_headings == 'yes':
|
|
|
|
|
plt.title(Clim_var_type + ' ' + Stats + ' ' + temp +' present day')
|
|
|
|
|
plt.ylim(xmin, xmax)
|
|
|
|
|
#plt.ylim(xmin, xmax)
|
|
|
|
|
ax.grid(False)
|
|
|
|
|
#if temp == 'MAM':
|
|
|
|
|
i=i+4
|
|
|
|
@ -327,54 +336,107 @@ for Est in Estuaries:
|
|
|
|
|
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)
|
|
|
|
|
if Allin1_delta_plot == 'yes':
|
|
|
|
|
ax=plt.subplot(2,4,4)
|
|
|
|
|
temp = Combined_Delta_df[0:2]
|
|
|
|
|
Plot_in_df_tp = temp
|
|
|
|
|
uni_colors = ['none', 'cornflowerblue', 'cornflowerblue','cornflowerblue','cornflowerblue']
|
|
|
|
|
Plot_in_df_tp['Median'] = pd.DataFrame(Plot_in_df_tp['-2std'] + Plot_in_df_tp['Med'])
|
|
|
|
|
if int(Plot_in_df_tp.stack().min(axis=None,skipna=True)) < 0:
|
|
|
|
|
Bottom = int(Plot_in_df_tp.stack().min(axis=None,skipna=True)) -1
|
|
|
|
|
Plot_in_df_tp['-2std'] = Plot_in_df_tp['-2std'] - Bottom
|
|
|
|
|
Plot_in_df_tp.plot.bar(stacked=True, color=uni_colors, edgecolor='none', legend=False, width=0.5,ax=ax, bottom = Bottom)
|
|
|
|
|
else:
|
|
|
|
|
Plot_in_df_tp.plot.bar(stacked=True, color=uni_colors, edgecolor='none', legend=False, width=0.5,ax=ax)
|
|
|
|
|
if Median_markers == 'yes':
|
|
|
|
|
plt.plot(Plot_in_df_tp.index, Plot_in_df_tp['Median'], linestyle="", markersize=13,
|
|
|
|
|
marker="_", color='darkblue', label="Median")
|
|
|
|
|
z = plt.axhline(float(0), linestyle='--', color='red', alpha=.5)
|
|
|
|
|
z.set_zorder(-1)
|
|
|
|
|
plt.ylim(-1, 20)
|
|
|
|
|
if Figure_headings == 'yes':
|
|
|
|
|
plt.title(Clim_var_type + ' All Deltas ' + Stats)
|
|
|
|
|
#ax.grid(False)
|
|
|
|
|
ax.xaxis.grid(False)
|
|
|
|
|
for tick in ax.get_xticklabels():
|
|
|
|
|
tick.set_rotation(10)
|
|
|
|
|
fig.tight_layout()
|
|
|
|
|
fig.patch.set_alpha(ALPHA_figs)
|
|
|
|
|
|
|
|
|
|
#plt.show()
|
|
|
|
|
if Main_Plot == 'yes':
|
|
|
|
|
if presentdaybar == False:
|
|
|
|
|
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_path = output_directory + '/' + out_file_name
|
|
|
|
|
fig.savefig(out_path)
|
|
|
|
|
|
|
|
|
|
plt.close(fig)
|
|
|
|
|
|
|
|
|
|
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()
|
|
|
|
|
ax = fig.add_subplot(2, 3, 1)
|
|
|
|
|
temp = Combined_Delta_df
|
|
|
|
|
Plot_in_df_tp = temp
|
|
|
|
|
uni_colors = ['none', 'cornflowerblue', 'cornflowerblue','cornflowerblue','cornflowerblue']
|
|
|
|
|
Plot_in_df_tp['Median'] = pd.DataFrame(Plot_in_df_tp['-2std'] + Plot_in_df_tp['Med'])
|
|
|
|
|
if int(Plot_in_df_tp.stack().min(axis=None,skipna=True)) < 0:
|
|
|
|
|
Bottom = int(Plot_in_df_tp.stack().min(axis=None,skipna=True)) -1
|
|
|
|
|
Plot_in_df_tp['-2std'] = Plot_in_df_tp['-2std'] - Bottom
|
|
|
|
|
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,
|
|
|
|
|
else:
|
|
|
|
|
Plot_in_df_tp.plot.bar(stacked=True, color=uni_colors, edgecolor='none', legend=False, width=0.5,ax=ax)
|
|
|
|
|
if Median_markers == 'yes':
|
|
|
|
|
plt.plot(Plot_in_df_tp.index, Plot_in_df_tp['Median'], linestyle="", markersize=13,
|
|
|
|
|
marker="_", color='darkblue', label="Median")
|
|
|
|
|
z = plt.axhline(float(0), linestyle='--', color='red', alpha=.5)
|
|
|
|
|
z.set_zorder(-1)
|
|
|
|
|
#plt.ylim(xmin, xmax)
|
|
|
|
|
plt.ylim(-5, 10)
|
|
|
|
|
if Figure_headings == 'yes':
|
|
|
|
|
plt.title(Clim_var_type + ' All Delstas ' + Stats)
|
|
|
|
|
ax.grid(False)
|
|
|
|
|
#ax.grid(False)
|
|
|
|
|
ax.xaxis.grid(False)
|
|
|
|
|
for tick in ax.get_xticklabels():
|
|
|
|
|
tick.set_rotation(90)
|
|
|
|
|
fig.tight_layout()
|
|
|
|
|
fig.patch.set_alpha(ALPHA_figs)
|
|
|
|
|
#plt.show()
|
|
|
|
|
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)
|
|
|
|
|
plt.close(fig)
|
|
|
|
|
|
|
|
|
|
##make barplot with alternating colours
|
|
|
|
|
#men_means, men_std = (20, 35, 30, 35, 27), (2, 3, 4, 1, 2)
|
|
|
|
|
#women_means, women_std = (25, 32, 34, 20, 25), (3, 5, 2, 3, 3)
|
|
|
|
|
#
|
|
|
|
|
#ind = np.arange(len(men_means)) # the x locations for the groups
|
|
|
|
|
#width = 0.35 # the width of the bars
|
|
|
|
|
#
|
|
|
|
|
#fig, ax = plt.subplots()
|
|
|
|
|
#rects1 = ax.bar(ind - width/2, men_means, width, yerr=men_std,
|
|
|
|
|
# color='SkyBlue', label='Men')
|
|
|
|
|
#rects2 = ax.bar(ind + width/2, women_means, width, yerr=women_std,
|
|
|
|
|
# color='IndianRed', label='Women')
|
|
|
|
|
#
|
|
|
|
|
## Add some text for labels, title and custom x-axis tick labels, etc.
|
|
|
|
|
#ax.set_ylabel('Scores')
|
|
|
|
|
#ax.set_title('Scores by group and gender')
|
|
|
|
|
#ax.set_xticks(ind)
|
|
|
|
|
#ax.set_xticklabels(('G1', 'G2', 'G3', 'G4', 'G5'))
|
|
|
|
|
#ax.legend()
|
|
|
|
|
|
|
|
|
|
if present_day_plot == 'yes':
|
|
|
|
|
#print present day climate data
|
|
|
|
|
fig = plt.figure(figsize=(5,4))
|
|
|
|
|
ax = fig.add_subplot(1, 1, 1)
|
|
|
|
|
if temp == 'annual':
|
|
|
|
|
xmin = int(min(Plot_in_df.min(axis=1))-minplotDelta)
|
|
|
|
|
xmax = int(max(Plot_in_df.max(axis=1))+maxplotDelta)
|
|
|
|
|
fig = plt.figure(figsize=(14,8))
|
|
|
|
|
for i1 in range(2):
|
|
|
|
|
if i1 ==0:
|
|
|
|
|
ax = fig.add_subplot(2, 3, 1)
|
|
|
|
|
else:
|
|
|
|
|
ax = fig.add_subplot(2, 1, 2)
|
|
|
|
|
xmin = int(min(Plot_in_df.min(axis=1))-minplotDelta)
|
|
|
|
|
xmax = int(max(Plot_in_df.max(axis=1))+maxplotDelta)
|
|
|
|
|
|
|
|
|
|
Present_Day_ref_df.plot(legend=False, ax=ax)
|
|
|
|
|
z = plt.axhline(float(Present_Day_Mean-2*Present_Day_SD), linestyle='-', color='black', alpha=.5)
|
|
|
|
|
z.set_zorder(-1)
|
|
|
|
@ -388,11 +450,12 @@ for Est in Estuaries:
|
|
|
|
|
z.set_zorder(-1)
|
|
|
|
|
#fig.patch.set_facecolor('deepskyblue')
|
|
|
|
|
fig.patch.set_alpha(0)
|
|
|
|
|
plt.ylim(13, xmax)
|
|
|
|
|
plt.ylim(0, 400)
|
|
|
|
|
#export plot to 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)
|
|
|
|
|
plt.close(fig)
|
|
|
|
|
# use transparent=True if you want the whole figure with a transparent background
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|