Beispiel #1
0
def draw_vvel_high(uwind,
                   vwind,
                   wwind,
                   lon,
                   lat,
                   gh=None,
                   skip_vector=None,
                   map_region=None,
                   title_kwargs={},
                   outfile=None):
    """
    Draw high vertical velocity.

    Args:
        uwind (np.array): u wind component, 2D array, [nlat, nlon]
        vwind (np.array): v wind component, 2D array, [nlat, nlon]
        wwind (np.array): w wind component, 2D array, [nlat, nlon]
        lon (np.array): longitude, 1D array, [nlon]
        lat (np.array): latitude, 1D array, [nlat]
        gh (np.array): geopotential height, 2D array, [nlat, nlon]
        skip_vector (integer): skip grid number for vector plot
        map_region (list or tuple): the map region limit, [lonmin, lonmax, latmin, latmax]
        title_kwargs (dictionaly, optional): keyword arguments for _get_title function.
    """

    # check default parameters
    if skip_vector is None:
        skip_vector = util.get_skip_vector(lon, lat, map_region)

    # put data into fields
    wind_field = util.minput_2d_vector(uwind,
                                       vwind,
                                       lon,
                                       lat,
                                       skip=skip_vector)
    vvel_field = util.minput_2d(wwind, lon, lat, {
        'long_name': 'vertical velocity',
        'units': 'Pa/s'
    })
    if gh is not None:
        gh_feild = util.minput_2d(gh, lon, lat, {
            'long_name': 'height',
            'units': 'gpm'
        })

    #
    # set up visual parameters
    #
    plots = []

    # Setting the coordinates of the geographical area
    if map_region is None:
        china_map = map_set.get_mmap(name='CHINA_CYLINDRICAL',
                                     subpage_frame_thickness=5)
    else:
        china_map = map_set.get_mmap(name='CHINA_REGION_CYLINDRICAL',
                                     map_region=map_region,
                                     subpage_frame_thickness=5)
    plots.append(china_map)

    # Background Coaslines
    coastlines = map_set.get_mcoast(name='COAST_FILL')
    plots.append(coastlines)

    # Define the shading contour
    vvel_contour = magics.mcont(legend='on',
                                contour_level_selection_type='level_list',
                                contour_level_list=[
                                    -60, -30, -10, -5, -2.5, -1, -0.5, -0.2,
                                    0.2, 0.5, 1, 2.5, 5, 10, 30
                                ],
                                contour_shade='on',
                                contour="off",
                                contour_shade_method='area_fill',
                                contour_shade_colour_method='list',
                                contour_shade_colour_list=[
                                    '#9D0001', '#C90101', '#F10202', '#FF3333',
                                    '#FF8585', '#FFBABA', '#FEDDDD', '#FFFFFF',
                                    '#E1E1FF', '#BABAFF', '#8484FF', '#2C2CF7',
                                    '#0404F1', '#0101C8', '#020299'
                                ],
                                contour_reference_level=0,
                                contour_highlight='off',
                                contour_hilo='off',
                                contour_label='off')
    plots.extend([vvel_field, vvel_contour])

    # Define the wind vector
    wind_vector = common._get_wind_flags()
    plots.extend([wind_field, wind_vector])

    # Define the simple contouring for gh
    if gh is not None:
        gh_contour = common._get_gh_contour()
        plots.extend([gh_feild, gh_contour])

    # Add a legend
    legend = common._get_legend(china_map, title="Vertical Velocity [Pa/s]")
    plots.append(legend)

    # Add the title
    title_kwargs = check_kwargs(title_kwargs, 'head',
                                "700hPa Vertical Velocity | Wind | GH")
    title = common._get_title(**title_kwargs)
    plots.append(title)

    # Add china province
    china_coastlines = map_set.get_mcoast(name='PROVINCE')
    plots.append(china_coastlines)

    # final plot
    return util.magics_plot(plots, outfile)
