Exemple #1
0
def animate_double(ii, ax1, ax2):
    i = iys[ii]

    year = anni[i]
    #print(year)
    color = cset[i]
    tam = tahiss[i] - pimean['tas']
    tit = r'{} $\to$ {:+5.1f} $^\circ$C wrt PI'.format(year, tam)
    fig.suptitle(tit)

    proj = ccrs.PlateCarree()
    ax1.clear()
    ax2.clear()
    map_plot1 = ctl.plot_mapc_on_ax(ax1,
                                    costas[i, ...],
                                    presme.lat,
                                    presme.lon,
                                    proj,
                                    cmappas[0],
                                    cbrangs[0],
                                    draw_grid=True)
    map_plot2 = ctl.plot_mapc_on_ax(ax2,
                                    cospr[i, ...],
                                    presme.lat,
                                    presme.lon,
                                    proj,
                                    cmappas[1],
                                    cbrangs[1],
                                    draw_grid=True)

    return
Exemple #2
0
def animate_rotate(ii):
    i = iys[ii]
    clon = clons[ii]
    proj = ctl.def_projection('nearside', (clat, clon), bounding_lat=blat)
    fig.clear()
    ax = plt.subplot(projection=proj)
    ax.set_global()
    ax.coastlines(linewidth=1)

    pc = ccrs.PlateCarree()
    map_plot = ctl.plot_mapc_on_ax(ax,
                                   cosoanom[i, ...],
                                   presme.lat,
                                   presme.lon,
                                   pc,
                                   cmappa,
                                   cbar_range,
                                   draw_grid=True)
    year = anni[i]
    #print(year)
    color = cset[i]
    tam = tahiss[i] - pimean['tas']

    ax.set_title(r'{} $\to$ {:+5.1f} $^\circ$C wrt PI'.format(year, tam))

    ## Colorbar
    cax = plt.axes([0.1, 0.11, 0.8, 0.05])  #horizontal
    cb = plt.colorbar(map_plot, cax=cax,
                      orientation='horizontal')  #, labelsize=18)
    cb.ax.tick_params(labelsize=14)
    if var == 'tas':
        cb.set_label('Temperature anomaly wrt 1960-1990 (K)', fontsize=14)
    elif var == 'pr':
        cb.set_label('Precipitation anomaly wrt 1960-1990 (mm/yr)',
                     fontsize=14)

    top = 0.88  # the top of the subplots
    bottom = 0.20  # the bottom of the subplots
    left = 0.02  # the left side
    right = 0.98  # the right side
    hspace = 0.20  # height reserved for white space
    wspace = 0.05  # width reserved for blank space
    plt.subplots_adjust(left=left,
                        bottom=bottom,
                        right=right,
                        top=top,
                        wspace=wspace,
                        hspace=hspace)

    return
def animate(i):
    proj = ccrs.PlateCarree()
    #proj = ccrs.Orthographic(central_longitude=lonstep*i, central_latitude=30.)
    ax = plt.subplot(projection=proj)
    ax.clear()
    map_plot = ctl.plot_mapc_on_ax(ax, yearly_anom[i], lat, lon, proj, cmappa,
                                   cbar_range)
    year = anni[i]
    color = cset[i]
    tit.set_text('{}'.format(year))
    #showdate.set_text('{}'.format(year))#, color = color)
    #showdate.update(color = color)
    ax.relim()
    ax.autoscale_view()
    return
Exemple #4
0
def animate(ii, ax, plot_margins=None):
    i = iys[ii]
    proj = ccrs.PlateCarree()
    ax.clear()
    map_plot = ctl.plot_mapc_on_ax(ax,
                                   cosoanom[i, ...],
                                   presme.lat,
                                   presme.lon,
                                   proj,
                                   cmappa,
                                   cbar_range,
                                   draw_grid=True,
                                   plot_margins=plot_margins)
    year = anni[i]
    #print(year)
    color = cset[i]
    tam = tahiss[i] - pimean['tas']
    ax.set_title(r'{} $\to$ {:+5.1f} $^\circ$C wrt PI'.format(year, tam))
    return
Exemple #5
0
        cosdue[var] = cosoanom

        #####
        print('flat global {} {}'.format(var, ssp))

        fig, ax = ctl.get_cartopy_fig_ax(visualization='standard',
                                         central_lat_lon=(0, 0),
                                         bounding_lat=None,
                                         figsize=(16, 9),
                                         coast_lw=1)
        #tit = plt.title('1850')

        # Plotting figure
        proj = ccrs.PlateCarree()
        map_plot = ctl.plot_mapc_on_ax(ax, cosoanom[0], presme.lat, presme.lon,
                                       proj, cmappa, cbar_range)

        cax = plt.axes([0.1, 0.11, 0.8, 0.05])  #horizontal
        cb = plt.colorbar(map_plot, cax=cax,
                          orientation='horizontal')  #, labelsize=18)
        cb.ax.tick_params(labelsize=14)
        if var == 'tas':
            cb.set_label('Temperature anomaly wrt 1960-1990 (K)', fontsize=14)
        elif var == 'pr':
            #cb.set_label('Relative precipitation anomaly wrt 1960-1990 (mm/yr)', fontsize=14)
            cb.set_label('Precipitation anomaly wrt 1960-1990 (mm/yr)',
                         fontsize=14)

        top = 0.88  # the top of the subplots
        bottom = 0.20  # the bottom of the subplots
        left = 0.02  # the left side
    ax = plt.subplot(projection=proj)
    ax.clear()
    map_plot = ctl.plot_mapc_on_ax(ax, yearly_anom[i], lat, lon, proj, cmappa,
                                   cbar_range)
    year = anni[i]
    color = cset[i]
    tit.set_text('{}'.format(year))
    #showdate.set_text('{}'.format(year))#, color = color)
    #showdate.update(color = color)
    ax.relim()
    ax.autoscale_view()
    return


