示例#1
0
def plot_skin_temp(file_name, cntr_lvl=None, save_frames=False):
    file, vars = peek(file_name, show_vars=False)
    lon = vars['lon'].get_value()
    lat = vars['lat'].get_value()
    skin_temp = vars['skin_temp']
    skin_temp = skin_temp_var.get_value()[0]
    valid_date = str(vars['valid_date'].get_value()[0])
    valid_time = zfill(str(vars['valid_time'].get_value()[0]), 4)
    valid_when = valid_date[6:] + ' ' \
      + cardinal_2_month(int(valid_date[4:6])) + ' ' \
      + valid_date[0:4] \
      + ' ' + valid_time[:2] + ':' \
      + valid_time[2:] + ' UTC'
    m = set_default_basemap(lon,lat)
    # must plot using 2d lon and lat
    LON, LAT = p.meshgrid(lon,lat)
    p.figure()
    if cntr_lvl is not None:
        m.contourf(LON,LAT,skin_temp, cntr_lvl)
    else:
        m.contourf(LON,LAT,skin_temp)
    m.drawcoastlines()
    m.drawmeridians(n.array(n.arange(lon.min(), lon.max() + a_small_number, 15.)), labels=[1,0,0,1])
    m.drawparallels(n.array(n.arange(lat.min(), lat.max() + a_small_number, 15.)), labels=[1,0,0,1])
    p.colorbar(orientation='horizontal', shrink=0.7, fraction=0.02, pad=0.07, aspect=70)
    title_string = 'Surface pressure (K) valid at' \
      + '\n' + valid_when + ' ' \
      + ' from LAPS'
    p.title(title_string)
    if save_frames:
        p.savefig('frames/frame_' + zfill(str(frame_number),3) +'_skin_temp_' + str(int(lvl[lvl_idx])) + '.png')
    return 
示例#2
0
文件: gfs.py 项目: carlos9917/pywrf
def plot_soilw_from_gfs(file_name, cntr_lvl=None):
    file, vars = peek(file_name, show_vars=False)
    lon = vars['lon_3'].get_value()
    lat = vars['lat_3'].get_value()
    soilw_var = vars['SOILW_3_DBLY_10']
    soilw = soilw_var.get_value()
    soilw_m = ma.masked_where(soilw == soilw_var._FillValue, soilw)
    for lvl_idx in range(len(soilw)):
        p.figure()
        if cntr_lvl is not None:
            p.contourf(lon, lat, soilw_m[lvl_idx], cntr_lvl)
        else:
            p.contourf(lon, lat, soilw_m[lvl_idx])
        p.colorbar()
        # flip the y-axis
        p.ylim((lat[-1], lat[0]))
        p.ylabel('degrees North')
        p.xlabel('degrees East')
        lvl_bounds = vars['lv_DBLY5_l' + str(lvl_idx)]
        valid_when = soilw_var.initial_time
        valid_when = valid_when[3:5] + ' ' \
          + cardinal_2_month(int(valid_when[:2])) + ' ' + valid_when[6:10] \
          + ' ' + valid_when[12:17] + ' UTC'
        title_string = 'Volumetric soil moisture (fraction) valid at ' \
          + '\n' + valid_when + ' ' \
          + str(lvl_bounds[0]) + '-' + str(lvl_bounds[1]) + ' cm from GFS'
        p.title(title_string)
    return
示例#3
0
def plot_temp(file_name, cntr_lvl=None, save_frames=False):
    file, vars = peek(file_name, show_vars=False)
    lon = vars['lon'].get_value()
    lat = vars['lat'].get_value()
    air_temp_var = vars['air_temp']
    air_temp = air_temp_var.get_value()[0]
    lvl = vars['lvl'].get_value()
    valid_date = str(vars['valid_date'].get_value()[0])
    valid_time = zfill(str(vars['valid_time'].get_value()[0]), 4)
    valid_when = valid_date[6:] + ' ' \
      + cardinal_2_month(int(valid_date[4:6])) + ' ' \
      + valid_date[0:4] \
      + ' ' + valid_time[:2] + ':' \
      + valid_time[2:] + ' UTC'
    if save_frames:
        frame_number = 0
    m = set_default_basemap(lon, lat)
    # must plot using 2d lon and lat
    LON, LAT = p.meshgrid(lon, lat)
    for lvl_idx in range(5):
        #for lvl_idx in range(len(lvl)):
        p.figure()
        if cntr_lvl is not None:
            m.contourf(LON, LAT, air_temp[lvl_idx], cntr_lvl)
        else:
            m.contourf(LON, LAT, air_temp[lvl_idx])
        m.drawcoastlines()
        m.drawmeridians(n.array(
            n.arange(lon.min(),
                     lon.max() + a_small_number, 15.)),
                        labels=[1, 0, 0, 1])
        m.drawparallels(n.array(
            n.arange(lat.min(),
                     lat.max() + a_small_number, 15.)),
                        labels=[1, 0, 0, 1])
        p.colorbar(orientation='horizontal',
                   shrink=0.7,
                   fraction=0.02,
                   pad=0.07,
                   aspect=50)
        title_string = 'Air temperature (K) valid at ' \
          + '\n' + valid_when + ' ' \
          + str(round(lvl[lvl_idx],4)) + ' sigma' \
          + ' from LAPS'
        p.title(title_string)
        if save_frames:
            p.savefig('frames/frame_' + zfill(str(frame_number), 3) +
                      '_air_temp_' + str(lvl[lvl_idx]) + '_sigma.png')
            frame_number += 1
    return
