In [1]:
from ahh import vis, exp, ext
import numpy as np
import matplotlib.pyplot as plt
import os

In [2]:
OUTPUT_DIR = 'output'
SAVE_FMT = 'plot_{pltype}_{testname}_dt.png'

def join_out(pltype, testname):
    return os.path.join(OUTPUT_DIR,
                        SAVE_FMT.format(pltype=pltype,
                                        testname=testname))

In [3]:
ds = exp.arr_ds()['air']
ds_clim = ds.groupby('time.month').mean()
ds_anom = ds.groupby('time.month') - ds_clim
ext.ahh(ds)


            Name: air
          Length: 366
      Dimensions: (366, 73, 144)
   Unnested Type: <class 'numpy.float64'>
Overarching Type: <class 'numpy.ndarray'>
Minimum, Maximum: 188.290, 315.300
 Average, Median: 277.191, 282.670

Snippet of values:
[ 238.1  238.1  238.1  238.1  238.1 ...,  238.1  238.1  238.1  238.1  238.1]

Out[3]:
True

In [4]:
testname = 'subplot'

vis_dict = dict(close=False, rows=2, cols=2, figsize='na')
vis.set_figsize(16, 9)
vis.plot_map(ds_anom.isel(time=18),
             title=testname, cmap='BlueWhiteOrangeRed',
             save=join_out('map', testname), **vis_dict)
vis.plot_map(ds_anom.isel(time=26), contourf=False,
             title=testname, cmap='RdBu_r', pos=2,
             save=join_out('map', testname), **vis_dict)
vis.plot_map(ds_anom.isel(time=124), contourf=False,
             title=testname, cmap='Greens', pos=3,
             save=join_out('map', testname), **vis_dict)
vis.plot_map(ds_anom.isel(time=255), contourf=[-40, -20, 20, 40],
             title=testname, cmap='Reds', pos=4,
             save=join_out('map', testname), **vis_dict)


