In [1]:
import matplotlib.pyplot as plt
import numpy.ma as ma
%matplotlib inline

In [2]:
url = 'http://geoport.whoi.edu/thredds/dodsC/coawst_4/use/fmrc/coawst_4_use_best.ncd'

In [3]:
#plot with NetCDF4
import netCDF4
nc = netCDF4.Dataset(url)
ncv = nc.variables
lon = ncv['lon_rho'][:,:]
lat = ncv['lat_rho'][:,:]
t = ncv['temp'][-1,-1,:,:]
#rmask = 1 - ncv['mask_rho'][:,:]
#plt.pcolormesh(lon,lat,ma.masked_where(rmask,t),vmin=5,vmax=30)
plt.pcolormesh(lon,lat,ma.masked_invalid(t),vmin=5,vmax=30)


Out[3]:
<matplotlib.collections.QuadMesh at 0x7fc6894e4b10>

In [4]:
#plot with Iris
import iris
import iris.quickplot as qplt
time0=time.time()
cube = iris.load_cube(url,'sea_water_potential_temperature')


/home/usgs/miniconda/envs/ioos/lib/python2.7/site-packages/Iris-1.8.0.dev0-py2.7.egg/iris/fileformats/cf.py:1040: UserWarning: Ignoring formula terms variable u'h' referenced by data variable u'v' via variable u's_rho': Dimensions (u'eta_rho', u'xi_rho') do not span (u'time', u's_rho', u'eta_v', u'xi_v')
  warnings.warn(msg)
/home/usgs/miniconda/envs/ioos/lib/python2.7/site-packages/Iris-1.8.0.dev0-py2.7.egg/iris/fileformats/cf.py:1040: UserWarning: Ignoring formula terms variable u'zeta' referenced by data variable u'v' via variable u's_rho': Dimensions (u'time', u'eta_rho', u'xi_rho') do not span (u'time', u's_rho', u'eta_v', u'xi_v')
  warnings.warn(msg)
/home/usgs/miniconda/envs/ioos/lib/python2.7/site-packages/Iris-1.8.0.dev0-py2.7.egg/iris/fileformats/cf.py:1040: UserWarning: Ignoring formula terms variable u'h' referenced by data variable u'u' via variable u's_rho': Dimensions (u'eta_rho', u'xi_rho') do not span (u'time', u's_rho', u'eta_u', u'xi_u')
  warnings.warn(msg)
/home/usgs/miniconda/envs/ioos/lib/python2.7/site-packages/Iris-1.8.0.dev0-py2.7.egg/iris/fileformats/cf.py:1040: UserWarning: Ignoring formula terms variable u'zeta' referenced by data variable u'u' via variable u's_rho': Dimensions (u'time', u'eta_rho', u'xi_rho') do not span (u'time', u's_rho', u'eta_u', u'xi_u')
  warnings.warn(msg)
/home/usgs/miniconda/envs/ioos/lib/python2.7/site-packages/Iris-1.8.0.dev0-py2.7.egg/iris/fileformats/_pyke_rules/compiled_krb/fc_rules_cf_fc.py:1396: UserWarning: Gracefully filling 'time' dimension coordinate masked points
  warnings.warn(msg.format(str(cf_coord_var.cf_name)))
/home/usgs/miniconda/envs/ioos/lib/python2.7/site-packages/Iris-1.8.0.dev0-py2.7.egg/iris/fileformats/netcdf.py:441: UserWarning: Unable to find coordinate for variable u'zeta'
  '{!r}'.format(name))
/home/usgs/miniconda/envs/ioos/lib/python2.7/site-packages/Iris-1.8.0.dev0-py2.7.egg/iris/fileformats/netcdf.py:441: UserWarning: Unable to find coordinate for variable u'h'
  '{!r}'.format(name))
/home/usgs/miniconda/envs/ioos/lib/python2.7/site-packages/Iris-1.8.0.dev0-py2.7.egg/iris/fileformats/netcdf.py:558: UserWarning: Unable to construct Ocean s-coordinate, generic form 1 factory due to insufficient source coordinates.
  warnings.warn('{}'.format(e))

In [5]:
qplt.pcolormesh(cube[-1,-1,:,:])


Out[5]:
<matplotlib.collections.QuadMesh at 0x7fc67b67cd50>
/home/usgs/miniconda/envs/ioos/lib/python2.7/site-packages/matplotlib/colors.py:584: RuntimeWarning: invalid value encountered in less
  cbook._putmask(xa, xa < 0.0, -1)