Beispiel #2
0
def draw_wind_high(uwind,
                   vwind,
                   lon,
                   lat,
                   gh=None,
                   skip_vector=None,
                   map_region=None,
                   title_kwargs={},
                   outfile=None):
    """
    Draw high wind speed and flags.

    Args:
        uwind (np.array): u wind component, 2D array, [nlat, nlon]
        vwind (np.array): v wind component, 2D array, [nlat, nlon]
        lon (np.array): longitude, 1D array, [nlon]
        lat (np.array): latitude, 1D array, [nlat]
        gh (np.array): geopotential height, 2D array, [nlat, nlon]
        skip_vector (integer): skip grid number for vector plot
        map_region (list or tuple): the map region limit, [lonmin, lonmax, latmin, latmax]
        title_kwargs (dictionaly, optional): keyword arguments for _get_title function.
    """

    # check default parameters
    if skip_vector is None:
        skip_vector = util.get_skip_vector(lon, lat, map_region)

    # put data into fields
    wind_field = util.minput_2d_vector(uwind,
                                       vwind,
                                       lon,
                                       lat,
                                       skip=skip_vector)
    wspeed_field = util.minput_2d(np.sqrt(uwind * uwind + vwind * vwind), lon,
                                  lat, {
                                      'long_name': 'Wind Speed',
                                      'units': 'm/s'
                                  })
    if gh is not None:
        gh_field = util.minput_2d(gh, lon, lat, {
            'long_name': 'height',
            'units': 'gpm'
        })

    #
    # set up visual parameters
    #

    plots = []

    # Setting the coordinates of the geographical area
    if map_region is None:
        china_map = map_set.get_mmap(name='CHINA_CYLINDRICAL',
                                     subpage_frame_thickness=5)
    else:
        china_map = map_set.get_mmap(name='CHINA_REGION_CYLINDRICAL',
                                     map_region=map_region,
                                     subpage_frame_thickness=5)
    plots.append(china_map)

    # Background Coaslines
    coastlines = map_set.get_mcoast(name='COAST_FILL')
    plots.append(coastlines)

    # Define the shading for the wind speed
    wspeed_contour = magics.mcont(
        legend='on',
        contour_level_selection_type='interval',
        contour_shade_max_level=44.,
        contour_shade_min_level=8.,
        contour_interval=4.,
        contour_shade='on',
        contour="off",
        contour_shade_method='area_fill',
        contour_shade_colour_method='palette',
        contour_shade_palette_name='eccharts_rainbow_blue_purple_9',
        contour_reference_level=8.,
        contour_highlight='off',
        contour_hilo='hi',
        contour_hilo_format='(F3.0)',
        contour_hilo_height=0.6,
        contour_hilo_type='number',
        contour_hilo_window_size=10,
        contour_label='off')
    plots.extend([wspeed_field, wspeed_contour])

    # Define the wind vector
    wind_vector = common._get_wind_flags()
    plots.extend([wind_field, wind_vector])

    # Define the simple contouring for gh
    if gh is not None:
        gh_contour = common._get_gh_contour()
        plots.extend([gh_field, gh_contour])

    # Add a legend
    legend = common._get_legend(china_map, title="Wind Speed [m/s]")
    plots.append(legend)

    # Add the title
    title_kwargs = check_kwargs(title_kwargs, 'head',
                                "850hPa Wind | 500hPa GH")
    title = common._get_title(**title_kwargs)
    plots.append(title)

    # Add china province
    china_coastlines = map_set.get_mcoast(name='PROVINCE')
    plots.append(china_coastlines)

    # final plot
    return util.magics_plot(plots, outfile)