Out[4]:
<matplotlib.figure.Figure at 0x7f8fd8c339b0>
/home/solactus/anaconda3/lib/python3.5/site-packages/matplotlib/ticker.py:1856: UserWarning: Steps argument should be a sequence of numbers
increasing from 1 to 10, inclusive. Behavior with
values outside this range is undefined, and will
raise a ValueError in future versions of mpl.
  warnings.warn('Steps argument should be a sequence of numbers\n'
/mnt/c/Users/Solactus/Google Drive/Bash/ahh/ahh/ext.py:718: RuntimeWarning: divide by zero encountered in log10
  return int(np.log10(x))
vmin and vmax were balanced!
5
-35 35
5
Out[4]:
<cartopy.mpl.geoaxes.GeoAxesSubplot at 0x7f8fd61d15c0>
vmin and vmax were balanced!
Out[4]:
<cartopy.mpl.geoaxes.GeoAxesSubplot at 0x7f8fd6cab780>
vmin and vmax were balanced!
Out[4]:
<cartopy.mpl.geoaxes.GeoAxesSubplot at 0x7f8fd5b5a8d0>
0.0125
-35.5 38.5
2800.0
Out[4]:
<cartopy.mpl.geoaxes.GeoAxesSubplot at 0x7f8fd5f6aa90>

In [5]:
testname = 'subplot2'

vis_dict = dict(close=False, rows=2, figsize='na')
vis.set_figsize(9, 9)
vis.plot_map(ds_anom.isel(time=18),
             title=testname, cmap='BlueWhiteOrangeRed',
             save=join_out('map', testname), **vis_dict)
vis.plot_map(ds_anom.isel(time=26), contourf=False,
             title=testname, cmap='RdBu_r', pos=2,
             save=join_out('map', testname), **vis_dict)


Out[5]:
<matplotlib.figure.Figure at 0x7f8fd8b919b0>
vmin and vmax were balanced!
5
-35 35
5
/mnt/c/Users/Solactus/Google Drive/Bash/ahh/ahh/ext.py:718: RuntimeWarning: divide by zero encountered in log10
  return int(np.log10(x))
Out[5]:
<cartopy.mpl.geoaxes.GeoAxesSubplot at 0x7f8fd8b91cc0>
vmin and vmax were balanced!
Out[5]:
<cartopy.mpl.geoaxes.GeoAxesSubplot at 0x7f8fd7ab1320>

In [6]:
testname = 'subplot3'

vis_dict = dict(close=False, cols=2, figsize='na')
vis.set_figsize(13, 5)
vis.plot_map(ds_anom.isel(time=18),
             title=testname, cmap='BlueWhiteOrangeRed',
             save=join_out('map', testname), **vis_dict)
ax = vis.plot_map(ds_anom.isel(time=26), contourf=False,
                  title=testname, cmap='RdBu_r', pos=2, lat_labels=None,
                  lon_labels=range(-120, 210, 60),
                  save=join_out('map', testname), **vis_dict)
vis.set_labels(ax, suptitle=True, title='SUPER TITLE!!')


Out[6]:
<matplotlib.figure.Figure at 0x7f8fd870c748>
vmin and vmax were balanced!
5
-35 35
5
/mnt/c/Users/Solactus/Google Drive/Bash/ahh/ahh/ext.py:718: RuntimeWarning: divide by zero encountered in log10
  return int(np.log10(x))
Out[6]:
<cartopy.mpl.geoaxes.GeoAxesSubplot at 0x7f8fd7a6b630>
vmin and vmax were balanced!
Out[6]:
<cartopy.mpl.geoaxes.GeoAxesSubplot at 0x7f8fd6cab240>

In [7]:
testname = 'contourf'

vis_dict = dict(close=False)
vis.plot_map(ds.isel(time=0), contourf=True,
             title=testname, cbar_label='Red and Blue', cmap='GMT_panoply',
             save=join_out('map', testname), **vis_dict)


5
240 300
5
Out[7]:
<cartopy.mpl.geoaxes.GeoAxesSubplot at 0x7f8fd86d2ac8>

In [8]:
testname = 'contourf_negative'

vis_dict = dict(close=False)
vis.plot_map(-ds.isel(time=0), contourf=True,
             title=testname, cbar_label='Red and Blue', cmap='Reds',
             save=join_out('map', testname), **vis_dict)


5
-300 -235
5
/mnt/c/Users/Solactus/Google Drive/Bash/ahh/ahh/ext.py:718: RuntimeWarning: invalid value encountered in log10
  return int(np.log10(x))
Out[8]:
<cartopy.mpl.geoaxes.GeoAxesSubplot at 0x7f8fd3bc8ac8>

In [9]:
testname = 'contourf_negative_small'

vis_dict = dict(close=False)
vis.plot_map(-ds.isel(time=15) / 10, contourf=True,
             title=testname, cbar_label='Red and Blue', cmap='Greens',
             save=join_out('map', testname), **vis_dict)


5
-30 -25
5
/mnt/c/Users/Solactus/Google Drive/Bash/ahh/ahh/ext.py:718: RuntimeWarning: invalid value encountered in log10
  return int(np.log10(x))
Out[9]:
<cartopy.mpl.geoaxes.GeoAxesSubplot at 0x7f8fd79d9470>

In [10]:
testname = 'contourf_positive_small'

vis_dict = dict(close=False)
vis.plot_map(ds.isel(time=25) / 100, contourf=True,
             title=testname, cbar_label='Red and Blue', cmap='Oranges',
             save=join_out('map', testname), **vis_dict)


0.1
2.4 3.0
0.1
Out[10]:
<cartopy.mpl.geoaxes.GeoAxesSubplot at 0x7f8fd6ab1128>

In [11]:
testname = 'contourf_set'

vis_dict = dict(close=False)
vis.plot_map(ds.isel(time=25), contourf=[240, 250, 260, 270, 280, 290, 320],
             title=testname, ar_label='Red and Blue', cmap='Accent',
             save=join_out('map', testname), **vis_dict)


5
245 315
5
/home/solactus/anaconda3/lib/python3.5/site-packages/matplotlib/contour.py:967: UserWarning: The following kwargs were not used by contour: 'ar_label'
  s)
Out[11]:
<cartopy.mpl.geoaxes.GeoAxesSubplot at 0x7f8fd6f69e80>

In [12]:
testname = 'contourf_ticklocs_set'

vis_dict = dict(close=False)
vis.plot_map(ds.isel(time=25), contourf=range(240, 290, 10), tick_locs=[240, 260, 280],
             title=testname, ar_label='Red and Blue', cmap='PuRd',
             save=join_out('map', testname), **vis_dict)


5
245 280
5
/home/solactus/anaconda3/lib/python3.5/site-packages/matplotlib/contour.py:967: UserWarning: The following kwargs were not used by contour: 'ar_label'
  s)