In [6]:
last_step = cube[-1,-1,:,:]
last_step.data = ma.masked_invalid(last_step.data)
qplt.pcolormesh(last_step)


Out[6]:
<matplotlib.collections.QuadMesh at 0x7fc67b4eab50>

In [7]:
print cube


sea_water_potential_temperature               (time: 23961; ocean_s_coordinate_g1: 16; -- : 336; -- : 896)
     Dimension coordinates:
          time                                             x                             -        -         -
          ocean_s_coordinate_g1                            -                             x        -         -
     Auxiliary coordinates:
          forecast_reference_time                          x                             -        -         -
          water_surface_height_above_reference_datum       x                             -        x         x
          S-coordinate stretching curves at RHO-points     -                             x        -         -
          latitude                                         -                             -        x         x
          longitude                                        -                             -        x         x
          sea_floor_depth                                  -                             -        x         x
     Derived coordinates:
          sea_surface_height_above_reference_ellipsoid     x                             x        x         x
     Scalar coordinates:
          S-coordinate parameter, critical depth: 5.0 meter
     Attributes:
          CPP_options: COAWST, ANA_BPFLUX, ANA_BSFLUX, ANA_BTFLUX, ANA_FSOBC, ANA_M2OBC, ANA_NUDGCOEF,...
          Conventions: CF-1.4, _Coordinates
          DODS_EXTRA.Unlimited_Dimension: ocean_time
          NLM_LBC: 
EDGE:         WEST   SOUTH  EAST   NORTH  
zeta:         Clo    Cha  ...
          _ChunkSize: [  1   4 112 299]
          _CoordSysBuilder: ucar.nc2.dataset.conv.CF1Convention
          ana_file: ROMS/Functionals/ana_btflux.h, ROMS/Functionals/ana_fsobc.h, ROMS/Functionals/ana_m2obc.h,...
          bry_file_01: ./forcings3/USE_coawst_bdy.nc
          cdm_data_type: GRID
          clm_file_01: ./forcings3/USE_coawst_clm.nc
          code_dir: /raid1/jcwarner/Models/COAWST_forecast
          compiler_command: /usr/local/mpi/bin/mpif90
          compiler_flags:  -fastsse -Mipa=fast -tp k8-64 -Mfree
          compiler_system: pgi
          cpu: x86_64
          featureType: GRID
          field: temperature, scalar, series
          file: ./Output/coawst_use_his_0001.nc
          format: netCDF-3 64bit offset file
          frc_file_01: ./forcings/cloud_coawst.nc
          frc_file_02: ./forcings/Pair_coawst.nc
          frc_file_03: ./forcings/Qair_coawst.nc
          frc_file_04: ./forcings/rain_coawst.nc
          frc_file_05: ./forcings/swrad_coawst.nc
          frc_file_06: ./forcings/Tair_coawst.nc
          frc_file_07: ./forcings/lwrad_coawst.nc
          frc_file_08: ./forcings/Big_grd2_coawstwind.nc
          frc_file_09: ./grids/tide_forc_USeast_grd16_osu_rev2.nc
          grd_file: ./grids/USeast_grd19.nc
          header_dir: /raid1/jcwarner/Models/COAWST_forecast/Projects/coawst
          header_file: coawst.h
          his_base: ./Output/coawst_use_his
          history: ROMS/TOMS, Version 3.7, Tuesday - May 12, 2015 -  2:39:15 AM ;
FMRC Best...
          ini_file: ./restart/ocean_use_rst.nc
          location: Proto fmrc:coawst_4_use
          os: Linux
          project: CMG_Portal
          rst_file: ./Output/ocean_use_rst.nc
          script_file: 
          summary: Experimental forecast model product from the USGS Coupled Ocean Atmosphere...
          svn_rev: exported
          svn_url: https:://myroms.org/svn/src
          tiling: 010x004
          time: ocean_time
          title: COAWST Forecast System : USGS : US East Coast and Gulf of Mexico (Expe...
          type: ROMS/TOMS history file

In [8]:
cube.plot


---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-8-0559144adc11> in <module>()
----> 1 cube.plot

AttributeError: 'Cube' object has no attribute 'plot'

In [ ]:
slice=temp[-1,-1,::2,::2]
print slice

In [ ]:
ma.maske

In [ ]: