CMRE search, access and visualize demo

Search for data using OGC Catalog Service for the Web (CSW)


In [1]:
from owslib.csw import CatalogueServiceWeb
from owslib import fes
import netCDF4
import numpy as np

In [2]:
endpoint='http://scsrv26v:8000/pycsw'
#endpoint='http://www.ngdc.noaa.gov/geoportal/csw'
csw = CatalogueServiceWeb(endpoint,timeout=60)
csw.version


Out[2]:
'2.0.2'

In [5]:
box=[38., 6., 41., 9.]     #  lon_min lat_min lon_max lat_max
start_date='2014-03-12 18:00'
stop_date='2014-09-18 18:00'
val = 'sea_water_potential_temperature'

In [6]:
# convert User Input into FES filters
start,stop = dateRange(start_date,stop_date)
bbox = fes.BBox(box)
any_text = fes.PropertyIsLike(propertyname='apiso:AnyText',literal=('*%s*' % val),
                        escapeChar='\\',wildCard='*',singleChar='?')

In [7]:
# combine filters into a list
filter_list = [fes.And([ start, stop, bbox,any_text]) ]

In [8]:
csw.getrecords2(constraints=filter_list,maxrecords=100,esn='full')
len(csw.records.keys())


Out[8]:
9

In [11]:
#scheme='urn:x-esri:specification:ServiceType:odp:url'
scheme='OPeNDAP:OPeNDAP'
urls = service_urls(csw.records,service_string=scheme)
print "\n".join(urls)


http://scsrv26v:8080/thredds/dodsC/cmre_roms/fmrc/cmre_roms_best.ncd
http://scsrv26v:8080/thredds/dodsC/gliders/GL-20140608-zoe-MEDREP14depl001-grid-D.nc.ncml
http://scsrv26v:8080/thredds/dodsC/gliders/GL-20140609-noa-MEDREP14depl001-grid-D.nc.ncml
http://scsrv26v:8080/thredds/dodsC/socib_roms/fmrc/socib_roms_best.ncd
http://scsrv26v:8080/thredds/dodsC/cmre_roms_regular/fmrc/cmre_roms_regular_best.ncd
http://scsrv26v:8080/thredds/dodsC/mfs/fmrc/mfs_best.ncd
http://scsrv26v:8080/thredds/dodsC/mercator/fmrc/mercator_best.ncd
http://scsrv26v:8080/thredds/dodsC/nrl/fmrc/nrl_best.ncd
http://thredds.socib.es/thredds/dodsC/operational_models/oceanographical/hydrodynamics/model_run_aggregation/wmopv2/wmopv2_best.ncd

Use Iris to access CF data


In [ ]:
cube = iris.load_cube(urls[7],'sea_water_potential_temperature')

In [15]:
# color filled contour plot
h = iplt.contourf(cube[1,0,:,:],64)
plt.title(cube.attributes['title']);