Out[12]:
<cartopy.mpl.geoaxes.GeoAxesSubplot at 0x7f8fd7129e10>

In [13]:
testname = 'pcolormesh_anom'

vis_dict = dict(close=False)
vis.plot_map(ds_anom.isel(time=0) / 100, contourf=False,
             title=testname, cbar_label='Red and Blue', cmap='GMT_panoply',
             save=join_out('map', testname), **vis_dict)


vmin and vmax were balanced!
Out[13]:
<cartopy.mpl.geoaxes.GeoAxesSubplot at 0x7f8fd5ab82b0>

In [14]:
testname = 'pcolormesh_anom_small'

vis_dict = dict(close=False)
vis.plot_map(ds_anom.isel(time=355) / 100, contourf=False,
             title=testname, cbar_label='Red and Blue', cmap='RdYlBu',
             save=join_out('map', testname), **vis_dict)


vmin and vmax were balanced!
Out[14]:
<cartopy.mpl.geoaxes.GeoAxesSubplot at 0x7f8fd5ab8240>

In [15]:
testname = 'contourf_large'

vis_dict = dict(close=False)
vis.plot_map(ds_anom.isel(time=355) * 100,
             title=testname, cbar_label='Good Colormap', cmap='NCV_jaisnd',
             save=join_out('map', testname), **vis_dict)


vmin and vmax were balanced!
5
-4035 4035
807.0
/mnt/c/Users/Solactus/Google Drive/Bash/ahh/ahh/ext.py:718: RuntimeWarning: divide by zero encountered in log10
  return int(np.log10(x))
Out[15]:
<cartopy.mpl.geoaxes.GeoAxesSubplot at 0x7f8fd5d58630>

In [16]:
testname = 'contourf_extra_large'

vis_dict = dict(close=False)
vis.plot_map(ds_anom.isel(time=355) * 1000,
             title=testname, cbar_label='Good Colormap',
             save=join_out('map', testname), **vis_dict)


vmin and vmax were balanced!
5
-40355 40355
8071.0
/mnt/c/Users/Solactus/Google Drive/Bash/ahh/ahh/ext.py:718: RuntimeWarning: divide by zero encountered in log10
  return int(np.log10(x))
Out[16]:
<cartopy.mpl.geoaxes.GeoAxesSubplot at 0x7f8fd7948518>

In [17]:
testname = 'contour'

vis_dict = dict(close=False)
vis.plot_map(ds_anom.isel(time=18),
             contour=[15, 20], contour2=[-20, -15],
             title=testname, cmap='MPL_RdYlBu_r',
             save=join_out('map', testname), **vis_dict)


vmin and vmax were balanced!
5
-35 35
5
/mnt/c/Users/Solactus/Google Drive/Bash/ahh/ahh/ext.py:718: RuntimeWarning: divide by zero encountered in log10
  return int(np.log10(x))
Out[17]:
<cartopy.mpl.geoaxes.GeoAxesSubplot at 0x7f8fd7ed0e10>

In [18]:
testname = 'stipple'

vis_dict = dict(close=False)
vis.plot_map(ds_anom.isel(time=255),
             contour=[15, 20], contour2=[-20, -15], stipple=[20, 25],
             title=testname, cmap='BlueWhiteOrangeRed',
             save=join_out('map', testname), **vis_dict)


vmin and vmax were balanced!
5
-45 45
5
/mnt/c/Users/Solactus/Google Drive/Bash/ahh/ahh/ext.py:718: RuntimeWarning: divide by zero encountered in log10
  return int(np.log10(x))
Out[18]:
<cartopy.mpl.geoaxes.GeoAxesSubplot at 0x7f8fd75fea58>

In [19]:
testname = 'subset'

vis_dict = dict(close=False)
vis.plot_map(ds_anom.isel(time=99), lat1=30, lon2=60,
             title=testname, cmap='bone',
             save=join_out('map', testname), **vis_dict)


vmin and vmax were balanced!
5
-40 40
5
/mnt/c/Users/Solactus/Google Drive/Bash/ahh/ahh/ext.py:718: RuntimeWarning: divide by zero encountered in log10
  return int(np.log10(x))
Out[19]:
<cartopy.mpl.geoaxes.GeoAxesSubplot at 0x7f8fd78d10f0>

In [20]:
testname = 'subset2'

