Performance of sci-wms and ncwms for curvilinear grid data


In [1]:
%matplotlib inline
from IPython.core.display import Image

Let's see if we can get ncwms and sci-wms maps that look the same from COAWST output


In [2]:
url='http://sci-wms.whoi.edu/wms/datasets/coawst?service=WMS&request=GetMap&version=1.1.1&layers=temp&styles=pcolor_jet&format=image/png&transparent=true&height=256&width=256&colorscalerange=10,30&srs=EPSG%3A4326&BBOX=-89.8606,21.882,-67.887973988643,40.890&elevation=15'
from IPython.core.display import Image
Image(url=url)


Out[2]:

In [3]:
url='http://geoport-dev.whoi.edu/thredds/wms/coawst_4/use/fmrc/coawst_4_use_best.ncd?LAYERS=temp&ELEVATION=-0.03125&TRANSPARENT=true&STYLES=boxfill%2Frainbow&COLORSCALERANGE=10.0%2C30.00&LOGSCALE=false&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&EXCEPTIONS=application%2Fvnd.ogc.se_inimage&FORMAT=image%2Fpng&SRS=EPSG%3A4326&BBOX=-89.8606,21.882,-67.887973988643,40.890&WIDTH=256&HEIGHT=256'
Image(url=url)


Out[3]:

How long does the sci-wms getmap query take?


In [4]:
!curl -o /tmp/foo.png "http://sci-wms.whoi.edu/wms/datasets/coawst?service=WMS&request=GetMap&version=1.1.1&layers=temp&styles=pcolor_jet&format=image/png&transparent=true&height=256&width=256&colorscalerange=10,30&srs=EPSG%3A4326&BBOX=-89.8606,21.882,-67.887973988643,40.890&elevation=15"


  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 33489  100 33489    0     0   7508      0  0:00:04  0:00:04 --:--:--  7866

How long does the ncWMS getmap query take?


In [5]:
!curl -o /tmp/foo2.png "http://geoport-dev.whoi.edu/thredds/wms/coawst_4/use/fmrc/coawst_4_use_best.ncd?LAYERS=temp&ELEVATION=-0.03125&TRANSPARENT=true&STYLES=boxfill%2Frainbow&COLORSCALERANGE=10.0%2C30.00&LOGSCALE=false&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&EXCEPTIONS=application%2Fvnd.ogc.se_inimage&FORMAT=image%2Fpng&SRS=EPSG%3A4326&BBOX=-89.8606,21.882,-67.887973988643,40.890&WIDTH=256&HEIGHT=256"


  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 18386    0 18386    0     0  14263      0 --:--:--  0:00:01 --:--:-- 14285

So on this test, sci-wms is much slower

Kyle points out here that the slowness in sci-wms might come from OPeNDAP rather than local file access. Let's check that out.

Try NetCDF4 with OPeNDAP


In [6]:
%%timeit
from netCDF4 import Dataset
url = 'http://geoport-dev.whoi.edu/thredds/dodsC/coawst_4/use/fmrc/coawst_4_use_best.ncd'
nc = Dataset(url)
ncv = nc.variables
t = ncv['temp'][-1,-1,:,:]
lon = ncv['lon_rho'][:,:]
lat = ncv['lat_rho'][:,:]


1 loops, best of 3: 4.75 s per loop

Try NetCDF4 with local file


In [7]:
%%timeit
from netCDF4 import Dataset
url = '/usgs/vault0/coawst/coawst_4/Output/use/coawst_us_20151029_13.nc'
nc = Dataset(url)
ncv = nc.variables
t = ncv['temp'][-1,-1,:,:]
lon = ncv['lon_rho'][:,:]
lat = ncv['lat_rho'][:,:]


10 loops, best of 3: 85.8 ms per loop

Try Siphon with CDMRemote


In [8]:
%%timeit
from siphon.cdmr import Dataset
url='http://geoport-dev.whoi.edu/thredds/cdmremote/coawst_4/use/fmrc/coawst_4_use_best.ncd'
ds = Dataset(url)
ncv = ds.variables
t = ncv['temp'][-1,-1,:,:]
lon = ncv['lon_rho'][:,:]
lat = ncv['lat_rho'][:,:]


1 loops, best of 3: 2.77 s per loop

Conclusion: Since sci-wms uses OPeNDAP, it can't compete with ncWMS local file reads. However, CDMRemote is faster than OPeNDAP on this test. We could check for CDMRemote and use it if is exists.


In [8]: