#!/usr/bin/env python # coding: utf-8 # # Load Hurricane Sandy model results # In[1]: get_ipython().run_line_magic('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') get_ipython().run_line_magic('time', 'temp = nc[var][istep:istep+10,:,:,:]') # ## load hyperslab from local netcdf file # In[4]: nc = netCDF4.Dataset('Sandy_ocean_his.nc') get_ipython().run_line_magic('time', 'temp = nc[var][istep:istep+10,:,:,:]') # ## load hyperslab from HSDS # In[5]: f = h5pyd.File("/home/john/sandy.nc", 'r') get_ipython().run_line_magic('time', 'temp = f[var][istep:istep+10,:,:]') # ## 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 # 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); # In[ ]: