Esempio n. 1
0
def test_plot():
    # Set up plotting info
    cmap_sic = matplotlib.colors.ListedColormap(sns.color_palette("Blues", 10))
    cmap_sic.set_bad(color='red')

    # Plot original projection
    plt.figure(figsize=(20, 10))
    ax1 = plt.axes(projection=ccrs.PlateCarree())
    ds_p = ds.sic.isel(init_time=0).isel(fore_time=0).isel(ensemble=0)
    ds_p.plot.pcolormesh(ax=ax1,
                         x='lon',
                         y='lat',
                         vmin=0,
                         vmax=1,
                         cmap=matplotlib.colors.ListedColormap(
                             sns.color_palette("Blues", 10)),
                         transform=ccrs.PlateCarree())
    ax1.set_extent([-180, 180, -90, 90], crs=ccrs.PlateCarree())
    gl = ax1.gridlines(crs=ccrs.PlateCarree(), linestyle='-')
    gl.xlabels_bottom = True
    gl.ylabels_left = True
    gl.xformatter = LONGITUDE_FORMATTER
    gl.yformatter = LATITUDE_FORMATTER
    ax1.coastlines(linewidth=0.75, color='black', resolution='50m')
    plt.title(model)

    # Plot SIC on target projection
    (f, ax1) = ice_plot.polar_axis()
    f.set_size_inches((10, 10))
    ds_p = ds.sic.isel(init_time=0).isel(fore_time=0).isel(ensemble=0)
    ds_p.plot.pcolormesh(ax=ax1,
                         x='lon',
                         y='lat',
                         transform=ccrs.PlateCarree(),
                         cmap=cmap_sic)
    ax1.set_title('Orginal Grid')

    # Plot SIC on target projection
    (f, ax1) = ice_plot.polar_axis()
    ds_p2 = var_out.isel(init_time=0).isel(fore_time=0).isel(ensemble=0)
    ds_p2.plot.pcolormesh(ax=ax1,
                          x='lon',
                          y='lat',
                          transform=ccrs.PlateCarree(),
                          cmap=cmap_sic)
    ax1.set_title('Target Grid')
Esempio n. 2
0
# Set up plotting info
cmap_reg = matplotlib.colors.ListedColormap(
    sns.color_palette("Paired", da_81reg.nregions.size))
cmap_reg_cycle = itertools.cycle(
    sns.color_palette("Paired", da_81reg.nregions.size))
cmap_reg.set_bad(color='lightgrey')
linecycler = itertools.cycle(["-", "--", "-.", ":", "--"])

# In[10]:

# Plot regional  map(s)
# Mask out other areas to missing
mask_plot = ds_region.where(ds_region.mask.isin(ds_region.ocean_regions))

(f, ax1) = ice_plot.polar_axis()
f.set_size_inches(10, 5)
p = mask_plot.mask.plot(ax=ax1,
                        x='lon',
                        y='lat',
                        transform=ccrs.PlateCarree(),
                        cmap=cmap_reg,
                        cbar_kwargs={
                            'label': '',
                            'ticks': ds_region.ocean_regions
                        })
#                                  'labels':mask_plot.region_names.sel(nregions=plot_regs)})
ax1.set_title('Regional Map')
plt.tight_layout()
cb = p.colorbar
# X = list(plot_regs.values)