def skewTPlot(nest, timetuple): """ This is the method to use from the outside nest: The nesting level of the nc-file from WRF time: The time for which to plot """ nc = openWRF(nest) time = convert_time(nest, timetuple) _Nx, _Ny, _Nz, _longs, _lats, _dx, _dy, x, y = getDimensions(nc) plt.figure() _isotherms() _isobars() _dry_adiabats() _moist_adiabats() P = nc.variables["P"][time, :, y, x] + nc.variables["PB"][time, :, y, x] _windbarbs(nc, time, y, x, P) _temperature(nc, time, y, x, P) _dewpoint(nc, time, y, x, P) plt.axis([-40, 50, P_b, P_t]) plt.xlabel("Temperature ($^{\circ}\! C$) at 1000hPa") xticks = np.arange(-40, 51, 5) plt.xticks(xticks, ["" if tick % 10 != 0 else str(tick) for tick in xticks]) plt.ylabel("Pressure (hPa)") yticks = np.arange(P_bot, P_t - 1, -10 ** 4) plt.yticks(yticks, yticks / 100) sfcT = nc.variables["T2"][time, y, x] - T_zero sfcP = nc.variables["PSFC"][time, y, x] sfcW = nc.variables["Q2"][time, y, x] sfcTd = td(e(sfcW, sfcP)) plt.suptitle( "Drybulb: %4.1f$^{\circ}\! C$ Dewpoint: %3.1f$^{\circ}\! C$ Pressure: %5.1f hPa" % (sfcT, sfcTd, 0.01 * sfcP), fontsize=10, x=0.5, y=0.03, ) # plt.show() plt.savefig(outdir + naming + str(nest) + "_skewT.png") plt.title("Skew-T plot for (location)") plt.close()
plt.yticks(yticks, ytix) # yticks = N.arange(P_bot,P_t-1,-10**4) # plt.yticks(yticks,yticks/100) # Legend ax = plt.gca() handles, labels = ax.get_legend_handles_labels() obsArt = plt.Line2D((0, 1), (0, 0), color="black") wrfArt = plt.Line2D((0, 1), (0, 0), color="blue") plt.legend([obsArt, wrfArt], ["Observed", "WRF Output"]) # plt.savefig(outdir+'kslcSkewT.png',bbox_inches='tight') ### ADD MODEL DATA nc = openWRF(dom) # Pick domain here Nx, Ny, Nz, lons, lats, dx, dy, x, y = getDimensions(nc) del x, y # We want our own locations time = gettime() x, y, exactlat, exactlon = gridded_data.getXY(lats[:, Nx / 2], lons[Ny / 2, :], obs_latlon[0], obs_latlon[1]) P = nc.variables["P"][time, :, y, x] + nc.variables["PB"][time, :, y, x] elev = nc.variables["HGT"][0, y, x] thin_locs = gridded_data.thinned_barbs(P) ST._windbarbs(nc, time, y, x, P, thin_locs, n=45, color="blue") ST._temperature(nc, time, y, x, P, linestyle="solid", color="blue") ST._dewpoint(nc, time, y, x, P, linestyle="dashed", color="blue")