コード例 #1
0
def my_plot9(lons, lats, d1, d2, units=None,
             vmin=None, vmax=None, amin=None,
             amax=None, mask=True, amap=None,
             t1='', t2='', cmap=None):
    """ 9 pannel plot to compare soil layers for two different datasets"""
    if vmin is None:
        vmin = d1.min()
    if vmax is None:
        vmax = d1.max()

    anom = d1 - d2
    if amin is None:
        amin = -1 * np.max(np.abs(anom))
    if amax is None:
        amax = np.max(np.abs(anom))

    if cmap is None:
        cmap = cmap_discretize('cm.winter')

    if amap is None:
        amap = cmap_discretize('cm.RdBu')

    f, axarr = plt.subplots(3, 3, figsize=(13.5, 9), dpi=150)
    f.tight_layout()

    for layer in pyrange(3):
        plt.sca(axarr[layer, 0])
        sub_plot_pcolor(lons, lats, np.ma.masked_where(mask, d1[layer]),
                        vmin=vmin, vmax=vmax, units=units,
                        ncolors=9, title='{} (A)'.format(t1),
                        cmap=cmap, cbar_location='right',)
        plt.ylabel('Layer {}'.format(layer))
        plt.sca(axarr[layer, 1])
        sub_plot_pcolor(lons, lats, np.ma.masked_where(mask, d2[layer]),
                        vmin=vmin, vmax=vmax,
                        ncolors=9, title='{} (B)'.format(t2), units=units,
                        cbar_location='right', cmap=cmap)
        plt.sca(axarr[layer, 2])

        sub_plot_pcolor(lons, lats, np.ma.masked_where(mask, anom[layer]),
                        ncolors=9, cmap=amap,
                        title='Difference (A-B)', units=units,
                        cbar_location='right', vmin=amin, vmax=amax)
    return f
コード例 #2
0
def my_plot3(lons, lats, d1, d2, units=None,
             vmin=None, vmax=None, amin=None,
             amax=None, mask=True, amap=None,
             t1='', t2='', cmap=None):
    """ 3 pannel plot to compare two different datasets"""
    if vmin is None:
        vmin = d1.min()
    if vmax is None:
        vmax = d1.max()

    if not cmap:
        cmap = cmap_discretize('cm.winter')

    if not amap:
        amap = cmap_discretize('cm.RdBu')

    d1 = np.ma.masked_where(mask, d1)
    d2 = np.ma.masked_where(mask, d2)

    anom = d1 - d2

    if amin is None:
        amin = -1 * np.max(np.abs(anom))
    if amax is None:
        amax = np.max(np.abs(anom))

    f, axarr = plt.subplots(1, 3, figsize=(13.5, 4), dpi=150)
    f.tight_layout()

    plt.sca(axarr[0])
    sub_plot_pcolor(lons, lats, d1, vmin=vmin, vmax=vmax, ncolors=9,
                    title='{} (A)'.format(t1), cmap=cmap, units=units,
                    cbar_location='right')
    plt.sca(axarr[1])
    sub_plot_pcolor(lons, lats, d2, vmin=vmin, vmax=vmax, ncolors=9,
                    title='{} (B)'.format(t2), units=units,
                    cbar_location='right', cmap=cmap)
    plt.sca(axarr[2])
    sub_plot_pcolor(lons, lats, anom, ncolors=9, cmap=amap,
                    title='Difference (A-B)', units=units,
                    cbar_location='right', vmin=amin, vmax=amax)
    return f