# Vt max time series, top half Xaxis = plu.AxisConfig('x', [0, 62], '') Xaxis.ticks = [6, 18, 30, 42, 54] Xaxis.ticklabels = [ "12Z\n22Aug", "0Z\n23Aug", "12Z\n23Aug", "0Z\n24Aug", "12Z\n23Aug" ] Xaxis.fontsize = 14 Yaxis = plu.AxisConfig('y', [5, 23], r'$Speed (ms^{-1})$') Yaxis.fontsize = 14 Ptitle = plu.TitleConfig('a', r'$V_t (max)$') Ptitle.fontsize = 24 Legend = plu.LegendConfig(LegText, 'upper left') Legend.bbox = [1.02, 1.0] Legend.fontsize = 12 Legend.ncol = 1 plu.PlotLine(AxVt, T, WindTs, Ptitle, Xaxis, Yaxis, Legend, Colors) # Mark the PRESAL (10-30 h) and SAL (40-60 h) time periods AxVt.plot([10, 30], [7, 7], color='black', linewidth=2) AxVt.plot([10, 10], [6, 8], color='black', linewidth=2) AxVt.plot([30, 30], [6, 8], color='black', linewidth=2) AxVt.text(15, 8.4, 'PSAP', color='black', fontsize=14) AxVt.plot([40, 60], [7, 7], color='black', linewidth=2) AxVt.plot([40, 40], [6, 8], color='black', linewidth=2) AxVt.plot([60, 60], [6, 8], color='black', linewidth=2)
print("") # Make the plot Fig = plt.figure() Ax = Fig.add_axes([0.1, 0.1, 0.7, 0.8]) Xaxis = plu.AxisConfig('x', Xlims, Xlabel) Xaxis.fontsize = 12 Yaxis = plu.AxisConfig('y', Ylims, Ylabel) Yaxis.fontsize = 12 Ptitle = plu.TitleConfig('', Pname) Ptitle.fontsize = 24 Legend = plu.LegendConfig(SimLegText, 'upper left') Legend.bbox = [1.02, 1.0] Legend.fontsize = 9 Legend.ncol = 1 plu.PlotLine(Ax, T, VARS.transpose(), Ptitle, Xaxis, Yaxis, Legend, SimColors) OutFile = "{0:s}/{1:s}TimeSeries{2:s}.png".format( Pdir, Pfprefix, Oname) print("Writing: {0:s}".format(OutFile)) Fig.savefig(OutFile) plt.close() print("")
def CreateFig(self): # get labels and colors for sims and factors LabelScheme = conf.SetLabelScheme() ColorScheme = conf.SetColorScheme() # Collect input data in an array: (y,sim) # Create factors on the y values, assume all sims have identical x values # and all sims have identical length y values SimLabels = [] SimColors = [] for i in range(self.Nsims): Sim = self.SimList[i] SimLabels.append(LabelScheme[Sim]) SimColors.append(ColorScheme[Sim]) InFname = self.InFname.replace("<SIM>", Sim) Xname = self.Xname Yname = self.Yname print("Reading {0:s} ({1:s})".format(InFname, Xname)) print("Reading {0:s} ({1:s})".format(InFname, Yname)) InFile = h5py.File(InFname, mode='r') X = InFile[Xname][...] * self.Xscale + self.Xoffset Y = InFile[Yname][...] * self.Yscale + self.Yoffset if (i == 0): Nx = len(X) Ny = len(Y) Yvals = np.zeros([ Ny, self.Nsims ], dtype=np.float_) Yvals[:,i] = Y InFile.close() print("") # Build the factors from the input cross sections # The second dimension in Yvals is the sim which # is mapped as: # # index sim # 0 NSND # 1 SND # 2 NSD # 3 SD # # Factors are in this order: # # index factor formula # 0 FAC_SAL SND - NSND # 1 FAC_DUST NSD - NSND # 2 FAC_INT SD - (SND + NSD) + NSND FacLabels = [] FacColors = [] FacVals = np.zeros( [ Ny, self.Nfacs ], dtype=np.float_) for i in range(self.Nfacs): Factor = self.FacList[i] FacLabels.append(LabelScheme[Factor]) FacColors.append(ColorScheme[Factor]) if (Factor == 'FAC_SAL'): # SND - NSND FacVals[:,i] = Yvals[:,1] - Yvals[:,0] elif (Factor == 'FAC_DUST'): # NSD - NSND FacVals[:,i] = Yvals[:,2] - Yvals[:,0] elif (Factor == 'FAC_INT'): # SD - (SND + NSD) + NSND FacVals[:,i] = Yvals[:,3] - (Yvals[:,1] + Yvals[:,2]) + Yvals[:,0] else: print("ERROR: PlotXsection: Attempted to calculate too many factors") print("ERROR: PlotXsection: Stopping!") sys.exit(1) # 2 panel plot # Sims on top # Factors on bottom self.Fig = plt.figure() # legeng specs LegBbox = [ 1.02, 1.0 ] LegFsize = 12 LegNcol = 1 # Place axes for all panels AxW = 0.70 AxH = 0.35 AxLlx = 0.10 AxLly = [ 0.10, 0.55 ] self.SimAx.append(self.Fig.add_axes([ AxLlx, AxLly[1], AxW, AxH ])) self.FacAx.append(self.Fig.add_axes([ AxLlx, AxLly[0], AxW, AxH ])) # create axes Xaxis = plu.AxisConfig('x', [ self.Xmin, self.Xmax ], self.Xlabel) Xaxis.fontsize = self.AxFsize if self.Xticks: Xaxis.ticks = self.Xticks if self.XtickLabels: Xaxis.ticklabels = self.XtickLabels Yaxis = plu.AxisConfig('y', [ self.Ymin, self.Ymax ], self.Ylabel) Yaxis.fontsize = self.AxFsize if self.Yticks: Yaxis.ticks = self.Yticks if self.YtickLabels: Yaxis.ticklabels = self.YtickLabels # Sim lines Ptitle = plu.TitleConfig(self.SimPmarkers[0], "SIMS: {0:s}".format(self.Title)) Ptitle.fontsize = self.TitleFsize Legend = plu.LegendConfig(SimLabels, 'upper left') Legend.bbox = LegBbox Legend.fontsize = LegFsize Legend.ncol = LegNcol Xaxis.show = self.SimXshow[0] Yaxis.show = self.SimYshow[0] Yaxis.lim = self.SimLimits plu.PlotLine(self.SimAx[0], X, Yvals, Ptitle, Xaxis, Yaxis, Legend, SimColors) # Factor lines Ptitle = plu.TitleConfig(self.FacPmarkers[0], "FACTORS: {0:s}".format(self.Title)) Ptitle.fontsize = self.TitleFsize Legend = plu.LegendConfig(FacLabels, 'upper left') Legend.bbox = LegBbox Legend.fontsize = LegFsize Legend.ncol = LegNcol Xaxis.show = self.FacXshow[0] Yaxis.show = self.FacYshow[0] Yaxis.lim = self.FacLimits plu.PlotLine(self.FacAx[0], X, FacVals, Ptitle, Xaxis, Yaxis, Legend, FacColors) print("Writing: {0:s}".format(self.OutFname)) self.Fig.savefig(self.OutFname) plt.close() print("")