Beispiel #3
0
def draw_vort_high(uwind,
                   vwind,
                   lon,
                   lat,
                   vort=None,
                   gh=None,
                   skip_vector=None,
                   smooth_factor=1.0,
                   map_region=None,
                   title_kwargs={},
                   outfile=None):
    """
    Draw high vorticity.

    Args:
        uwind (np.array): u wind component, 2D array, [nlat, nlon]
        vwind (np.array): v wind component, 2D array, [nlat, nlon]
        lon (np.array): longitude, 1D array, [nlon]
        lat (np.array): latitude, 1D array, [nlat]
        vort (np.array, optional): vorticity component, 2D array, [nlat, nlon]
        gh (np.array): geopotential height, 2D array, [nlat, nlon]
        skip_vector (integer): skip grid number for vector plot
        smooth_factor (float): smooth factor for vorticity, larger for smoother.
        map_region (list or tuple): the map region limit, [lonmin, lonmax, latmin, latmax]
        title_kwargs (dictionaly, optional): keyword arguments for _get_title function.
    """

    # check default parameters
    if skip_vector is None:
        skip_vector = util.get_skip_vector(lon, lat, map_region)

    # put data into fields
    wind_field = util.minput_2d_vector(uwind,
                                       vwind,
                                       lon,
                                       lat,
                                       skip=skip_vector)
    if vort is None:
        dx, dy = calc.lat_lon_grid_deltas(lon, lat)
        vort = calc.vorticity(uwind * units.meter / units.second,
                              vwind * units.meter / units.second, dx, dy)
        vort = ndimage.gaussian_filter(vort, sigma=smooth_factor,
                                       order=0) * 10**5
    vort_field = util.minput_2d(vort, lon, lat, {
        'long_name': 'vorticity',
        'units': 's-1'
    })
    if gh is not None:
        gh_feild = util.minput_2d(gh, lon, lat, {
            'long_name': 'height',
            'units': 'gpm'
        })

    #
    # set up visual parameters
    #
    plots = []

    # Setting the coordinates of the geographical area
    if map_region is None:
        china_map = map_set.get_mmap(name='CHINA_CYLINDRICAL',
                                     subpage_frame_thickness=5)
    else:
        china_map = map_set.get_mmap(name='CHINA_REGION_CYLINDRICAL',
                                     map_region=map_region,
                                     subpage_frame_thickness=5)
    plots.append(china_map)

    # Background Coaslines
    coastlines = map_set.get_mcoast(name='COAST_FILL')
    plots.append(coastlines)

    # Define the shading contour
    vort_contour = magics.mcont(
        legend='on',
        contour_level_selection_type='level_list',
        contour_level_list=[
            -200.0, -100.0, -75.0, -50.0, -30.0, -20.0, -15.0, -13.0, -11.0,
            -9.0, -7.0, -5.0, -3.0, -1.0, 1.0, 3.0, 5.0, 7.0, 9.0, 11.0, 13.0,
            15.0, 20.0, 30.0, 50.0, 75.0, 100.0, 200.0
        ],
        contour_shade='on',
        contour="off",
        contour_shade_method='area_fill',
        contour_shade_colour_method='list',
        contour_shade_colour_list=[
            "rgb(0,0,0.3)", "rgb(0,0,0.5)", "rgb(0,0,0.7)", "rgb(0,0,0.9)",
            "rgb(0,0.15,1)", "rgb(0,0.3,1)", "rgb(0,0.45,1)", "rgb(0,0.6,1)",
            "rgb(0,0.75,1)", "rgb(0,0.85,1)", "rgb(0.2,0.95,1)",
            "rgb(0.45,1,1)", "rgb(0.75,1,1)", "none", "rgb(1,1,0)",
            "rgb(1,0.9,0)", "rgb(1,0.8,0)", "rgb(1,0.7,0)", "rgb(1,0.6,0)",
            "rgb(1,0.5,0)", "rgb(1,0.4,0)", "rgb(1,0.3,0)", "rgb(1,0.15,0)",
            "rgb(0.9,0,0)", "rgb(0.7,0,0)", "rgb(0.5,0,0)", "rgb(0.3,0,0)"
        ],
        contour_reference_level=8.,
        contour_highlight='off',
        contour_hilo='off',
        contour_label='off')
    plots.extend([vort_field, vort_contour])

    # Define the wind vector
    wind_vector = common._get_wind_flags()
    plots.extend([wind_field, wind_vector])

    # Define the simple contouring for gh
    if gh is not None:
        gh_contour = common._get_gh_contour()
        plots.extend([gh_feild, gh_contour])

    # Add a legend
    legend = common._get_legend(china_map, title="Vorticity [s^-1]")
    plots.append(legend)

    # Add the title
    title_kwargs = check_kwargs(title_kwargs, 'head',
                                "500hPa Relative vorticity | Wind | GH")
    title = common._get_title(**title_kwargs)
    plots.append(title)

    # Add china province
    china_coastlines = map_set.get_mcoast(name='PROVINCE')
    plots.append(china_coastlines)

    # final plot
    return util.magics_plot(plots, outfile)