示例#4
0
def plot_soilw(file_name, cntr_lvl=None):
    file, vars = peek(file_name, show_vars=False)
    lon = vars['lon'].get_value()
    lat = vars['lat'].get_value()
    soilw_var = vars['soil_mois']
    soilw = soilw_var.get_value()[0]
    mask = n.zeros(soilw.shape, dtype=int)
    for lvl_idx in range(len(soilw)):
        mask[lvl_idx] = vars['sea_lnd_ice_mask'].get_value()
    soilw_m = ma.masked_where(mask == 0 , soilw)
    lvl_bounds = vars['soil_lvl'].get_value()
    valid_date = str(vars['valid_date'].get_value()[0])
    valid_time = zfill(str(vars['valid_time'].get_value()[0]), 4)
    valid_when = valid_date[6:] + ' ' \
      + cardinal_2_month(int(valid_date[4:6])) + ' ' \
      + valid_date[0:4] \
      + ' ' + valid_time[:2] + ':' \
      + valid_time[2:] + ' UTC'
    m = set_default_basemap(lon,lat)
    # must plot using 2d lon and lat
    LON, LAT = p.meshgrid(lon,lat)
    #for lvl_idx in range(1):
    for lvl_idx in range(len(soilw)):
        p.figure()
        if cntr_lvl is not None:
            # let's not forget the scaling by the layer depth
            m.contourf(LON,LAT,soilw_m[lvl_idx]/lvl_bounds[lvl_idx], cntr_lvl)
        else:
            # let's not forget the scaling by the layer depth
            m.contourf(LON,LAT,soilw_m[lvl_idx]/lvl_bounds[lvl_idx])
        m.drawcoastlines()
        m.drawmeridians(n.array(n.arange(lon.min(), lon.max() + a_small_number, 15.)), labels=[1,0,0,1])
        m.drawparallels(n.array(n.arange(lat.min(), lat.max() + a_small_number, 15.)), labels=[1,0,0,1])
        p.colorbar(orientation='horizontal', shrink=0.7, fraction=0.02, pad=0.07, aspect=50)
        if lvl_idx == 0:
            title_string = 'Volumetric soil moisture (fraction) valid at ' \
              + '\n' + valid_when + ' ' \
              + '0' \
              + '-' + str(int(round(lvl_bounds[lvl_idx]*100))) + ' cm' \
              + ' from LAPS'
        else:
            title_string = 'Volumetric soil moisture (fraction) valid at ' \
              + '\n' + valid_when + ' ' \
              + str(int(round(lvl_bounds[lvl_idx-1]*100))) \
              + '-' + str(int(round(lvl_bounds[lvl_idx]*100))) + ' cm' \
              + ' from LAPS'
        p.title(title_string)
    return 
示例#5
0
文件: laps_press.py 项目: Joz84/pywrf
def plot_temp(file_name, cntr_lvl=None, save_frames=False):
    file, vars = peek(file_name, show_vars=False)
    lon = vars['lon'].get_value()
    lat = vars['lat'].get_value()
    air_temp_var = vars['air_temp']
    air_temp = air_temp_var.get_value()[0]
    lvl = vars['lvl'].get_value()
    valid_date = str(vars['valid_date'].get_value()[0])
    valid_time = zfill(str(vars['valid_time'].get_value()[0]), 4)
    valid_when = valid_date[6:] + ' ' \
      + cardinal_2_month(int(valid_date[4:6])) + ' ' \
      + valid_date[0:4] \
      + ' ' + valid_time[:2] + ':' \
      + valid_time[2:] + ' UTC'
    if save_frames:
        frame_number = 0
    m = set_default_basemap(lon,lat)
    # must plot using 2d lon and lat
    LON, LAT = p.meshgrid(lon,lat)
    #for lvl_idx in range(1):
    for lvl_idx in range(len(lvl)):
        p.figure()
        if cntr_lvl is not None:
            #p.contourf(lon,lat,air_temp_m[lvl_idx], cntr_lvl)
            #p.contourf(lon,lat,air_temp[lvl_idx], cntr_lvl)
            m.contourf(LON,LAT,air_temp[lvl_idx], cntr_lvl)
        else:
            #p.contourf(lon,lat,air_temp_m[lvl_idx])
            #p.contourf(lon,lat,air_temp[lvl_idx])
            m.contourf(LON,LAT,air_temp[lvl_idx])
        m.drawcoastlines()
        m.drawmeridians(n.array(n.arange(lon.min(), lon.max() + a_small_number, 15.)), labels=[1,0,0,1])
        m.drawparallels(n.array(n.arange(lat.min(), lat.max() + a_small_number, 15.)), labels=[1,0,0,1])
        p.colorbar(orientation='horizontal', shrink=0.7, fraction=0.02, pad=0.07, aspect=50)
        title_string = 'Air temperature (K) valid at ' \
          + '\n' + valid_when + ' ' \
          + str(int(round(lvl[lvl_idx]))) + ' mb' \
          + ' from LAPS'
        p.title(title_string)
        if save_frames:
            p.savefig('frames/frame_' + zfill(str(frame_number),3) +'_air_temp_' + str(int(lvl[lvl_idx])) + '_mb.png')
            frame_number += 1
    return 
