from pylab import * import time # The netCDF4-Python library accesses OPeNDAP using the Unidata NetCDF-C library: import netCDF4 # the full dataset OPeNDAP URL: #url='http://ec2-54-245-151-123.us-west-2.compute.amazonaws.com:8080/opendap/ugrids/fvcom_1step.nc' url='http://ec2-54-242-224-73.compute-1.amazonaws.com:8080/opendap/ebs/fvcom_1step.nc' # the region we want to subset, in Matlab style bbox: bbox=[-95.0, -94.4, 29.3, 29.8] # [lonmin lonmax latmin latmax] Galveston Bay # open and read a field from the full dataset: time0 = time.time() nc = netCDF4.Dataset(url) nc.variables lon = nc.variables['lon'][:] lat = nc.variables['lat'][:] # read connectivity array, and convert to pythonic 0-based indexing nv = nc.variables['nv'][:] - nc.variables['nv'].start_index h = nc.variables['h'][:] etime = time.time()- time0 print 'Elapsed time to read full grid: %.2f seconds' % etime # plot full bathy: figure(figsize=(10,6),frameon=True) tricontourf(lon,lat,-h,triangles=nv, levels=[-5000,-4000,-3000,-2000,-1000,-500,-100,-50,-20,-10,0]) colorbar() gca().set_aspect(1./cos(30.0*pi/180)) title('FVCOM Bathy (m)') # construct the subset expression expr='_expr_{}{ugr3(0,ua,va,h,\"%.6f