%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import netCDF4
import h5pyd
#var = 'Hwave'
var = 'temp'
istep = 55
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
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
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
import cartopy.crs as ccrs
from cartopy.feature import NaturalEarthFeature, COLORS
from cartopy.mpl.gridliner import LONGITUDE_FORMATTER, LATITUDE_FORMATTER
LAND = NaturalEarthFeature('physical', 'land', '10m', edgecolor='face', facecolor=COLORS['land'])
nc['temp'].shape
(97, 16, 64, 84)
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);