yPosition=ymax - 0.25) PlotTweak.setXLim(fig2.getAxes(True)[ind], 0, xmax) PlotTweak.setYLim(fig2.getAxes(True)[ind], 0, ymax) #fig2.getAxes(True)[ind].plot( [0,xmax], [0, ymax], 'k-', alpha=0.75, zorder=0) PlotTweak.useLegend(fig2.getAxes(True)[ind], loc='upper left') PlotTweak.setXaxisLabel(fig2.getAxes(True)[ind], "", None, useBold=True) PlotTweak.setYaxisLabel(fig2.getAxes(True)[ind], "", None, useBold=True) Plot.getVerticalLine(fig2.getAxes(True)[ind], 1.5) PlotTweak.setXaxisLabel(fig2.getAxes(True)[2], "Time", "h", useBold=True) PlotTweak.setXaxisLabel(fig2.getAxes(True)[3], "Time", "h", useBold=True) PlotTweak.setYaxisLabel(fig2.getAxes(True)[0], "Cloud top relative change", None, useBold=True) PlotTweak.setYaxisLabel(fig2.getAxes(True)[2], "Cloud top relative change",
PlotTweak.setYTickSizes(ax, shownLabelsBoolean) for i in [1, 3, 5]: #IWP figures ax = fig.getAxes(i) PlotTweak.setYaxisLabel(ax, "IWP", "g\ m^{-2}") end = iwpYlimit PlotTweak.setYLim(ax, end=end) ticks = PlotTweak.setYticks(ax, end=end, interval=1) shownLabelsBoolean = PlotTweak.setYLabels(ax, ticks, end=end, interval=3) PlotTweak.setYTickSizes(ax, shownLabelsBoolean) for i in [0, 2, 3, 4, 5]: #all timeseries figures ax = fig.getAxes(i) end = 8 PlotTweak.setXLim(ax, end=end) Plot.getVerticalLine(ax, 2) if i in [4, 5]: PlotTweak.setXaxisLabel(ax, "Time", "h") else: PlotTweak.setXaxisLabel(ax, "") PlotTweak.hideXTickLabels(ax) ticks = PlotTweak.setXticks(ax, end=end, interval=0.5, integer=False) ticks = [int(k) for k in ticks] shownLabelsBoolean = PlotTweak.setXLabels(ax, ticks, end=end, interval=2) PlotTweak.setXTickSizes(ax, shownLabelsBoolean) # empty space ax = fig.getAxes(1) ax.axis("off")
def main(simulationDataFrameCSVFile): simulationDataFrame = pandas.read_csv(simulationDataFrameCSVFile) # set simulation data as dictionary simulationCollection = InputSimulation.getSimulationCollection( simulationDataFrame) if False: fig1 = Figure("/home/aholaj/Nextcloud/kuvatesti", "Prognostic") cloudTicks = Plot.getTicks(0, 1000, 250) logaritmicLevels = Plot.getLogaritmicTicks(-17, -9, includeFives=True) ax, im = Plot.getTimeseriesOfProfile( fig1.getAxes(), simulationCollection["Prognostic_48h"], "P_cDUa", title="", yticks=cloudTicks, timeEndH=33.05, levels=logaritmicLevels, useColorBar=False, showXaxisLabels=False, showXLabel=False) fig1.save() if False: # create figure object fig2 = Figure("/home/aholaj/Nextcloud/kuvatesti", "LWP") # load ts-datasets and change their time coordinates to hours for k in [ "Prognostic_48h", "ICE4_24h", "Prognostic_2", "Prognostic_Aero", "Prognostic_2_Aero" ]: simulationCollection[k].getTSDataset() simulationCollection[k].setTimeCoordToHours() # plot timeseries with unit conversion Plot.getTimeseries(fig2.getAxes(), [ simulationCollection["Prognostic_48h"], simulationCollection["ICE4_24h"], simulationCollection["Prognostic_Aero"], simulationCollection["Prognostic_2"], simulationCollection["Prognostic_2_Aero"] ], "lwp_bar", conversionFactor=1000.) end = 32 # set xticks ticks = PlotTweak.setXticks(fig2.getAxes(), end=end, interval=0.5) # set xlabels shownLabelsBoolean = PlotTweak.setXLabels(fig2.getAxes(), ticks, end=end, interval=4) # set xtick sizes PlotTweak.setXTickSizes(fig2.getAxes(), shownLabelsBoolean, minorFontSize=8) # limit x-axes PlotTweak.setXLim(fig2.getAxes(), end=end) PlotTweak.setYLim(fig2.getAxes(), end=60) # set annotation for figure PlotTweak.setAnnotation(fig2.getAxes(), "a) Liquid water path", xPosition=2, yPosition=30) Plot.getVerticalLine(fig2.getAxes(), 2) # set axes labels PlotTweak.setXaxisLabel(fig2.getAxes(), "LWP", "g\ m^{-2}") PlotTweak.setYaxisLabel(fig2.getAxes(), "Time", "h") PlotTweak.useLegend(fig2.getAxes()) PlotTweak.setTightLayot(fig2.getFig()) fig2.save() if True: # create figure object fig2 = Figure("/home/aholaj/Nextcloud/kuvatesti", "Nc_ic") # load ts-datasets and change their time coordinates to hours sensitive = [ "ICE0_8h", "ICE1_24h", "ICE2_24h", "ICE3_24h", "ICE3_8h", "ICE4_24h", "ICE5_8h", "ICE6_8h", "Prognostic_48h" ] for k in sensitive: simulationCollection[k].getTSDataset() simulationCollection[k].setTimeCoordToHours() # plot timeseries with unit conversion Plot.getTimeseries(fig2.getAxes(), simulationCollection[k], "Nc_ic", conversionFactor=1e-6) end = 32 # set xticks ticks = PlotTweak.setXticks(fig2.getAxes(), end=end, interval=0.5) # set xlabels shownLabelsBoolean = PlotTweak.setXLabels(fig2.getAxes(), ticks, end=end, interval=4) # set xtick sizes PlotTweak.setXTickSizes(fig2.getAxes(), shownLabelsBoolean, minorFontSize=8) # limit x-axes PlotTweak.setXLim(fig2.getAxes(), end=end) #PlotTweak.setYLim(fig2.getAxes(), end = 60) # set annotation for figure PlotTweak.setAnnotation(fig2.getAxes(), "a) Nc_ic", xPosition=2, yPosition=155) Plot.getVerticalLine(fig2.getAxes(), 2) # set axes labels PlotTweak.setYaxisLabel(fig2.getAxes(), "In-cloud\ CDNC", "mg^{-1}") PlotTweak.setXaxisLabel(fig2.getAxes(), "Time", "h") PlotTweak.useLegend(fig2.getAxes()) PlotTweak.setTightLayot(fig2.getFig()) fig2.save(file_extension=".png") if True: # create figure object fig3 = Figure("/home/aholaj/Nextcloud/kuvatesti", "IWP") # load ts-datasets and change their time coordinates to hours for k in [ "Prognostic_48h", "ICE4_24h", "Prognostic_2", "Prognostic_Aero", "Prognostic_2_Aero" ]: simulationCollection[k].getTSDataset() #simulationCollection[k].setTimeCoordToHours() # plot timeseries with unit conversion Plot.getTimeseries(fig3.getAxes(), [ simulationCollection["Prognostic_48h"], simulationCollection["ICE4_24h"], simulationCollection["Prognostic_Aero"], simulationCollection["Prognostic_2"], simulationCollection["Prognostic_2_Aero"] ], "iwp_bar", conversionFactor=1000.) end = 32 # set xticks ticks = PlotTweak.setXticks(fig3.getAxes(), end=end, interval=0.5) # set xlabels shownLabelsBoolean = PlotTweak.setXLabels(fig3.getAxes(), ticks, end=end, interval=4) # set xtick sizes PlotTweak.setXTickSizes(fig3.getAxes(), shownLabelsBoolean, minorFontSize=8) # limit x-axes PlotTweak.setXLim(fig3.getAxes(), end=end) PlotTweak.setYLim(fig3.getAxes(), end=60) # set annotation for figure PlotTweak.setAnnotation(fig3.getAxes(), "b) Ice water path", xPosition=2, yPosition=30) Plot.getVerticalLine(fig3.getAxes(), 2) # set axes labels PlotTweak.setXaxisLabel(fig3.getAxes(), "IWP", "g\ m^{-2}") PlotTweak.setYaxisLabel(fig3.getAxes(), "Time", "h") PlotTweak.useLegend(fig3.getAxes()) PlotTweak.setTightLayot(fig3.getFig()) fig3.save() if False: # create figure object fig2 = Figure("/home/aholaj/Nextcloud/kuvatesti", "fourWinds", ncols=2, nrows=2, style="seaborn-paper") # load ts-datasets and change their time coordinates to hours for k in ["ICE0_8h", "ICE1_8h"]: simulationCollection[k].getTSDataset() simulationCollection[k].getPSDataset() simulationCollection[k].setTimeCoordToHours() # plot timeseries with unit conversion Plot.getTimeseries(fig2.getAxes()[0, 0], simulationCollection["ICE0_8h"], "lwp_bar", conversionFactor=1000.) Plot.getVerticalLine(fig2.getAxes()[0, 0], 2) if True: PlotTweak.setSuperWrapper( fig2.getAxes()[0, 0], xstart=0, xend=8, xtickinterval=0.5, xlabelinterval=2, xticks=None, xShownLabels=None, xTickMajorFontSize= 3.5, # matplotlib.rcParams["xtick.major.size"], yTickMajorFontSize= 3.5, #matplotlib.rcParams["ytick.major.size"], ystart=0, yend=60, ytickinterval=2, ylabelinterval=10, yticks=None, yShownLabels=None, annotationText=None, annotationXPosition=2, annotationYPosition=30, xlabel="Time", xunit="h", ylabel="LWP", yunit="g\ m^{-2}", useBold=True) PlotTweak.hideYTickLabels(fig2.getAxes()[0, 0]) PlotTweak.setAxesOff(fig2.getAxes()[0, 1]) PlotTweak.setLegendSimulation( fig2.getAxes()[0, 1], [simulationCollection["ICE0_8h"], simulationCollection["ICE1_8h"]]) ax, im, levels = Plot.getTimeseriesOfProfile( fig2.getAxes()[1, 1], simulationCollection["ICE0_8h"], "P_RH", levels=None, useLogaritmic=False, colors=None) PlotTweak.setAxesOff(fig2.getAxes()[1, 0]) cax = matplotlib.pyplot.axes([0.05, 0.25, 0.3, 0.03]) Plot.getColorBar(im, cax, levels) #Plot.getContourLine(fig2.getAxes()[1,1],"ICE0_8h", color = 'black' , value = 100) fig2.save()
def figure5(self): fig = Figure(self.figurefolder,"figure5", ncols = 2, nrows = 2, wspace=0.1, bottom = 0.14, left=0.15, top=0.98) simulation = "Prognostic_48h" self.simulationCollection[simulation].getPSDataset() self.simulationCollection[simulation].getTSDataset() self.simulationCollection[simulation].setTimeCoordToHours() logaritmicLevels = PlotTweak.getLogaritmicTicks(-17,-9, includeFives = True) end = 1000 yPositionFrac = 0.9 xPosition = 0.5 orange = Colorful.getDistinctColorList("orange") annotation = ["a) Dust in aerosols", "b) Dust in cloud droplets", "c) Dust in ice crystals"] for ind, muuttuja in enumerate(["P_cDUa", "P_cDUc", "P_cDUi"]): ax = fig.getAxes(ind) data = self.simulationCollection[simulation].getPSDataset()[muuttuja] data.values = numpy.log10(data.values) im = data.plot.contourf("time","zt", ax = ax, levels=logaritmicLevels, add_colorbar = False) self.simulationCollection[simulation].getTSDataset()["zb"].plot(ax = ax, color = orange, linewidth = self.simulationCollection[simulation].getLineWidth()) ax = Plot.getContourLine(ax, self.simulationCollection[simulation], "P_RHi", 100) PlotTweak.setAnnotation(ax, annotation[ind], xPosition=xPosition, yPosition= yPositionFrac*end) end = 1000 PlotTweak.setYLim(ax, end = end) ticks = PlotTweak.setYticks(ax, end = end, interval = 100) shownLabelsBoolean = PlotTweak.setYLabels(ax, ticks, end = end, interval = 200) PlotTweak.setYTickSizes(ax, shownLabelsBoolean) for i in range(3): ax = fig.getAxes(i) end = 33.05 PlotTweak.setXLim(ax, end = end) Plot.getVerticalLine(ax, 2) if i in [1,2]: PlotTweak.setXaxisLabel(ax,"Time", "h") else: PlotTweak.setXaxisLabel(ax,"") PlotTweak.hideXTickLabels(ax) if i == 1: PlotTweak.hideYTickLabels(ax) if i in [0,2]: PlotTweak.setYaxisLabel(ax,"Height", "m") else: PlotTweak.setYaxisLabel(ax,"") PlotTweak.hideYTickLabels(ax) ticks = PlotTweak.setXticks(ax, end = end, interval = 1) shownLabelsBoolean = PlotTweak.setXLabels(ax, ticks, end = end, interval = 4) PlotTweak.setXTickSizes(ax, shownLabelsBoolean) # empty space ax = fig.getAxes(3) ax.axis("off") legend_elements = [Patch(facecolor="black", label='RH over ice 100%'), Patch(facecolor=orange, label='Cloud base')] ax.legend(handles=legend_elements, loc=(0.07,-0.02), frameon = True, framealpha = 1.0) cax = matplotlib.pyplot.axes([0.6, 0.4, 0.33, 0.03]) Plot.getColorBar(im,cax,logaritmicLevels) shownLabelsBoolean = Data.getMaskedList(logaritmicLevels, numpy.arange(-11,-19,-1)) PlotTweak.hideLabels(cax.xaxis, shownLabelsBoolean) PlotTweak.setXTickSizes(cax, shownLabelsBoolean) PlotTweak.setXaxisLabel(cax, "", unit="kg\ kg^{-1}") ### fig.save()
def figure2(self): # create figure object fig = Figure(self.figurefolder,"figure2", ncols = 2, nrows = 3) simulationList = Figure2SimulationList() for k in simulationList.getAllSimulations(): try: self.simulationCollection[k].getTSDataset() self.simulationCollection[k].setTimeCoordToHours() except FileNotFoundError: if "ovchinnikov" in str(self.simulationCollection[k].getFolder()).lower(): print("Ovchinnikov data is not available. Continue with existing simulations") continue else: print("{0} data missing from {1}, make sure you have set your \ folder and environment variables correctly".format(k, self.simulationCollection[k].getFolder())) if self.simulationCollection[k].getLabel() == "BULK": self.simulationCollection[k].setZorder(1) elif self.simulationCollection[k].getLabel() == "BIN": self.simulationCollection[k].setZorder(2) else: self.simulationCollection[k].setZorder(3) for k in simulationList.getUCLALESSALSASimulations(): self.simulationCollection[k].setLineWidth(matplotlib.rcParams["lines.linewidth"]*1.5) self.simulationCollection[k].setColor(Colorful.getDistinctColorList("green")) lwpYlimit = 60 iwpYlimit = 21 yPositionFrac = 0.91 # figA ax = fig.getAxes(0) for k in simulationList.getIce0Simulations(): Plot.getTimeseries(ax, self.simulationCollection[k], "lwp_bar", conversionFactor=1000.) PlotTweak.setAnnotation(ax, "a) ICE0 liquid water path", xPosition=0.2, yPosition= lwpYlimit*yPositionFrac) # figB ax = fig.getAxes(2) for k in simulationList.getIce1Simulations(): Plot.getTimeseries(ax, self.simulationCollection[k], "lwp_bar", conversionFactor=1000.) PlotTweak.setAnnotation(ax, "b) ICE1 liquid water path", xPosition=0.2, yPosition= lwpYlimit*yPositionFrac) # figC ax = fig.getAxes(3) for k in simulationList.getIce1Simulations(): Plot.getTimeseries(ax, self.simulationCollection[k], "iwp_bar", conversionFactor=1000.) PlotTweak.setAnnotation(ax, "c) ICE1 ice water path", xPosition=0.2, yPosition= iwpYlimit*yPositionFrac) # figD ax = fig.getAxes(4) for k in simulationList.getIce4Simulations(): Plot.getTimeseries(ax, self.simulationCollection[k], "lwp_bar", conversionFactor=1000.) PlotTweak.setAnnotation(ax, "d) ICE4 liquid water path", xPosition=0.2, yPosition= lwpYlimit*yPositionFrac) # figE ax = fig.getAxes(5) for k in simulationList.getIce4Simulations(): Plot.getTimeseries(ax, self.simulationCollection[k], "iwp_bar", conversionFactor=1000.) PlotTweak.setAnnotation(ax, "e) ICE4 ice water path", xPosition=0.2, yPosition= iwpYlimit*yPositionFrac) for i in [0,2,4]: #LWP figures ax = fig.getAxes(i) end = lwpYlimit PlotTweak.setYaxisLabel(ax,"LWP", "g\ m^{-2}") PlotTweak.setYLim(ax, end = end) ticks = PlotTweak.setYticks(ax, end = end, interval = 2) shownLabelsBoolean = PlotTweak.setYLabels(ax, ticks, end = end, interval = 10) PlotTweak.setYTickSizes(ax, shownLabelsBoolean) for i in [1,3,5]: #IWP figures ax = fig.getAxes(i) PlotTweak.setYaxisLabel(ax,"IWP", "g\ m^{-2}") end = iwpYlimit PlotTweak.setYLim(ax, end = end) ticks = PlotTweak.setYticks(ax, end = end, interval = 1) shownLabelsBoolean = PlotTweak.setYLabels(ax, ticks, end = end, interval = 3) PlotTweak.setYTickSizes(ax, shownLabelsBoolean) for i in [0,2,3,4,5]: #all timeseries figures ax = fig.getAxes(i) end = 8 PlotTweak.setXLim(ax, end = end) Plot.getVerticalLine(ax, 2) if i in [4,5]: PlotTweak.setXaxisLabel(ax,"Time", "h") else: PlotTweak.setXaxisLabel(ax,"") PlotTweak.hideXTickLabels(ax) ticks = PlotTweak.setXticks(ax, end = end, interval = 0.5, integer=False) ticks = [int(k) for k in ticks] shownLabelsBoolean = PlotTweak.setXLabels(ax, ticks, end = end, interval = 2) PlotTweak.setXTickSizes(ax, shownLabelsBoolean) # empty space ax = fig.getAxes(1) ax.axis("off") legend_elements = [Patch(facecolor=self.simulationCollection["ICE0_8h"].getColor(), label='UCLALES-SALSA'), Patch(facecolor=self.simulationCollection["SAM-bin_ice0"].getColor(), label='BIN'), Patch(facecolor=self.simulationCollection["COSMO_ice0"].getColor(), label='BULK')] ax.legend(handles=legend_elements, loc='center', frameon = True, framealpha = 1.0) fig.save()
def figure4(self): fig = Figure(self.figurefolder,"figure4", ncols = 2, nrows = 3, left=0.15, wspace=0.4) simulationList = ["Prognostic_48h", "ICE4_24h"] for k in simulationList: self.simulationCollection[k].getTSDataset() self.simulationCollection[k].getNCDataset() self.simulationCollection[k].setTimeCoordToHours() lwpYlimit = 60 iwpYlimit = 21 xPosition = 0.52 yPositionFrac = 0.91 # figA ax = fig.getAxes(0) for k in simulationList: Plot.getTimeseries(ax, self.simulationCollection[k], "lwp_bar", conversionFactor=1000.) end = lwpYlimit PlotTweak.setAnnotation(ax, "a) Liquid water path", xPosition=xPosition, yPosition= yPositionFrac*end) PlotTweak.setYaxisLabel(ax,"LWP", "g\ m^{-2}") PlotTweak.setYLim(ax, end = end) PlotTweak.setYLim(ax, end = end) ticks = PlotTweak.setYticks(ax, end = end, interval = 2) shownLabelsBoolean = PlotTweak.setYLabels(ax, ticks, end = end, interval = 10) PlotTweak.setYTickSizes(ax, shownLabelsBoolean) # figB ax = fig.getAxes(1) for k in simulationList: Plot.getTimeseries(ax, self.simulationCollection[k], "iwp_bar", conversionFactor=1000.) end = iwpYlimit PlotTweak.setAnnotation(ax, "b) Ice water path", xPosition=xPosition, yPosition= yPositionFrac*end) PlotTweak.setYaxisLabel(ax,"IWP", "g\ m^{-2}") PlotTweak.setYLim(ax, end = end) end = iwpYlimit PlotTweak.setYLim(ax, end = end) ticks = PlotTweak.setYticks(ax, end = end, interval = 1) shownLabelsBoolean = PlotTweak.setYLabels(ax, ticks, end = end, interval = 3) PlotTweak.setYTickSizes(ax, shownLabelsBoolean) # figC ax = fig.getAxes(2) for k in simulationList: self.simulationCollection[k].getNCDataset()["Ni_ii_vol"].plot(ax = ax, color = self.simulationCollection[k].getColor(), label = self.simulationCollection[k].getLabel(), linewidth = self.simulationCollection[k].getLineWidth()) end = 5 PlotTweak.setAnnotation(ax, "c) Ice number \nconcentration", xPosition=xPosition, yPosition= 4) PlotTweak.setYaxisLabel(ax,"N_{i}", "L^{-1}") PlotTweak.setYLim(ax, end = end) ticks = PlotTweak.setYticks(ax, end = end, interval = 0.2, integer=False) shownLabelsBoolean = PlotTweak.setYLabels(ax, ticks, end = end, interval = 1) PlotTweak.setYTickSizes(ax, shownLabelsBoolean) # figD ax = fig.getAxes(3) for k in simulationList: Plot.getTimeseries(ax, self.simulationCollection[k], "Nc_ic", conversionFactor=1e-6) end = 170 PlotTweak.setAnnotation(ax, "d) In-cloud CDNC", xPosition=xPosition, yPosition= yPositionFrac*end) PlotTweak.setYaxisLabel(ax,"CDNC", "mg^{-1}") PlotTweak.setYLim(ax, end = end) ticks = PlotTweak.setYticks(ax, end = end, interval = 10) shownLabelsBoolean = PlotTweak.setYLabels(ax, ticks, end = end, interval = 50) PlotTweak.setYTickSizes(ax, shownLabelsBoolean) # figE ax = fig.getAxes(4) for k in simulationList: for muuttuja in ["zb", "zc"]: self.simulationCollection[k].getTSDataset()[muuttuja].where(self.simulationCollection[k].getTSDataset()[muuttuja] > 0).plot(ax = ax, color = self.simulationCollection[k].getColor(), label = self.simulationCollection[k].getLabel(), linewidth = self.simulationCollection[k].getLineWidth()) end = 1000 PlotTweak.setAnnotation(ax, "e) Cloud top and base", xPosition=xPosition, yPosition= yPositionFrac*end) PlotTweak.setYaxisLabel(ax,"Height", "m") PlotTweak.setYLim(ax, end = end) ticks = PlotTweak.setYticks(ax, end = end, interval = 100) shownLabelsBoolean = PlotTweak.setYLabels(ax, ticks, end = end, interval = 200) PlotTweak.setYTickSizes(ax, shownLabelsBoolean) for i in range(5): ax = fig.getAxes(i) end = 32 PlotTweak.setXLim(ax, end = end) Plot.getVerticalLine(ax, 2) Plot.getVerticalLine(ax, 24) if i in [3,4]: PlotTweak.setXaxisLabel(ax,"Time", "h") else: PlotTweak.setXaxisLabel(ax,"") PlotTweak.hideXTickLabels(ax) ticks = PlotTweak.setXticks(ax, end = end, interval = 0.5) shownLabelsBoolean = PlotTweak.setXLabels(ax, ticks, end = end, interval = 4) PlotTweak.setXTickSizes(ax, shownLabelsBoolean) # empty space ax = fig.getAxes(5) ax.axis("off") legend_elements = [Patch(facecolor=self.simulationCollection["Prognostic_48h"].getColor(), label='Prognostic ice'), Patch(facecolor=self.simulationCollection["ICE4_24h"].getColor(), label='ICE4')] ax.legend(handles=legend_elements, loc='center', frameon = True, framealpha = 1.0) fig.save()