Testing ScienceBase CSW


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

In [2]:
endpoint = 'http://catalog.data.gov/csw-all'  #granule level catalog
endpoint = 'https://www.sciencebase.gov/catalog/item/54dd2326e4b08de9379b2fb1/csw'
csw = CatalogueServiceWeb(endpoint,timeout=60)
print csw.version


2.0.2

In [3]:
csw.get_operation_by_name('GetRecords').constraints


Out[3]:
[Constraint: SupportedCommonQueryables - ['AnyText', 'Title', 'Abstract', 'Subject'],
 Constraint: AdditionalQueryables - ['sb:collection', 'sb:servicetype']]

In [4]:
val = 'prism'
filter1 = fes.PropertyIsLike(propertyname='AnyText',literal=('*%s*' % val),
                        escapeChar='\\',wildCard='*',singleChar='?')
filter_list = [ filter1 ]

In [5]:
csw.getrecords2(constraints=filter_list,maxrecords=100,esn='full')
print len(csw.records.keys())
for rec in list(csw.records.keys()):
    print csw.records[rec].title


3
Parameter-elevation Regressions on Independent Slopes Model Monthly Climate Data for the Continental United States.
University of Idaho Daily Meteorological data for continental US
California Basin Characterization Model Downscaled Climate and Hydrology

In [8]:
choice = np.random.choice(list(csw.records.keys()))
print(csw.records[choice].title)
csw.records[choice].references


Parameter-elevation Regressions on Independent Slopes Model Monthly Climate Data for the Continental United States.
Out[8]:
[{'scheme': 'WWW:LINK',
  'url': 'http://cida.usgs.gov/gdp/client/catalog/gdp/dataset/54dd5e05e4b08de9379b38e1'},
 {'scheme': 'OPeNDAP:OPeNDAP',
  'url': 'http://cida.usgs.gov/thredds/dodsC/prism'},
 {'scheme': 'OPeNDAP:OPeNDAP',
  'url': 'http://cida.usgs.gov/thredds/dodsC/prism_v2'}]

In [6]: