import sys, datetime, copy, os from dateutil.relativedelta import relativedelta import numpy as np; np.set_printoptions(threshold=sys.maxsize) import matplotlib; matplotlib.use('Agg') import matplotlib.pyplot as plt import matplotlib.colors as clr from mpl_toolkits.basemap import Basemap import seaborn as sns from matplotlib.colors import ListedColormap from netCDF4 import Dataset nc = Dataset('../NC/FD_Char_1961-2020_1yrs_Daily_Reg_New.nc','r') #../NC/FD_Char_1961-2020_1yrs_Daily_Reg.nc','r') year = nc.variables['year'][:] reg = nc.variables['reg'][:] cha = nc.variables['cha'][:] fd = nc.variables['fd'][:] #regs = ['R1','R2','R3','R4','R5','R6','R7'] var = ["NumFD","Dur","Sev","Spd","RD","Int"] regs = ['B1','B2','B3','B4','N1','N2','N3'] Max_All = [ 7, 85, 2200, 85, 35, 35 ] for i in range(len(cha)): fig, ax = plt.subplots(7,figsize=(6,12)) plt.subplots_adjust(hspace=0.5) a = fd[:,i,:] #amax = round(np.nanmax(a)); amin = round(np.nanmin(a)) amax = Max_All[i]; amin = 0 print (amax) atext = amax * 3/4 yticks = np.linspace(amin,amax,3) for k in range(len(reg)): x = year[:] # day[0:30] y = fd[:,i,k] # sw1[0:30,k] fit = np.polyfit(x, y, 1) ax[k].scatter(x, y, s=20,c="blue",marker ="^") ax[k].set_ylim(amin,amax) ax[k].set_xlim(0,60) ax[k].plot(x, fit[0]*x + fit[1], 'r-') ax[k].text(5, atext, 'y='+str(round(fit[0],2))+'*x + '+str(round(fit[1],2))) ax[k].set_title(regs[k]) ax[k].set_yticks(yticks) # fig.suptitle("ABCDF") fig.savefig("Timeseries_"+var[i]+".pdf", bbox_inches="tight", pad_inches=.05, dpi=600) plt.cla() plt.clf() plt.close()