示例#6
0
文件: gfs.py 项目: carlos9917/pywrf
def plot_soilw_from_gfs(file_name, cntr_lvl=None):
    file, vars = peek(file_name, show_vars=False)
    lon = vars["lon_3"].get_value()
    lat = vars["lat_3"].get_value()
    soilw_var = vars["SOILW_3_DBLY_10"]
    soilw = soilw_var.get_value()
    soilw_m = ma.masked_where(soilw == soilw_var._FillValue, soilw)
    for lvl_idx in range(len(soilw)):
        p.figure()
        if cntr_lvl is not None:
            p.contourf(lon, lat, soilw_m[lvl_idx], cntr_lvl)
        else:
            p.contourf(lon, lat, soilw_m[lvl_idx])
        p.colorbar()
        # flip the y-axis
        p.ylim((lat[-1], lat[0]))
        p.ylabel("degrees North")
        p.xlabel("degrees East")
        lvl_bounds = vars["lv_DBLY5_l" + str(lvl_idx)]
        valid_when = soilw_var.initial_time
        valid_when = (
            valid_when[3:5]
            + " "
            + cardinal_2_month(int(valid_when[:2]))
            + " "
            + valid_when[6:10]
            + " "
            + valid_when[12:17]
            + " UTC"
        )
        title_string = (
            "Volumetric soil moisture (fraction) valid at "
            + "\n"
            + valid_when
            + " "
            + str(lvl_bounds[0])
            + "-"
            + str(lvl_bounds[1])
            + " cm from GFS"
        )
        p.title(title_string)
    return
示例#7
0
def plot_mr(file_name, cntr_lvl=None, save_frames=False):
    file, vars = peek(file_name, show_vars=False)
    lon = vars['lon'].get_value()
    lat = vars['lat'].get_value()
    mr_var = vars['mix_rto']
    # to change between kg/kg to g/kg
    mr = mr_var.get_value()[0]*1000.
    lvl = vars['lvl'].get_value()
    valid_date = str(vars['valid_date'].get_value()[0])
    valid_time = zfill(str(vars['valid_time'].get_value()[0]), 4)
    valid_when = valid_date[6:] + ' ' \
      + cardinal_2_month(int(valid_date[4:6])) + ' ' \
      + valid_date[0:4] \
      + ' ' + valid_time[:2] + ':' \
      + valid_time[2:] + ' UTC'
    if save_frames:
        frame_number = 0
    m = set_default_basemap(lon,lat)
    # must plot using 2d lon and lat
    LON, LAT = p.meshgrid(lon,lat)
    #for lvl_idx in range(2):
    for lvl_idx in range(len(lvl)):
        p.figure()
        if cntr_lvl is not None:
            m.contourf(LON,LAT,mr[lvl_idx], cntr_lvl)
        else:
            m.contourf(LON,LAT,mr[lvl_idx])
        m.drawcoastlines()
        m.drawmeridians(n.array(n.arange(lon.min(), lon.max() + a_small_number, 15.)), labels=[1,0,0,1])
        m.drawparallels(n.array(n.arange(lat.min(), lat.max() + a_small_number, 15.)), labels=[1,0,0,1])
        p.colorbar(orientation='horizontal', shrink=0.7, fraction=0.02, pad=0.07, aspect=50)
        title_string = 'Mixing ration (g/kg)' \
          + '\n' + valid_when + ' ' \
          + str(int(round(lvl[lvl_idx]))) + ' mb' \
          + ' from LAPS'
        p.title(title_string)
        if save_frames:
            p.savefig('frames/frame_' + zfill(str(frame_number),3) +'_mr_' + str(int(lvl[lvl_idx])) + '_mb.png')
            frame_number += 1
    return