Load Hurricane Sandy model results

In [1]:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import netCDF4
import h5pyd
In [2]:
#var = 'Hwave'
var = 'temp'
istep = 55

load hyperslab from local OPeNDAP

In [3]:
nc = netCDF4.Dataset('http://jetstream.signell.us:8080/thredds/dodsC/local/Sandy_ocean_his_nc4.nc')
%time temp = nc[var][istep:istep+10,:,:,:]
CPU times: user 64 ms, sys: 8 ms, total: 72 ms
Wall time: 179 ms

load hyperslab from local netcdf file

In [4]:
nc = netCDF4.Dataset('Sandy_ocean_his.nc')
%time temp = nc[var][istep:istep+10,:,:,:]
CPU times: user 8 ms, sys: 4 ms, total: 12 ms
Wall time: 426 ms

load hyperslab from HSDS

In [5]:
f = h5pyd.File("/home/john/sandy.nc", 'r')
%time temp = f[var][istep:istep+10,:,:]
CPU times: user 32 ms, sys: 0 ns, total: 32 ms
Wall time: 449 ms

plot wave height at peak of storm

In [6]:
import cartopy.crs as ccrs
from cartopy.feature import NaturalEarthFeature, COLORS
from cartopy.mpl.gridliner import LONGITUDE_FORMATTER, LATITUDE_FORMATTER
In [7]:
LAND = NaturalEarthFeature('physical', 'land', '10m', edgecolor='face', facecolor=COLORS['land'])
In [8]:
nc['temp'].shape
Out[8]:
(97, 16, 64, 84)
In [9]:
lon = nc['lon_rho'][:]
lat = nc['lat_rho'][:]

crs = ccrs.PlateCarree()

fig, ax = plt.subplots(figsize=(10,8),subplot_kw=dict(projection=ccrs.Mercator()))

ax.set_extent([lon.min(), lon.max(), lat.min(), lat.max()])
ax.add_feature(LAND)
ax.coastlines(resolution='10m')
gl = ax.gridlines(draw_labels=True)
gl.xlabels_top = gl.ylabels_right = False
gl.xformatter = LONGITUDE_FORMATTER
gl.yformatter = LATITUDE_FORMATTER

p = ax.pcolormesh(lon, lat, nc['Hwave'][55,:,:], transform = crs);
plt.colorbar(p);