def main():
    """In the main function we basically read the files and prepare the variables to be plotted.
    This is not included in utils.py as it can change from case to case."""
    dset = read_dataset(variables=['T', 'FI'], level=[5000],
                        projection=projection, remapped=True)

    levels_temp = np.arange(-86, -18, 1)
    levels_gph = np.arange(19700., 20500., 250.)

    cmap = get_colormap('temp_meteociel')

    _ = plt.figure(figsize=(figsize_x, figsize_y))
    ax = plt.gca()
    _, x, y, mask = get_projection(dset, projection, remapped=True)
    # Subset dataset only on the area
    dset = dset.where(mask, drop=True)
    # and then compute what we need
    dset = compute_geopot_height(dset, zvar='z')
    dset = dset.drop(['z', 'lon', 'lat']).squeeze().load()

    # All the arguments that need to be passed to the plotting function
    args=dict(x=x, y=y, ax=ax,
             levels_temp=levels_temp, cmap=cmap,
             levels_gph=levels_gph)

    print_message('Pre-processing finished, launching plotting scripts')
    if debug:
        plot_files(dset.isel(time=slice(-2, -1)), **args)
    else:
        # Parallelize the plotting by dividing into chunks and processes
        dss = chunks_dataset(dset, chunks_size)
        plot_files_param = partial(plot_files, **args)
        p = Pool(processes)
        p.map(plot_files_param, dss)
Esempio n. 2
0
def main():
    """In the main function we basically read the files and prepare the variables to be plotted.
    This is not included in utils.py as it can change from case to case."""
    dset = read_dataset(variables=['t', 'fi'],
                        level=[l * 100 for l in levels],
                        projection=projection)
    dset = compute_geopot_height(dset)
    cmap = get_colormap('temp')

    for level in levels:
        dset_level = dset.sel(plev=level * 100., method='nearest')
        dset_level.t.metpy.convert_units('degC')
        levels_gph = np.arange(
            np.nanmin(dset_level.geop).astype("int"),
            np.nanmax(dset_level.geop).astype("int"), 25.)
        levels_temp = np.arange(
            np.nanmin(dset_level.t).astype("int"),
            np.nanmax(dset_level.t).astype("int"), 1.)

        _ = plt.figure(figsize=(figsize_x, figsize_y))

        ax = plt.gca()
        # Get coordinates from dataset
        m, x, y = get_projection(dset_level, projection, labels=True)
        dset_level = dset_level.drop(['lon', 'lat', 'z']).load()

        # All the arguments that need to be passed to the plotting function
        args = dict(x=x,
                    y=y,
                    ax=ax,
                    cmap=cmap,
                    level=level,
                    levels_temp=levels_temp,
                    levels_gph=levels_gph,
                    time=dset_level.time,
                    projection=projection)

        print_message('Pre-processing finished, launching plotting scripts')
        if debug:
            plot_files(dset_level.isel(time=slice(0, 2)), **args)
        else:
            # Parallelize the plotting by dividing into chunks and processes
            dss = chunks_dataset(dset_level, chunks_size)
            plot_files_param = partial(plot_files, **args)
            p = Pool(processes)
            p.map(plot_files_param, dss)
