Exemple #1
0
def mapTerrain(nest,includePMSL=False,includeTemp=False):
    """Creates a map of the domain, showing
    filled contours of the terrain
    """
    nc = openWRF(nest)
    met = openWPS(nest)
    nc1 = openWRF(nest+1)
    _Nx,_Ny,_Nz,longitude,latitude,_dx,_dy,_x,_y = getDimensions(nc)

    m = _getMapForNC(nc,False,_getDL(nest),100)
    x, y = m(longitude,latitude)
    _makeDots(m)
    
    if (includeTemp and met is not None):
        ST = met.variables['TT'][0][0,:,:]
        cs = plt.contour(x,y, ST-T_zero,arange(-48,50,2.),colors='blue',linestyles='solid')
        plt.clabel(cs, inline=1,  fmt='%1.0f', fontsize=12)
    if (includePMSL and met is not None):
        levels = arange(960.,1040.,1.)
        PMSL = met.variables['PMSL'][0]
        cs = plt.contour(x,y, PMSL/100.,levels,colors='black',label='Pressure')
        plt.clabel(cs, inline=1,  fmt='%1.0f', fontsize=11)

    heightground = (nc.variables['PH'][0][0,:,:] + nc.variables['PHB'][0][0,:,:])/g
    plt.contourf(x, y, heightground, levels=arange(0,max_h,100),cmap=cmap_grey,extend='max')
    plt.colorbar()
    if (nc1 is not None):
        _plotBorder(nc1,m,'black')
    plt.show()  
    plt.close()
Exemple #2
0
def mapTerrain(nest, includePMSL=False, includeTemp=False):
    """Creates a map of the domain, showing
    filled contours of the terrain
    """
    nc = openWRF(nest)
    met = openWPS(nest)
    nc1 = openWRF(nest + 1)
    _Nx, _Ny, _Nz, longitude, latitude, _dx, _dy, _x, _y = getDimensions(nc)

    m = _getMapForNC(nc, False, _getDL(nest), 100)
    x, y = m(longitude, latitude)
    _makeDots(m)

    if includeTemp and met is not None:
        ST = met.variables["TT"][0][0, :, :]
        cs = plt.contour(x, y, ST - T_zero, arange(-48, 50, 2.0), colors="blue", linestyles="solid")
        plt.clabel(cs, inline=1, fmt="%1.0f", fontsize=12)
    if includePMSL and met is not None:
        levels = arange(960.0, 1040.0, 1.0)
        PMSL = met.variables["PMSL"][0]
        cs = plt.contour(x, y, PMSL / 100.0, levels, colors="black", label="Pressure")
        plt.clabel(cs, inline=1, fmt="%1.0f", fontsize=11)

    heightground = (nc.variables["PH"][0][0, :, :] + nc.variables["PHB"][0][0, :, :]) / g
    plt.contourf(x, y, heightground, levels=arange(0, max_h, 100), cmap=cmap_grey, extend="max")
    plt.colorbar()
    if nc1 is not None:
        _plotBorder(nc1, m, "black")
    plt.show()
    plt.close()
Exemple #3
0
def mapCloud(nest, time):
    """Creates a map of the domain, showing
    filled contours of the cloud water
    """
    nc = openWRF(nest)
    _Nx, _Ny, _Nz, longitude, latitude, _dx, _dy, _x, _y = getDimensions(nc)

    m = _getMapForNC(nc, False, _getDL(nest), 100)
    x, y = m(longitude, latitude)

    qcloud = 1000.0 * np.sum(nc.variables["QCLOUD"][time, :, :, :], axis=0)
    plt.contourf(x, y, qcloud, cmap=cmap_red)
    plt.colorbar()
    plt.show()
    plt.close()
Exemple #4
0
def mapCloud(nest, time):
    """Creates a map of the domain, showing
    filled contours of the cloud water
    """
    nc = openWRF(nest)
    _Nx, _Ny, _Nz, longitude, latitude, _dx, _dy, _x, _y = getDimensions(nc)

    m = _getMapForNC(nc, False, _getDL(nest), 100)
    x, y = m(longitude, latitude)

    qcloud = 1000.0 * np.sum(nc.variables['QCLOUD'][time, :, :, :], axis=0)
    plt.contourf(x, y, qcloud, cmap=cmap_red)
    plt.colorbar()
    plt.show()
    plt.close()
Exemple #5
0
def mapTerrain(nest, includePMSL=False, includeTemp=False):
    """Creates a map of the domain, showing
    filled contours of the terrain
    """
    nc = openWRF(nest)
    met = openWPS(nest)
    nc1 = openWRF(nest + 1)
    _Nx, _Ny, _Nz, longitude, latitude, _dx, _dy, _x, _y = getDimensions(nc)

    m = _getMapForNC(nc, False, _getDL(nest), 100)
    x, y = m(longitude, latitude)
    _makeDots(m)

    if (includeTemp and met is not None):
        ST = met.variables['TT'][0][0, :, :]
        cs = plt.contour(x,
                         y,
                         ST - T_zero,
                         arange(-48, 50, 2.),
                         colors='blue',
                         linestyles='solid')
        plt.clabel(cs, inline=1, fmt='%1.0f', fontsize=12)
    if (includePMSL and met is not None):
        levels = arange(960., 1040., 1.)
        PMSL = met.variables['PMSL'][0]
        cs = plt.contour(x,
                         y,
                         PMSL / 100.,
                         levels,
                         colors='black',
                         label='Pressure')
        plt.clabel(cs, inline=1, fmt='%1.0f', fontsize=11)

    heightground = (nc.variables['PH'][0][0, :, :] +
                    nc.variables['PHB'][0][0, :, :]) / g
    plt.contourf(x,
                 y,
                 heightground,
                 levels=arange(0, max_h, 100),
                 cmap=cmap_grey,
                 extend='max')
    plt.colorbar()
    if (nc1 is not None):
        _plotBorder(nc1, m, 'black')
    plt.show()
    plt.close()
Exemple #6
0
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()        
Exemple #7
0
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()
Exemple #8
0
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()