vis_dict = dict(close=False)
vis.plot_map(ds_anom.isel(time=99), lat2=30, lon1=60,
             title=testname, cmap='bone',
             save=join_out('map', testname), **vis_dict)


vmin and vmax were balanced!
5
-40 40
5
/mnt/c/Users/Solactus/Google Drive/Bash/ahh/ahh/ext.py:718: RuntimeWarning: divide by zero encountered in log10
  return int(np.log10(x))
Out[20]:
<cartopy.mpl.geoaxes.GeoAxesSubplot at 0x7f8fd7a3d9b0>

In [21]:
testname = 'subset3'

vis_dict = dict(close=False)
vis.plot_map(ds_anom.isel(time=99), latlim=(45, 90), lonlim=(75, 150),
             title=testname, cmap='bone',
             save=join_out('map', testname), **vis_dict)


vmin and vmax were balanced!
5
-40 40
5
/mnt/c/Users/Solactus/Google Drive/Bash/ahh/ahh/ext.py:718: RuntimeWarning: divide by zero encountered in log10
  return int(np.log10(x))
Out[21]:
<cartopy.mpl.geoaxes.GeoAxesSubplot at 0x7f8fd876a240>

In [22]:
testname = 'subset4'

vis_dict = dict(close=False)
vis.plot_map(ds_anom.isel(time=99), latlim=(-90, 45), lonlim=(75, 150),
             title=testname, cmap='bone', orientation='vertical',
             save=join_out('map', testname), **vis_dict)


vmin and vmax were balanced!
5
-40 40
5
/mnt/c/Users/Solactus/Google Drive/Bash/ahh/ahh/ext.py:718: RuntimeWarning: divide by zero encountered in log10
  return int(np.log10(x))
Out[22]:
<cartopy.mpl.geoaxes.GeoAxesSubplot at 0x7f8fd38a44a8>

In [23]:
testname = 'regions'

vis_dict = dict(close=False)
vis.plot_map(ds_anom.isel(time=99), region='na',
             title=testname, cmap='bone',
             save=join_out('map', testname), **vis_dict)


vmin and vmax were balanced!
5
-40 40
5
/mnt/c/Users/Solactus/Google Drive/Bash/ahh/ahh/ext.py:718: RuntimeWarning: divide by zero encountered in log10
  return int(np.log10(x))
Out[23]:
<cartopy.mpl.geoaxes.GeoAxesSubplot at 0x7f8fd3d727f0>

In [24]:
testname = 'vmax_vmin_interval'

vis_dict = dict(close=False)
vis.plot_map(ds_anom.isel(time=99), region='na',
             title=testname, cmap='inferno', vmax=20, vmin=-20, interval=4,
             save=join_out('map', testname), **vis_dict)


vmin and vmax were balanced!
5
-20 20
4
/mnt/c/Users/Solactus/Google Drive/Bash/ahh/ahh/ext.py:718: RuntimeWarning: divide by zero encountered in log10
  return int(np.log10(x))
Out[24]:
<cartopy.mpl.geoaxes.GeoAxesSubplot at 0x7f8fd3e90780>

In [25]:
testname = 'show_land'

vis_dict = dict(close=False)
vis.plot_map(ds_anom.isel(time=99), region='na',
             coastlines=True, lakes=True, rivers=True, ocean=True,
             title=testname, states=True, countries=True,
             save=join_out('map', testname), **vis_dict)


vmin and vmax were balanced!
5
-40 40
5
/mnt/c/Users/Solactus/Google Drive/Bash/ahh/ahh/ext.py:718: RuntimeWarning: divide by zero encountered in log10
  return int(np.log10(x))
Out[25]:
<cartopy.mpl.geoaxes.GeoAxesSubplot at 0x7f8fd69186a0>

In [26]:
testname = 'show_ocean'

vis_dict = dict(close=False)
vis.plot_map(ds_anom.isel(time=99), region='na',
             land=True,
             title=testname, states=True, countries=True,
             save=join_out('map', testname), **vis_dict)


vmin and vmax were balanced!
5
-40 40
5
/mnt/c/Users/Solactus/Google Drive/Bash/ahh/ahh/ext.py:718: RuntimeWarning: divide by zero encountered in log10
  return int(np.log10(x))
Out[26]:
<cartopy.mpl.geoaxes.GeoAxesSubplot at 0x7f8fd7489e48>

In [ ]: