import xray
%matplotlib inline
import matplotlib.pyplot as plt
resampled_xray = xray.open_dataset(
'COLA_data/resampled_tas_Amon_CCSM4_piControl_r3i1p1_000101-012012.nc')
climatology = resampled_xray.groupby('time.month').mean('time')
anomalies = resampled_xray.groupby('time.month') - climatology
import urllib
urllib.urlretrieve('https://drive.google.com/uc?export=download&id=0B-CxJMRyTT32el85MFRSYnU5TGM', 'mask.nc')
raw_mask = xray.open_dataset('mask.nc')
# extract places where the nearest latitude or longitude (before or after) is in the ocean
sea_mask = ((raw_mask.reindex_like(resampled_xray, method='pad').sftlf < 100)
& (raw_mask.reindex_like(resampled_xray, method='backfill').sftlf < 100))
('mask.nc', <httplib.HTTPMessage instance at 0x7f9813b99320>)
anomalies.tas[0].plot.pcolormesh()
<matplotlib.collections.QuadMesh at 0x7f97e8b41c10>
anomalies.tas.where(sea_mask)[0].plot.pcolormesh()
<matplotlib.collections.QuadMesh at 0x7f97e8c820d0>