def xzCloudPlot(nest,time,plotTemp=True,plotRH=False): nc = openWRF(nest) Nx,Ny,Nz,longitude,_lats,_dx,_dy,x_nr,y_nr = getDimensions(nc) heightground_x,heighthalf_xz = _getHeight(nc, time, Nx, -1, Nz, -1, y_nr) print 'Model height: ' + str(heightground_x[x_nr]) theta = nc.variables['T'][time,:,y_nr,:] + T_base P = nc.variables['P'][time,:,y_nr,:] + nc.variables['PB'][time,:,y_nr,:] T = theta*(P/P_bot)**kappa # Temperatur i halvflatene (Kelvin) rho = P/(R*T) #[kg/m3] qcloud_xz = 1000.0*nc.variables['QCLOUD'][time,:,y_nr,:]*rho # regner om til g/m3 qrain_xz = 1000.0*nc.variables['QRAIN'][time,:,y_nr,:]*rho qsnow_xz = 1000.0*nc.variables['QSNOW'][time,:,y_nr,:]*rho plt.figure() plt.set_cmap(cmap_red) plt.axis([0,Nx-1,0.0,z_max]) print u'Cloud water red, snow blue, rain green ($g/m^3$)' grid = np.reshape(np.tile(arange(Nx),Nz),(Nz,-1)) plt.contourf(grid, heighthalf_xz, qcloud_xz, alpha=0.9,levels=xz_cloudwater_levels, cmap=cmap_red)# plt.colorbar() plt.contourf(grid, heighthalf_xz, qrain_xz, alpha=0.6,levels=xz_rain_levels, cmap=cmap_green)# plt.colorbar() plt.contourf(grid, heighthalf_xz, qsnow_xz, alpha=0.6,levels=xz_snow_levels,cmap=cmap_blue)# plt.colorbar() if plotTemp: temp_int = arange(-80.0,50.0,2.0) cs = plt.contour(grid, heighthalf_xz, T-T_zero, temp_int,colors='black',linestyles='solid')#linewidths=4 plt.clabel(cs, inline=1, fmt='%1.0f', fontsize=12,colors='black') if plotRH: rh = _getRH(nc,time,-1,y_nr,T,P) rh_int = arange(90.,111.,5.) cs = plt.contour(grid, heighthalf_xz,rh , rh_int, colors='grey') plt.clabel(cs, inline=1, fmt='%1.0f', fontsize=12, colors='grey') plt.plot(arange(Nx),heightground_x,color='black') plt.fill_between(arange(Nx),heightground_x,0,facecolor='lightgrey') plt.xticks(np.arange(0,Nx,8),np.round(longitude[Ny/2,::8], 1), fontsize='small') plt.yticks(np.arange(0,z_max,dz), fontsize='small') plt.xlabel('Lengdegrad') plt.ylabel(u'Høyde [m]') plt.show() plt.close()
def skewTPlot(nest, time): """ 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) _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('Temperatur ($^{\circ}\! C$) ved 1000hPa') xticks = np.arange(-40, 51, 5) plt.xticks(xticks, ['' if tick % 10 != 0 else str(tick) for tick in xticks]) plt.ylabel('Trykk (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('Bakketemp: %4.1f$^{\circ}\! C$ Duggpunkt: %3.1f$^{\circ}\! C$ Trykk: %5.1f hPa' % (sfcT,sfcTd,0.01*sfcP), \ fontsize=10, x = 0.5, y = 0.03) plt.show() plt.close()
def skewTPlot(nest,time): """ 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) _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('Temperatur ($^{\circ}\! C$) ved 1000hPa') xticks = np.arange(-40,51,5) plt.xticks(xticks,['' if tick%10!=0 else str(tick) for tick in xticks]) plt.ylabel('Trykk (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('Bakketemp: %4.1f$^{\circ}\! C$ Duggpunkt: %3.1f$^{\circ}\! C$ Trykk: %5.1f hPa' % (sfcT,sfcTd,0.01*sfcP), \ fontsize=10, x = 0.5, y = 0.03) plt.show() plt.close()
import numpy as np import cv2 form matplotlib import pyplot as plt img=cv2.imread('fate_zero.jpg',0) cv2.imshow("Fate Zero",img) plt.imshow(img, cmap = 'gray', interpolation = 'bicubic') plt.xticks([]), plt.yticks([]) plt.show() key=cv2.waitKey(0) & 0xFF if key == ord('k'): cv2.imwrite('Fate Zero.jpeg',img) cv2.destroyWindow("Fate Zero") elif key == 27: cv2.destroyWindow("Fate Zero")
def tzCloudPlot(nest, plotMetar=False, offset=0): nc = openWRF(nest) Nx, Ny, Nz, _longs, _lats, _dx, _dy, x_nr, y_nr = getDimensions(nc) heightground_t, heighthalf_tz = _getHeight(nc, Nx, Ny, Nz, x_nr, y_nr) T_tz = np.zeros((Nz, Nt)) qcloud_tz = np.zeros((Nz, Nt)) qice_tz = np.zeros((Nz, Nt)) qsnow_tz = np.zeros((Nz, Nt)) qrain_tz = np.zeros((Nz, Nt)) for t in arange(Nt): theta = nc.variables['T'][t, :, y_nr, x_nr] + T_base P = nc.variables['P'][t, :, y_nr, x_nr] + nc.variables['PB'][t, :, y_nr, x_nr] T_tz[:, t] = theta * (P / P_bot)**kappa # Temperatur i halvflatene (Kelvin) rho = P[:] / (R * T_tz[:, t]) # regner om til g/m3 qcloud_tz[:, t] = 1000.0 * nc.variables['QCLOUD'][t, :, y_nr, x_nr] * rho qice_tz[:, t] = 1000.0 * nc.variables['QICE'][t, :, y_nr, x_nr] * rho qsnow_tz[:, t] = 1000.0 * nc.variables['QSNOW'][t, :, y_nr, x_nr] * rho qrain_tz[:, t] = 1000.0 * nc.variables['QRAIN'][t, :, y_nr, x_nr] * rho for s in [u'Snø', 'Regn']: plt.figure() plt.axis([-offset, Nt - 1, 0.0, z_max]) grid = np.reshape(np.tile(arange(Nt), Nz), (Nz, -1)) if (s == u"Snø"): var = qsnow_tz cm = cmap_blue levs = tz_snow_levels else: var = qrain_tz cm = cmap_green levs = tz_rain_levels plt.contourf(grid, heighthalf_tz, qcloud_tz, alpha=0.9, levels=tz_cloudwater_levels, cmap=cmap_red) # plt.colorbar() plt.contourf(grid, heighthalf_tz, var, alpha=0.6, levels=levs, cmap=cm) # plt.colorbar() cs = plt.contour(grid, heighthalf_tz, T_tz - T_zero, temp_int, colors='black', linestyles='solid') plt.clabel(cs, inline=1, fmt='%1.0f', fontsize=12, colors='black') plt.fill_between(arange(-offset, Nt), heightground_t[0], 0, facecolor='lightgrey') if plotMetar: _metar() print s + ' ($g/m^3$)' plt.xlabel('Timer etter ' + date + 'T00:00Z') plt.ylabel(u'Høyde [m]') plt.yticks(np.arange(0, z_max, dz), fontsize='small') plt.show() plt.close() fig = plt.figure() ax1 = fig.add_subplot(111) ax1.set_xlim(0, Nt - 1) ax1.plot(np.sum(qcloud_tz, axis=0), color='black', label=u"skyvann") ax1.plot(np.sum(qsnow_tz, axis=0), color='green', label=u"snø") ax1.set_xlabel('Timer etter ' + date + 'T00:00Z') ax1.set_ylabel(u'Skyvann og snø ($g/m^2$)') ax2 = ax1.twinx() ax2.plot(np.sum(qice_tz, axis=0), color='blue', label="is") ax2.plot(np.sum(qrain_tz, axis=0), color='red', label="regn") ax2.set_ylabel('Regn og is ($g/m^2$)') ax1.set_xlim(0, Nt - 1) ax1.legend(loc='upper left') ax2.legend(loc='upper right') plt.show() plt.close()
def yzCloudPlot(nest, time, plotTemp=True, plotRH=False): nc = openWRF(nest) Nx, Ny, Nz, _longs, latitude, _dx, _dy, x_nr, y_nr = getDimensions(nc) heightground_y, heighthalf_yz = _getHeight(nc, time, -1, Ny, Nz, x_nr, -1) print 'Model height: ' + str(heightground_y[y_nr]) theta = nc.variables['T'][time, :, :, x_nr] + T_base P = nc.variables['P'][time, :, :, x_nr] + nc.variables['PB'][time, :, :, x_nr] T = theta * (P / P_bot)**kappa # Temperatur i halvflatene (Kelvin) rho = P / (R * T) #[kg/m3] qcloud_yz = 1000.0 * nc.variables['QCLOUD'][ time, :, :, x_nr] * rho # regner om til g/m3 qrain_yz = 1000.0 * nc.variables['QRAIN'][time, :, :, x_nr] * rho qsnow_yz = 1000.0 * nc.variables['QSNOW'][time, :, :, x_nr] * rho plt.figure() plt.set_cmap(cmap_red) plt.axis([0, Ny - 1, 0.0, z_max]) print u'Cloud water red, snow blue, rain green ($g/m^3$)' grid = np.reshape(np.tile(arange(Ny), Nz), (Nz, -1)) plt.contourf(grid, heighthalf_yz, qcloud_yz, alpha=0.9, levels=xz_cloudwater_levels, cmap=cmap_red) # plt.colorbar() plt.contourf(grid, heighthalf_yz, qrain_yz, alpha=0.6, levels=xz_rain_levels, cmap=cmap_green) # plt.colorbar() plt.contourf(grid, heighthalf_yz, qsnow_yz, alpha=0.6, levels=xz_snow_levels, cmap=cmap_blue) # plt.colorbar() if plotTemp: cs = plt.contour(grid, heighthalf_yz, T - T_zero, temp_int, colors='black', linestyles='solid') #linewidths=4 plt.clabel(cs, inline=1, fmt='%1.0f', fontsize=12, colors='black') if plotRH: rh = _getRH(nc, time, x_nr, -1, T, P) rh_int = arange(90., 111., 5.) cs = plt.contour(grid, heighthalf_yz, rh, rh_int, colors='grey') plt.clabel(cs, inline=1, fmt='%1.0f', fontsize=12, colors='grey') plt.plot(arange(Ny), heightground_y, color='black') plt.fill_between(arange(Ny), heightground_y, 0, facecolor='lightgrey') plt.xticks(np.arange(0, Ny, 8), np.round(latitude[::8, Nx / 2], 1), fontsize='small') plt.yticks(np.arange(0, z_max, dz), fontsize='small') plt.xlabel('Breddegrad') plt.ylabel(u'Høyde [m]') plt.show() plt.close()