Beispiel #4
0
def draw_rh_high(uwind,
                 vwind,
                 rh,
                 lon,
                 lat,
                 gh=None,
                 skip_vector=None,
                 map_region=None,
                 title_kwargs={},
                 outfile=None):
    """
    Draw high relative humidity.

    Args:
        uwind (np.array): u wind component, 2D array, [nlat, nlon]
        vwind (np.array): v wind component, 2D array, [nlat, nlon]
        rh (np.array): relative humidity wind component, 2D array, [nlat, nlon]
        lon (np.array): longitude, 1D array, [nlon]
        lat (np.array): latitude, 1D array, [nlat]
        gh (np.array): geopotential height, 2D array, [nlat, nlon]
        skip_vector (integer): skip grid number for vector plot
        map_region (list or tuple): the map region limit, [lonmin, lonmax, latmin, latmax]
        title_kwargs (dictionaly, optional): keyword arguments for _get_title function.
    """

    # check default parameters
    if skip_vector is None:
        skip_vector = util.get_skip_vector(lon, lat, map_region)

    # put data into fields
    wind_field = util.minput_2d_vector(uwind,
                                       vwind,
                                       lon,
                                       lat,
                                       skip=skip_vector)
    rh_field = util.minput_2d(rh, lon, lat, {
        'long_name': 'Relative Humidity',
        'units': '%'
    })
    gh_field = util.minput_2d(gh, lon, lat, {
        'long_name': 'height',
        'units': 'gpm'
    })

    #
    # set up visual parameters
    #

    plots = []

    # Setting the coordinates of the geographical area
    if map_region is None:
        china_map = map_set.get_mmap(name='CHINA_CYLINDRICAL',
                                     subpage_frame_thickness=5)
    else:
        china_map = map_set.get_mmap(name='CHINA_REGION_CYLINDRICAL',
                                     map_region=map_region,
                                     subpage_frame_thickness=5)
    plots.append(china_map)

    # Background Coaslines
    coastlines = map_set.get_mcoast(name='COAST_FILL')
    plots.append(coastlines)

    # Define the shading for the specific humidity
    rh_contour = magics.mcont(legend='on',
                              contour_level_selection_type='level_list',
                              contour_level_list=[
                                  0, 1., 5., 10, 20, 30, 40, 50, 60, 65, 70,
                                  75, 80, 85, 90, 99, 100.
                              ],
                              contour_shade='on',
                              contour="off",
                              contour_shade_method='area_fill',
                              contour_shade_colour_method='list',
                              contour_shade_colour_list=[
                                  '#644228', '#7f5330', '#9b6238', '#ab754b',
                                  '#b78a60', '#d0b494', '#decab2', '#e0dac8',
                                  '#bdcbab', '#adc59c', '#88bd89', '#6ba48d',
                                  '#506c93', '#4d6393', '#5c5692', '#6b4b92',
                                  '#7a3e94'
                              ],
                              contour_reference_level=60.,
                              contour_highlight='off',
                              contour_hilo='hi',
                              contour_hilo_format='(F3.0)',
                              contour_hilo_height=0.6,
                              contour_hilo_type='number',
                              contour_hilo_window_size=10,
                              contour_label='off')
    plots.extend([rh_field, rh_contour])

    # Define the wind vector
    wind_vector = common._get_wind_flags()
    plots.extend([wind_field, wind_vector])

    # Define the simple contouring for gh
    if gh is not None:
        gh_contour = common._get_gh_contour()
        plots.extend([gh_field, gh_contour])

    # Add a legend
    legend = common._get_legend(china_map, title="Relative Humidity[%]")
    plots.append(legend)

    # Add the title
    title_kwargs = check_kwargs(title_kwargs, 'head',
                                "Relative Humidity | Wind | 500hPa GH")
    title = common._get_title(**title_kwargs)
    plots.append(title)

    # Add china province
    china_coastlines = map_set.get_mcoast(name='PROVINCE')
    plots.append(china_coastlines)

    # final plot
    return util.magics_plot(plots, outfile)