Esempio n. 3
0
def main():
    """In the main function we basically read the files and prepare the variables to be plotted.
    This is not included in utils.py as it can change from case to case."""
    dset = read_dataset(variables=['U', 'V', 'FI'],
                        level=30000,
                        projection=projection,
                        remapped=True)

    # Select 850 hPa level using metpy
    levels_wind = np.arange(80., 300., 10.)
    levels_gph = np.arange(8200., 9700., 100.)
    cmap = truncate_colormap(plt.get_cmap('CMRmap_r'), 0., 0.9)

    _ = plt.figure(figsize=(figsize_x, figsize_y))
    ax = plt.gca()
    m, x, y, mask = get_projection(dset, projection, remapped=True)
    m.fillcontinents(color='lightgray', lake_color='whitesmoke', zorder=0)
    # Subset dataset only on the area
    dset = dset.where(mask, drop=True)
    dset = compute_wind_speed(dset)
    dset = compute_geopot_height(dset)

    dset = dset.drop(['z', 'u', 'v']).load()

    # All the arguments that need to be passed to the plotting function
    args = dict(x=x,
                y=y,
                ax=ax,
                levels_wind=levels_wind,
                levels_gph=levels_gph,
                time=dset.time,
                cmap=cmap)

    print_message(sys.argv[0] +
                  ': Pre-processing finished, launching plotting scripts')
    if debug:
        plot_files(dset.isel(time=slice(0, 2)), **args)
    else:
        # Parallelize the plotting by dividing into chunks and processes
        dss = chunks_dataset(dset, chunks_size)
        plot_files_param = partial(plot_files, **args)
        p = Pool(processes)
        p.map(plot_files_param, dss)
Esempio n. 4
0
def main():
    """In the main function we basically read the files and prepare the variables to be plotted.
    This is not included in utils.py as it can change from case to case."""
    dset = read_dataset(variables=['t', 'fi'],
                        level=[50000, 85000],
                        projection=projection)

    dset = compute_geopot_height(dset, zvar='z', level=50000)
    dset = dset.sel(plev=50000, method='nearest')

    levels_temp = np.arange(-58, 12, 2)
    levels_gph = np.arange(4700., 6000., 70.)

    cmap = get_colormap('temp_meteociel')

    _ = plt.figure(figsize=(figsize_x, figsize_y))

    ax = plt.gca()
    # Get coordinates from dataset
    m, x, y = get_projection(dset, projection, labels=True)

    dset = dset.drop(['lon', 'lat', 'z']).load()

    # All the arguments that need to be passed to the plotting function
    args = dict(x=x,
                y=y,
                ax=ax,
                cmap=cmap,
                levels_temp=levels_temp,
                levels_gph=levels_gph,
                time=dset.time)

    print_message('Pre-processing finished, launching plotting scripts')
    if debug:
        plot_files(dset.isel(time=slice(0, 2)), **args)
    else:
        # Parallelize the plotting by dividing into chunks and processes
        dss = chunks_dataset(dset, chunks_size)
        plot_files_param = partial(plot_files, **args)
        p = Pool(processes)
        p.map(plot_files_param, dss)
Esempio n. 5
0
def main():
    """In the main function we basically read the files and prepare the variables to be plotted.
    This is not included in utils.py as it can change from case to case."""
    dset = read_dataset(variables=['fi', 'pmsl'], level=[50000],
                        projection=projection)

    dset = compute_geopot_height(dset, zvar='z', level=50000)
    dset['prmsl'].metpy.convert_units('hPa')

    levels_gph = np.arange(5000., 6000., 40.)

    cmap = get_colormap('gph')
    #cmap = truncate_colormap(cmap, 0.05, 0.9)

    _ = plt.figure(figsize=(figsize_x, figsize_y))

    ax  = plt.gca()
    # Get coordinates from dataset
    m, x, y = get_projection(dset, projection, labels=True)

    dset = dset.drop(['lon', 'lat', 'z']).load()

    levels_mslp = np.arange(dset['prmsl'].min().astype("int"),
                            dset['prmsl'].max().astype("int"), 4.)

    # All the arguments that need to be passed to the plotting function
    args = dict(x=x, y=y, ax=ax, cmap=cmap,
                levels_gph=levels_gph,
                levels_mslp=levels_mslp)

    print_message('Pre-processing finished, launching plotting scripts')
    if debug:
        plot_files(dset.isel(time=slice(0, 2)), **args)
    else:
        # Parallelize the plotting by dividing into chunks and processes 
        dss = chunks_dataset(dset, chunks_size)
        plot_files_param = partial(plot_files, **args)
        p = Pool(processes)
        p.map(plot_files_param, dss)