# Plotting figure
map_plot = ctl.plot_mapc_on_ax(ax, yearly_anom[0], lat, lon, proj, cmappa,
                               cbar_range)

cax = plt.axes([0.1, 0.11, 0.8, 0.05])  #horizontal
cb = plt.colorbar(map_plot, cax=cax,
                  orientation='horizontal')  #, labelsize=18)
cb.ax.tick_params(labelsize=14)
cb.set_label('Temp anomaly (K)', fontsize=16)

top = 0.88  # the top of the subplots
bottom = 0.20  # the bottom of the subplots
left = 0.02  # the left side
right = 0.98  # the right side
hspace = 0.20  # height reserved for white space
wspace = 0.05  # width reserved for blank space
plt.subplots_adjust(left=left,
                    bottom=bottom,
Exemple #7
0
        coso.values[~np.isnan(coso)] = 1
        coso.values[np.isnan(coso)] = 0
        monreg[(ru, iiy)] = coso

#### Figurez
# only stab
fig, ax = ctl.get_cartopy_fig_ax(coast_lw=0.1)
proj = ccrs.PlateCarree()

for ru, col in zip(allru, colors):
    coso = monreg[(ru, 'stab')]
    ctl.plot_mapc_on_ax(ax,
                        coso.values,
                        coso.lat.values,
                        coso.lon.values,
                        proj,
                        None, (0, 1),
                        plot_type='binary_contour',
                        lw_contour=2.,
                        line_color=col)

ctl.custom_legend(fig, colors, allru, ncol=4)
fig.savefig(cart_out + 'monsoon_stab.pdf')

cosi = [mpi[(ru, 'stab')] for ru in allru]
for co in cosi:
    co.values[co < 0.5] = np.nan

ctl.plot_multimap_contour(cosi,
                          filename=cart_out + 'monsoon_all.pdf',
                          cbar_range=(0.5, 1.),
Exemple #8
0
# Shade from the northwest, with the sun 45 degrees from horizontal
ls = LightSource(azdeg=315, altdeg=45)

hillsh = ls.hillshade(elev, vert_exag=100, dx=10000, dy=10000)
ax.pcolormesh(lon,
              lat,
              hillsh,
              cmap='gray',
              transform=ccrs.PlateCarree(),
              alpha=1.0)

map = ctl.plot_mapc_on_ax(ax,
                          elev,
                          lat,
                          lon,
                          proj,
                          cmappa,
                          cbar_range,
                          clevels=clevels,
                          draw_grid=True,
                          alphamap=0.7)
#cb = plt.colorbar(map, orientation='horizontal')

# #### N/S Polar
proj = ctl.def_projection('nearside', (88, 0), bounding_lat=0)
fig2 = plt.figure(figsize=(32, 24))
ax2 = plt.subplot(projection=proj)
ax2.set_global()
ax2.coastlines(linewidth=2)

ax2.pcolormesh(lon,
               lat,
        #mod_anoms, varmean, varstd = all_res[var]
        stpl_mask = dict()
        for ke in varanom:
            stpl_mask[ke] = np.zeros(varanom[ke].shape)
            oksig = abs(varanom[ke]) > 2*varstd[ke]
            stpl_mask[ke][oksig] = 1

            oksig = abs(varanom[ke]) < varstd[ke]
            stpl_mask[ke][oksig] = -1

        fig = plt.figure(figsize = (16, 12))

        seas = 'JJA'
        ax = fig.add_subplot(221, projection = proj)
        data = varanom[seas]
        map_plot = ctl.plot_mapc_on_ax(ax, data, lat, lon, proj, cmappa, cbar_ranges[var], n_color_levels = len(paletta[var])-1, add_hatching = stpl_mask[seas], hatch_styles = ['///', '', '...'], hatch_levels = [-1.5, -0.5, 0.5, 1.5], colors = paletta[var], clevels = clevels[var])
        ax.set_title(r'$\Delta$ Temperature {}'.format(seas))

        ax = fig.add_subplot(222, projection = proj)
        data = varstd[seas]
        map_plot = ctl.plot_mapc_on_ax(ax, data, lat, lon, proj, cmappa, cbar_ranges[var], n_color_levels = len(paletta[var])-1, colors = paletta[var], clevels = clevels[var])
        ax.set_title(r'$\sigma$ Temperature {}'.format(seas))

        seas = 'DJF'
        ax = fig.add_subplot(223, projection = proj)
        data = varanom[seas]
        map_plot = ctl.plot_mapc_on_ax(ax, data, lat, lon, proj, cmappa, cbar_ranges[var], n_color_levels = len(paletta[var])-1, add_hatching = stpl_mask[seas], colors = paletta[var], hatch_styles = ['///', '', '...'], hatch_levels = [-1.5, -0.5, 0.5, 1.5], clevels = clevels[var])
        ax.set_title(r'$\Delta$ Temperature {}'.format(seas))

        ax = fig.add_subplot(224, projection = proj)
        data = varstd[seas]