from owslib.csw import CatalogueServiceWeb
from owslib import fes
import netCDF4
import numpy as np
endpoint='http://scsrv26v:8000/pycsw'
#endpoint='http://www.ngdc.noaa.gov/geoportal/csw'
csw = CatalogueServiceWeb(endpoint,timeout=60)
csw.version
'2.0.2'
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'
# 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='?')
# combine filters into a list
filter_list = [fes.And([ start, stop, bbox,any_text]) ]
csw.getrecords2(constraints=filter_list,maxrecords=100,esn='full')
len(csw.records.keys())
9
#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
cube = iris.load_cube(urls[7],'sea_water_potential_temperature')
# color filled contour plot
h = iplt.contourf(cube[1,0,:,:],64)
plt.title(cube.attributes['title']);