Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
# -------------------------------------------------------------------- #
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
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
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
# -------------------------------------------------------------------- #
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
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