Example #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 
Example #2
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 
Example #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(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