This notebook demonstrates the following typical tasks you might want to do with CETB EASE-Grid 2.0 cube data:
You will need to be working in a python environment with the following packages installed. I think the cartopy features here require it to be a python 3 environment:
cartopy
matplotlib
netCDF4
In [1]:
%matplotlib notebook
import cartopy.crs as ccrs
import matplotlib.pyplot as plt
from netCDF4 import Dataset
import numpy as np
In [2]:
geod = ccrs.Geodetic()
e2n = ccrs.LambertAzimuthalEqualArea(central_latitude=90.0)
In [3]:
file = "/Users/brodzik/cetb_data/v1.3/F16_SSMIS/N/cubes_WesternUS/CETB.cubefile.WesternUS.F16_SSMIS-19H-SIR-CSU-v1.3.2005.TB.nc"
f = Dataset(file, 'r', 'netCDF4')
In [4]:
x = f.variables['x'][:]
y = f.variables['y'][:]
In [5]:
# Define extent in projected coordinates.
# Use the x, y coordinate variables in the file, which give the centers of the pixels,
# and adjust these by 1/2 pixel to get the corners of the corner pixels
# We want extent as [x_min, x_max, y_min, y_max]
extent = [x[0], x[-1], y[-1], y[0]]
extent
Out[5]:
In [6]:
x_res_m = np.fabs(x[1] - x[0])
y_res_m = np.fabs(y[1] - y[0])
In [7]:
x_res_m, y_res_m
Out[7]:
In [8]:
extent = [x[0] - (x_res_m / 2.), x[-1] + (x_res_m / 2.),
y[-1] - (y_res_m / 2.), y[0] + (y_res_m / 2.)]
extent
Out[8]:
In [9]:
tb = f.variables['TB'][:]
tb.shape
Out[9]:
In [10]:
f.close()
In [11]:
for t in np.arange(730):
print(t, np.min(tb[t,:,:]), np.max(tb[t,:,:]))
In [12]:
fig = plt.figure(figsize=(8,4))
axes = fig.subplots(1, 2, subplot_kw=dict(projection=e2n))
for ax in axes:
ax.set_extent(extent, crs=e2n)
axes[0].imshow(tb[645,:,:], extent=extent, transform=e2n, origin='upper')
axes[1].imshow(tb[646,:,:], extent=extent, transform=e2n, origin='upper')
for ax in axes:
ax.gridlines(color='gray', linestyle='--')
ax.coastlines()
fig.tight_layout()
In [ ]: