CSW access with OWSLib using ISO and long_name

Note: requires OSWLib 0.7_dev or higher


In [1]:
from pylab import *
from owslib.csw import CatalogueServiceWeb
from owslib import fes
import netCDF4
import pandas as pd

In [2]:
from IPython.core.display import HTML
HTML('<iframe src=http://geoport.whoi.edu/geoportal/ width=950 height=400></iframe>')


Out[2]:

In [3]:
# connect to CSW, explore it's properties
#endpoint = 'http://www.ngdc.noaa.gov/geoportal/csw' # NGDC Geoportal
#endpoint = 'http://www.nodc.noaa.gov/geoportal/csw'   # NODC Geoportal: granule level
#endpoint = 'http://data.nodc.noaa.gov/geoportal/csw'  # NODC Geoportal: collection level
    
#endpoint = 'http://geodiscover.cgdi.ca/wes/serviceManagerCSW/csw'  # NRCAN CUSTOM
#endpoint = 'http://geoport.whoi.edu/gi-cat/services/cswiso' # USGS Woods Hole GI_CAT
#endpoint = 'http://cida.usgs.gov/gdp/geonetwork/srv/en/csw' # USGS CIDA Geonetwork

endpoint = 'http://geoport.whoi.edu/geoportal/csw'

csw = CatalogueServiceWeb(endpoint,timeout=30)
csw.version


Out[3]:
'2.0.2'

In [4]:
[op.name for op in csw.operations]


Out[4]:
['GetCapabilities',
 'DescribeRecord',
 'GetRecords',
 'GetRecordById',
 'Transaction']

In [5]:
# hopefully something like this will be implemented in fes soon
def dateRange(start_date='1900-01-01',stop_date='2100-01-01',constraint='overlaps'):
    if constraint == 'overlaps':
        start = fes.PropertyIsLessThanOrEqualTo(propertyname='startDate', literal=stop_date)
        stop = fes.PropertyIsGreaterThanOrEqualTo(propertyname='endDate', literal=start_date)
    elif constraint == 'within':
        start = fes.PropertyIsGreaterThanOrEqualTo(propertyname='startDate', literal=start_date)
        stop = fes.PropertyIsLessThanOrEqualTo(propertyname='endDate', literal=stop_date)
    return start,stop

In [6]:
# Perform the CSW query, using Kyle's cool new filters on ISO queryables
# find all datasets in a bounding box and temporal extent that have 
# specific keywords and also can be accessed via OPeNDAP  

box = [-70.5, 43.0, -68.0, 44.0]
bbox = fes.BBox(box)
start,stop = dateRange('1993-01-01','2001-09-01')
long_name = 'ATTENUATION'
#std_name = 'sea_water_temperature'
#keywords = fes.PropertyIsLike(propertyname='anyText', literal=std_name)
serviceType = fes.PropertyIsLike(propertyname='apiso:ServiceType', literal='*opendap*')

# apply all the filters using the "and" syntax: [[filter1,filter2]]
csw.getrecords2(constraints=[[start,stop,serviceType,bbox]],maxrecords=150,esn='full')
#csw.get_filtered_records([[keywords,start,stop,serviceType,bbox]],maxrecords=5)
csw.records.keys()


Out[6]:
['ECOHAB_II/6211mc-a1h_1d.nc',
 'ECOHAB_II/6221mc-a1h_1d.nc',
 'ECOHAB_II/6191mc-a1h_1d.nc',
 'ECOHAB_I/4161-a1h_1d.cdf',
 'ECOHAB_I/4163-a_1d.cdf',
 'ECOHAB_II/6225adc-a_1d.nc',
 'ECOHAB_I/4151att-a1h_1d.cdf',
 'ECOHAB_II/6226cs-a_1d.nc',
 'ECOHAB_II/5223-a1h_1d.cdf',
 'ECOHAB_II/6226-a1h_1d.nc',
 'ECOHAB_II/5225bsc-a_1d.cdf',
 'ECOHAB_II/6224sc-a1h_1d.nc',
 'ECOHAB_II/6211mc-a_1d.nc',
 'ECOHAB_II/6231mc-a_1d.nc',
 'ECOHAB_II/6226cs-a1h_1d.nc',
 'ECOHAB_I/4162-a1h_1d.cdf',
 'ECOHAB_I/4333-a1h_1d.cdf',
 'ECOHAB_II/5261sc-a1h_1d.cdf',
 'ECOHAB_I/4331-a_1d.cdf',
 'ECOHAB_II/5251mc-a_1d.cdf',
 'ECOHAB_II/5261att-a_1d.cdf',
 'ECOHAB_II/6232s4-a_1d.nc',
 'ECOHAB_I/4163cs-a1h_1d.cdf',
 'ECOHAB_I/4351sc-a1h_1d.cdf',
 'ECOHAB_I/4162-a1hlp_1d.nc',
 'ECOHAB_II/5224-a_1d.cdf',
 'ECOHAB_I/4332sc-a_1d.cdf',
 'ECOHAB_II/6191mc-a_1d.nc',
 'ECOHAB_I/4152-a1hlp_1d.nc',
 'ECOHAB_II/5223asc-a1h_1d.cdf',
 'ECOHAB_II/5234-a_1d.cdf',
 'ECOHAB_I/4161-a_1d.cdf',
 'ECOHAB_II/5234-a1h_1d.cdf',
 'ECOHAB_II/5223-a_1d.cdf',
 'ECOHAB_I/4161sc-a1h_1d.cdf',
 'ECOHAB_II/5225asc-a_1d.cdf',
 'ECOHAB_II/6223-a1h_1d.nc',
 'ECOHAB_I/4341-a_1d.cdf',
 'ECOHAB_I/4163att-a_1d.cdf',
 'ECOHAB_I/4153att-a1h_1d.cdf',
 'ECOHAB_I/4333cs-a1h_1d.cdf',
 'ECOHAB_II/6234sc-a1h_1d.nc',
 'ECOHAB_I/4332-a_1d.cdf',
 'ECOHAB_II/5224cs-a1h_1d.cdf',
 'ECOHAB_II/6226att-a_1d.nc',
 'ECOHAB_I/4151-a_1d.cdf',
 'ECOHAB_I/4331-a1h_1d.cdf',
 'ECOHAB_I/4152sc-a_1d.cdf',
 'ECOHAB_I/4161sc-a_1d.cdf',
 'ECOHAB_II/6226att-a1h_1d.nc',
 'ECOHAB_I/4331sc-a_1d.cdf',
 'ECOHAB_II/617Apt-a_1d.nc',
 'ECOHAB_I/4333cs-a_1d.cdf',
 'ECOHAB_II/5252sc-a_1d.cdf',
 'ECOHAB_I/4151att-a_1d.cdf',
 'ECOHAB_I/4153-a1h_1d.cdf',
 'ECOHAB_II/5221mc-a_1d.cdf',
 'ECOHAB_II/617Apt-a1h_1d.nc',
 'ECOHAB_I/4153att-a_1d.cdf',
 'ECOHAB_I/4332-a1h_1d.cdf',
 'ECOHAB_II/6187att-a1h_1d.nc',
 'ECOHAB_I/4171-a1h_1d.cdf',
 'ECOHAB_II/6226-a_1d.nc',
 'ECOHAB_II/5241adc-a_1d.nc',
 'ECOHAB_II/6201mc-a_1d.nc',
 'ECOHAB_II/5223bsc-a_1d.cdf',
 'ECOHAB_I/4163att-a1h_1d.cdf',
 'ECOHAB_I/4162-a_1d.cdf',
 'ECOHAB_II/6183-a1h_1d.nc',
 'ECOHAB_I/4333-a_1d.cdf',
 'ECOHAB_I/4163-a1h_1d.cdf',
 'ECOHAB_II/5224cs-a_1d.cdf',
 'ECOHAB_II/6235adc-a_1d.nc',
 'ECOHAB_II/5231mc-a_1d.cdf',
 'ECOHAB_II/6236att-a_1d.nc',
 'ECOHAB_II/5225bsc-a1h_1d.cdf',
 'ECOHAB_II/6233-a1h_1d.nc',
 'ECOHAB_II/5241adc-a_2d.nc',
 'ECOHAB_I/4332sc-a1h_1d.cdf',
 'ECOHAB_I/4351att-a_1d.cdf',
 'ECOHAB_II/6187att-a_1d.nc',
 'ECOHAB_II/5233-a_1d.cdf',
 'ECOHAB_I/4153cs-a1h_1d.cdf',
 'ECOHAB_II/6182s4-a_1d.nc',
 'ECOHAB_II/6236cs-a1h_1d.nc',
 'ECOHAB_I/4351att-a1h_1d.cdf',
 'ECOHAB_II/6187-a_1d.nc',
 'ECOHAB_I/4151-a1h_1d.cdf',
 'ECOHAB_II/6235adc-a_2d.nc',
 'ECOHAB_I/4161att-a1h_1d.cdf',
 'ECOHAB_I/4151sc-a_1d.cdf',
 'ECOHAB_II/6185sc-a1h_1d.nc',
 'ECOHAB_II/6201mc-a1h_1d.nc',
 'ECOHAB_I/4153cs-a_1d.cdf',
 'ECOHAB_II/6223-a_1d.nc',
 'ECOHAB_II/6233-a_1d.nc',
 'ECOHAB_I/4191p-a_1d.cdf',
 'ECOHAB_I/4152-a1h_1d.cdf',
 'ECOHAB_II/5224-a1h_1d.cdf',
 'ECOHAB_II/6224sc-a_1d.nc',
 'ECOHAB_I/4153-a1hlp_1d.nc',
 'ECOHAB_I/4161att-a_1d.cdf',
 'ECOHAB_I/4352-a_1d.cdf',
 'ECOHAB_II/5233sc-a1h_1d.cdf',
 'ECOHAB_II/6225adc-a_2d.nc',
 'ECOHAB_II/6187-a1h_1d.nc',
 'ECOHAB_I/4351sc-a_1d.cdf',
 'ECOHAB_I/4351-a1h_1d.cdf',
 'ECOHAB_I/4191-a1h_1d.cdf',
 'ECOHAB_II/6187cs-a_1d.nc',
 'ECOHAB_II/5261sc-a_1d.cdf',
 'ECOHAB_I/4163cs-a_1d.cdf',
 'ECOHAB_II/6236cs-a_1d.nc',
 'ECOHAB_II/6236att-a1h_1d.nc',
 'ECOHAB_I/4163-a1hlp_1d.nc',
 'ECOHAB_II/5225asc-a1h_1d.cdf',
 'ECOHAB_I/4341-a1h_1d.cdf',
 'ECOHAB_I/4331sc-a1h_1d.cdf',
 'ECOHAB_II/6236-a1h_1d.nc',
 'ECOHAB_II/6181mc-a1h_1d.nc',
 'ECOHAB_I/4152sc-a1h_1d.cdf',
 'ECOHAB_I/4351-a_1d.cdf',
 'ECOHAB_II/5231mc-a1h_1d.cdf',
 'ECOHAB_II/5223asc-a_1d.cdf',
 'ECOHAB_I/4152-a_1d.cdf',
 'ECOHAB_II/6186adc-a_2d.nc',
 'ECOHAB_I/4151-a1hlp_1d.nc',
 'ECOHAB_II/6236-a_1d.nc',
 'ECOHAB_II/5223bsc-a1h_1d.cdf',
 'ECOHAB_II/5234att-a1h_1d.cdf',
 'ECOHAB_I/4171-a_1d.cdf',
 'ECOHAB_I/4151sc-a1h_1d.cdf',
 'ECOHAB_I/4161-a1hlp_1d.nc',
 'ECOHAB_I/4153-a_1d.cdf',
 'ECOHAB_II/5251mc-a1h_1d.cdf',
 'ECOHAB_II/6231mc-a1h_1d.nc',
 'ECOHAB_II/5252sc-a1h_1d.cdf',
 'ECOHAB_II/6181mc-a_1d.nc',
 'ECOHAB_I/4352-a1h_1d.cdf',
 'ECOHAB_II/6185sc-a_1d.nc',
 'ECOHAB_II/5234att-a_1d.cdf',
 'ECOHAB_II/6187cs-a1h_1d.nc',
 'ECOHAB_II/6222s4-a_1d.nc',
 'ECOHAB_II/6186adc-a_1d.nc',
 'ECOHAB_II/5221mc-a1h_1d.cdf',
 'ECOHAB_II/5233sc-a_1d.cdf',
 'ECOHAB_II/5261att-a1h_1d.cdf',
 'ECOHAB_II/5233-a1h_1d.cdf',
 'ECOHAB_II/6234sc-a_1d.nc',
 'ECOHAB_II/6221mc-a_1d.nc']

In [7]:
for rec,item in csw.records.iteritems():
    print item.title


6211mc-a1h.nc - Ecology of Harmful Algal Blooms (ECOHAB-II)
6221mc-a1h.nc - Ecology of Harmful Algal Blooms (ECOHAB-II)
6191mc-a1h.nc - Ecology of Harmful Algal Blooms (ECOHAB-II)
4161-a1h.cdf - Ecology of Harmful Algal Blooms (ECOHAB-I)
4163-a.cdf - Ecology of Harmful Algal Blooms (ECOHAB-I)
6225adc-a.nc - Ecology of Harmful Algal Blooms (ECOHAB-II)
4151att-a1h.cdf - Ecology of Harmful Algal Blooms (ECOHAB-I)
6226cs-a.nc - Ecology of Harmful Algal Blooms (ECOHAB-II)
5223-a1h.cdf - Ecology of Harmful Algal Blooms (ECOHAB-II)
6226-a1h.nc - Ecology of Harmful Algal Blooms (ECOHAB-II)
5225bsc-a.cdf - Ecology of Harmful Algal Blooms (ECOHAB-II)
6224sc-a1h.nc - Ecology of Harmful Algal Blooms (ECOHAB-II)
6211mc-a.nc - Ecology of Harmful Algal Blooms (ECOHAB-II)
6231mc-a.nc - Ecology of Harmful Algal Blooms (ECOHAB-II)
6226cs-a1h.nc - Ecology of Harmful Algal Blooms (ECOHAB-II)
4162-a1h.cdf - Ecology of Harmful Algal Blooms (ECOHAB-I)
4333-a1h.cdf - Ecology of Harmful Algal Blooms (ECOHAB-I)
5261sc-a1h.cdf - Ecology of Harmful Algal Blooms (ECOHAB-II)
4331-a.cdf - Ecology of Harmful Algal Blooms (ECOHAB-I)
5251mc-a.cdf - Ecology of Harmful Algal Blooms (ECOHAB-II)
5261att-a.cdf - Ecology of Harmful Algal Blooms (ECOHAB-II)
6232s4-a.nc - Ecology of Harmful Algal Blooms (ECOHAB-II)
4163cs-a1h.cdf - Ecology of Harmful Algal Blooms (ECOHAB-I)
4351sc-a1h.cdf - Ecology of Harmful Algal Blooms (ECOHAB-I)
4162-a1hlp.nc - Ecology of Harmful Algal Blooms (ECOHAB-I)
5224-a.cdf - Ecology of Harmful Algal Blooms (ECOHAB-II)
4332sc-a.cdf - Ecology of Harmful Algal Blooms (ECOHAB-I)
6191mc-a.nc - Ecology of Harmful Algal Blooms (ECOHAB-II)
4152-a1hlp.nc - Ecology of Harmful Algal Blooms (ECOHAB-I)
5223asc-a1h.cdf - Ecology of Harmful Algal Blooms (ECOHAB-II)
5234-a.cdf - Ecology of Harmful Algal Blooms (ECOHAB-II)
4161-a.cdf - Ecology of Harmful Algal Blooms (ECOHAB-I)
5234-a1h.cdf - Ecology of Harmful Algal Blooms (ECOHAB-II)
5223-a.cdf - Ecology of Harmful Algal Blooms (ECOHAB-II)
4161sc-a1h.cdf - Ecology of Harmful Algal Blooms (ECOHAB-I)
5225asc-a.cdf - Ecology of Harmful Algal Blooms (ECOHAB-II)
6223-a1h.nc - Ecology of Harmful Algal Blooms (ECOHAB-II)
4341-a.cdf - Ecology of Harmful Algal Blooms (ECOHAB-I)
4163att-a.cdf - Ecology of Harmful Algal Blooms (ECOHAB-I)
4153att-a1h.cdf - Ecology of Harmful Algal Blooms (ECOHAB-I)
4333cs-a1h.cdf - Ecology of Harmful Algal Blooms (ECOHAB-I)
6234sc-a1h.nc - Ecology of Harmful Algal Blooms (ECOHAB-II)
4332-a.cdf - Ecology of Harmful Algal Blooms (ECOHAB-I)
5224cs-a1h.cdf - Ecology of Harmful Algal Blooms (ECOHAB-II)
6226att-a.nc - Ecology of Harmful Algal Blooms (ECOHAB-II)
4151-a.cdf - Ecology of Harmful Algal Blooms (ECOHAB-I)
4331-a1h.cdf - Ecology of Harmful Algal Blooms (ECOHAB-I)
4152sc-a.cdf - Ecology of Harmful Algal Blooms (ECOHAB-I)
4161sc-a.cdf - Ecology of Harmful Algal Blooms (ECOHAB-I)
6226att-a1h.nc - Ecology of Harmful Algal Blooms (ECOHAB-II)
4331sc-a.cdf - Ecology of Harmful Algal Blooms (ECOHAB-I)
617Apt-a.nc - Ecology of Harmful Algal Blooms (ECOHAB-II)
4333cs-a.cdf - Ecology of Harmful Algal Blooms (ECOHAB-I)
5252sc-a.cdf - Ecology of Harmful Algal Blooms (ECOHAB-II)
4151att-a.cdf - Ecology of Harmful Algal Blooms (ECOHAB-I)
4153-a1h.cdf - Ecology of Harmful Algal Blooms (ECOHAB-I)
5221mc-a.cdf - Ecology of Harmful Algal Blooms (ECOHAB-II)
617Apt-a1h.nc - Ecology of Harmful Algal Blooms (ECOHAB-II)
4153att-a.cdf - Ecology of Harmful Algal Blooms (ECOHAB-I)
4332-a1h.cdf - Ecology of Harmful Algal Blooms (ECOHAB-I)
6187att-a1h.nc - Ecology of Harmful Algal Blooms (ECOHAB-II)
4171-a1h.cdf - Ecology of Harmful Algal Blooms (ECOHAB-I)
6226-a.nc - Ecology of Harmful Algal Blooms (ECOHAB-II)
5241adc-a.nc - Ecology of Harmful Algal Blooms (ECOHAB-II)
6201mc-a.nc - Ecology of Harmful Algal Blooms (ECOHAB-II)
5223bsc-a.cdf - Ecology of Harmful Algal Blooms (ECOHAB-II)
4163att-a1h.cdf - Ecology of Harmful Algal Blooms (ECOHAB-I)
4162-a.cdf - Ecology of Harmful Algal Blooms (ECOHAB-I)
6183-a1h.nc - Ecology of Harmful Algal Blooms (ECOHAB-II)
4333-a.cdf - Ecology of Harmful Algal Blooms (ECOHAB-I)
4163-a1h.cdf - Ecology of Harmful Algal Blooms (ECOHAB-I)
5224cs-a.cdf - Ecology of Harmful Algal Blooms (ECOHAB-II)
6235adc-a.nc - Ecology of Harmful Algal Blooms (ECOHAB-II)
5231mc-a.cdf - Ecology of Harmful Algal Blooms (ECOHAB-II)
6236att-a.nc - Ecology of Harmful Algal Blooms (ECOHAB-II)
5225bsc-a1h.cdf - Ecology of Harmful Algal Blooms (ECOHAB-II)
6233-a1h.nc - Ecology of Harmful Algal Blooms (ECOHAB-II)
5241adc-a.nc - Ecology of Harmful Algal Blooms (ECOHAB-II)
4332sc-a1h.cdf - Ecology of Harmful Algal Blooms (ECOHAB-I)
4351att-a.cdf - Ecology of Harmful Algal Blooms (ECOHAB-I)
6187att-a.nc - Ecology of Harmful Algal Blooms (ECOHAB-II)
5233-a.cdf - Ecology of Harmful Algal Blooms (ECOHAB-II)
4153cs-a1h.cdf - Ecology of Harmful Algal Blooms (ECOHAB-I)
6182s4-a.nc - Ecology of Harmful Algal Blooms (ECOHAB-II)
6236cs-a1h.nc - Ecology of Harmful Algal Blooms (ECOHAB-II)
4351att-a1h.cdf - Ecology of Harmful Algal Blooms (ECOHAB-I)
6187-a.nc - Ecology of Harmful Algal Blooms (ECOHAB-II)
4151-a1h.cdf - Ecology of Harmful Algal Blooms (ECOHAB-I)
6235adc-a.nc - Ecology of Harmful Algal Blooms (ECOHAB-II)
4161att-a1h.cdf - Ecology of Harmful Algal Blooms (ECOHAB-I)
4151sc-a.cdf - Ecology of Harmful Algal Blooms (ECOHAB-I)
6185sc-a1h.nc - Ecology of Harmful Algal Blooms (ECOHAB-II)
6201mc-a1h.nc - Ecology of Harmful Algal Blooms (ECOHAB-II)
4153cs-a.cdf - Ecology of Harmful Algal Blooms (ECOHAB-I)
6223-a.nc - Ecology of Harmful Algal Blooms (ECOHAB-II)
6233-a.nc - Ecology of Harmful Algal Blooms (ECOHAB-II)
4191p-a.cdf - Ecology of Harmful Algal Blooms (ECOHAB-I)
4152-a1h.cdf - Ecology of Harmful Algal Blooms (ECOHAB-I)
5224-a1h.cdf - Ecology of Harmful Algal Blooms (ECOHAB-II)
6224sc-a.nc - Ecology of Harmful Algal Blooms (ECOHAB-II)
4153-a1hlp.nc - Ecology of Harmful Algal Blooms (ECOHAB-I)
4161att-a.cdf - Ecology of Harmful Algal Blooms (ECOHAB-I)
4352-a.cdf - Ecology of Harmful Algal Blooms (ECOHAB-I)
5233sc-a1h.cdf - Ecology of Harmful Algal Blooms (ECOHAB-II)
6225adc-a.nc - Ecology of Harmful Algal Blooms (ECOHAB-II)
6187-a1h.nc - Ecology of Harmful Algal Blooms (ECOHAB-II)
4351sc-a.cdf - Ecology of Harmful Algal Blooms (ECOHAB-I)
4351-a1h.cdf - Ecology of Harmful Algal Blooms (ECOHAB-I)
4191-a1h.cdf - Ecology of Harmful Algal Blooms (ECOHAB-I)
6187cs-a.nc - Ecology of Harmful Algal Blooms (ECOHAB-II)
5261sc-a.cdf - Ecology of Harmful Algal Blooms (ECOHAB-II)
4163cs-a.cdf - Ecology of Harmful Algal Blooms (ECOHAB-I)
6236cs-a.nc - Ecology of Harmful Algal Blooms (ECOHAB-II)
6236att-a1h.nc - Ecology of Harmful Algal Blooms (ECOHAB-II)
4163-a1hlp.nc - Ecology of Harmful Algal Blooms (ECOHAB-I)
5225asc-a1h.cdf - Ecology of Harmful Algal Blooms (ECOHAB-II)
4341-a1h.cdf - Ecology of Harmful Algal Blooms (ECOHAB-I)
4331sc-a1h.cdf - Ecology of Harmful Algal Blooms (ECOHAB-I)
6236-a1h.nc - Ecology of Harmful Algal Blooms (ECOHAB-II)
6181mc-a1h.nc - Ecology of Harmful Algal Blooms (ECOHAB-II)
4152sc-a1h.cdf - Ecology of Harmful Algal Blooms (ECOHAB-I)
4351-a.cdf - Ecology of Harmful Algal Blooms (ECOHAB-I)
5231mc-a1h.cdf - Ecology of Harmful Algal Blooms (ECOHAB-II)
5223asc-a.cdf - Ecology of Harmful Algal Blooms (ECOHAB-II)
4152-a.cdf - Ecology of Harmful Algal Blooms (ECOHAB-I)
6186adc-a.nc - Ecology of Harmful Algal Blooms (ECOHAB-II)
4151-a1hlp.nc - Ecology of Harmful Algal Blooms (ECOHAB-I)
6236-a.nc - Ecology of Harmful Algal Blooms (ECOHAB-II)
5223bsc-a1h.cdf - Ecology of Harmful Algal Blooms (ECOHAB-II)
5234att-a1h.cdf - Ecology of Harmful Algal Blooms (ECOHAB-II)
4171-a.cdf - Ecology of Harmful Algal Blooms (ECOHAB-I)
4151sc-a1h.cdf - Ecology of Harmful Algal Blooms (ECOHAB-I)
4161-a1hlp.nc - Ecology of Harmful Algal Blooms (ECOHAB-I)
4153-a.cdf - Ecology of Harmful Algal Blooms (ECOHAB-I)
5251mc-a1h.cdf - Ecology of Harmful Algal Blooms (ECOHAB-II)
6231mc-a1h.nc - Ecology of Harmful Algal Blooms (ECOHAB-II)
5252sc-a1h.cdf - Ecology of Harmful Algal Blooms (ECOHAB-II)
6181mc-a.nc - Ecology of Harmful Algal Blooms (ECOHAB-II)
4352-a1h.cdf - Ecology of Harmful Algal Blooms (ECOHAB-I)
6185sc-a.nc - Ecology of Harmful Algal Blooms (ECOHAB-II)
5234att-a.cdf - Ecology of Harmful Algal Blooms (ECOHAB-II)
6187cs-a1h.nc - Ecology of Harmful Algal Blooms (ECOHAB-II)
6222s4-a.nc - Ecology of Harmful Algal Blooms (ECOHAB-II)
6186adc-a.nc - Ecology of Harmful Algal Blooms (ECOHAB-II)
5221mc-a1h.cdf - Ecology of Harmful Algal Blooms (ECOHAB-II)
5233sc-a.cdf - Ecology of Harmful Algal Blooms (ECOHAB-II)
5261att-a1h.cdf - Ecology of Harmful Algal Blooms (ECOHAB-II)
5233-a1h.cdf - Ecology of Harmful Algal Blooms (ECOHAB-II)
6234sc-a.nc - Ecology of Harmful Algal Blooms (ECOHAB-II)
6221mc-a.nc - Ecology of Harmful Algal Blooms (ECOHAB-II)

In [8]:
# get specific ServiceType URL from records
def service_urls(records,service_string='urn:x-esri:specification:ServiceType:odp:url'):
    urls=[]
    for key,rec in records.iteritems():
        #create a generator object, and iterate through it until the match is found
        #if not found, gets the default value (here "none")
        url = next((d['url'] for d in rec.references if d['scheme'] == service_string), None)
        if url is not None:
            urls.append(url)
    return urls

In [9]:
dap_urls = service_urls(csw.records,service_string='urn:x-esri:specification:ServiceType:odp:url')
print ".html\n".join(dap_urls)


http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6211mc-a1h_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6221mc-a1h_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6191mc-a1h_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4161-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4163-a_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6225adc-a_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4151att-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6226cs-a_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/5223-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6226-a1h_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/5225bsc-a_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6224sc-a1h_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6211mc-a_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6231mc-a_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6226cs-a1h_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4162-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4333-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/5261sc-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4331-a_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/5251mc-a_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/5261att-a_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6232s4-a_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4163cs-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4351sc-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4162-a1hlp_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/5224-a_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4332sc-a_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6191mc-a_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4152-a1hlp_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/5223asc-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/5234-a_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4161-a_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/5234-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/5223-a_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4161sc-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/5225asc-a_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6223-a1h_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4341-a_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4163att-a_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4153att-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4333cs-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6234sc-a1h_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4332-a_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/5224cs-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6226att-a_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4151-a_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4331-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4152sc-a_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4161sc-a_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6226att-a1h_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4331sc-a_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/617Apt-a_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4333cs-a_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/5252sc-a_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4151att-a_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4153-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/5221mc-a_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/617Apt-a1h_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4153att-a_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4332-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6187att-a1h_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4171-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6226-a_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/5241adc-a_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6201mc-a_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/5223bsc-a_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4163att-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4162-a_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6183-a1h_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4333-a_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4163-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/5224cs-a_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6235adc-a_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/5231mc-a_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6236att-a_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/5225bsc-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6233-a1h_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/5241adc-a_2d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4332sc-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4351att-a_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6187att-a_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/5233-a_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4153cs-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6182s4-a_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6236cs-a1h_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4351att-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6187-a_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4151-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6235adc-a_2d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4161att-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4151sc-a_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6185sc-a1h_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6201mc-a1h_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4153cs-a_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6223-a_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6233-a_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4191p-a_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4152-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/5224-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6224sc-a_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4153-a1hlp_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4161att-a_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4352-a_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/5233sc-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6225adc-a_2d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6187-a1h_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4351sc-a_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4351-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4191-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6187cs-a_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/5261sc-a_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4163cs-a_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6236cs-a_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6236att-a1h_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4163-a1hlp_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/5225asc-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4341-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4331sc-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6236-a1h_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6181mc-a1h_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4152sc-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4351-a_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/5231mc-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/5223asc-a_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4152-a_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6186adc-a_2d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4151-a1hlp_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6236-a_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/5223bsc-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/5234att-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4171-a_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4151sc-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4161-a1hlp_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4153-a_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/5251mc-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6231mc-a1h_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/5252sc-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6181mc-a_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4352-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6185sc-a_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/5234att-a_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6187cs-a1h_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6222s4-a_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6186adc-a_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/5221mc-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/5233sc-a_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/5261att-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/5233-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6234sc-a_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6221mc-a_1d.nc

In [10]:
def standard_names(nc):
    '''
    get dictionary of variables with standard_names
    '''
    d={}
    for k,v in nc.iteritems():
        try:
            standard_name=v.getncattr('standard_name')
            try:
                d[standard_name]=[d[standard_name],[k]]
            except:
                d[standard_name]=[k]
        except:
            pass
    return d

In [11]:
def long_names(nc):
    '''
    get dictionary of variables with long_names
    '''
    d={}
    for k,v in nc.iteritems():
        try:
            long_name=v.getncattr('long_name').strip()
            try:
                d[long_name]=[d[long_name],[k]]
            except:
                d[long_name]=[k]
        except:
            pass
    return d

In [12]:
def names(nc):
    '''
    get dictionary of variables with names
    '''
    d={}
    for k,v in nc.iteritems():
        try:
            name=v.getncattr('name').strip()
            try:
                d[name]=[d[name],[k]]
            except:
                d[name]=[k]
        except:
            pass
    return d

In [13]:
dap_urls = [url for url in dap_urls if '-a1h_1d' in url]
print ".html\n".join(dap_urls)


http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6211mc-a1h_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6221mc-a1h_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6191mc-a1h_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4161-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4151att-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/5223-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6226-a1h_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6224sc-a1h_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6226cs-a1h_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4162-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4333-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/5261sc-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4163cs-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4351sc-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/5223asc-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/5234-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4161sc-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6223-a1h_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4153att-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4333cs-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6234sc-a1h_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/5224cs-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4331-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6226att-a1h_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4153-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/617Apt-a1h_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4332-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6187att-a1h_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4171-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4163att-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6183-a1h_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4163-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/5225bsc-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6233-a1h_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4332sc-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4153cs-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6236cs-a1h_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4351att-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4151-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4161att-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6185sc-a1h_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6201mc-a1h_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4152-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/5224-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/5233sc-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6187-a1h_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4351-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4191-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6236att-a1h_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/5225asc-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4341-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4331sc-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6236-a1h_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6181mc-a1h_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4152sc-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/5231mc-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/5223bsc-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/5234att-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4151sc-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/5251mc-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6231mc-a1h_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/5252sc-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4352-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6187cs-a1h_1d.nc.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/5221mc-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/5261att-a1h_1d.cdf.html
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/5233-a1h_1d.cdf

In [14]:
long_name='ATTENUATION'

In [15]:
for url in dap_urls:
    ncd = netCDF4.Dataset(url)
    nc = ncd.variables

    # make a dictionary containing all data from variables that matched the standard_name
    # find list of variables for each standard_name
    d = long_names(nc)
    # find all the variables matching standard_name=std_name
    if long_name in d:
        # read all the data into a dictionary
        lat = nc['lat'][:]
        lon = nc['lon'][:]
        depth = nc['depth'][:]
        try: 
            water_depth = str(ncd.WATER_DEPTH)
        except: 
            try: 
                water_depth = str(ncd.water_depth)
            except:
                water_depth = 'unknown'
                
        time_var = nc['time']
        dtime = netCDF4.num2date(time_var[:],time_var.units)
        data_dict={}
        for v in d[long_name]:
            data_dict[v]=nc[v][:].flatten()
            print url
        # Create Pandas data frame, with time index
        ts = pd.DataFrame.from_dict(data_dict)
        ts.index=dtime
        ts.plot(figsize=(12,4));
        title('%s, %s, depth=%4.2f, water_depth=%s' % (url[-30:],long_name, depth, water_depth))


http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4151att-a1h_1d.cdf
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6224sc-a1h_1d.nc
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4153att-a1h_1d.cdf
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6234sc-a1h_1d.nc
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6226att-a1h_1d.nc
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6187att-a1h_1d.nc
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4163att-a1h_1d.cdf
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4351att-a1h_1d.cdf
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_I/4161att-a1h_1d.cdf
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6185sc-a1h_1d.nc
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6236att-a1h_1d.nc
http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/5234att-a1h_1d.cdf

In [16]:
ncd = netCDF4.Dataset(url)

In [17]:
ncd.WATER_DEPTH


Out[17]:
39

In [18]:
name='SDP'
for url in dap_urls:
    ncd = netCDF4.Dataset(url)
    nc = ncd.variables

    # make a dictionary containing all data from variables that matched the standard_name
    # find list of variables for each standard_name
    d = names(nc)
    # find all the variables matching standard_name=std_name
    if name in d:
        # read all the data into a dictionary
        lat = nc['lat'][:]
        lon = nc['lon'][:]
        depth = nc['depth'][:]
        try: 
            water_depth = str(ncd.WATER_DEPTH)
        except: 
            try: 
                water_depth = str(ncd.water_depth)
            except:
                water_depth = 'unknown'
                
        time_var = nc['time']
        dtime = netCDF4.num2date(time_var[:],time_var.units)
        data_dict={}
        for v in d[name]:
            data_dict[v]=nc[v][:].flatten()
            print url
        # Create Pandas data frame, with time index
        ts = pd.DataFrame.from_dict(data_dict)
        ts.index=dtime
        ts.plot(figsize=(12,4));
        title('%s, %s, depth=%4.2f, water_depth=%s' % (url[-30:],name, depth, water_depth))

In [19]:
import iris
import iris.plot as iplt
import iris.quickplot as qplt
bathy_url='http://geoport.whoi.edu/thredds/dodsC/bathy/gom03_v1_0'
c = iris.load(bathy_url)

In [20]:
slice=c[0].extract(iris.Constraint(
    longitude=lambda cell: box[0] < cell < box[2],
    latitude=lambda cell: box[1] < cell < box[3]))

In [21]:
url='http://geoport-dev.whoi.edu/thredds/dodsC/ECOHAB_II/6226att-a1h_1d.nc'
ncd=netCDF4.Dataset(url)
nc = ncd.variables

In [22]:
lon=nc['lon'][:]
lat=nc['lat'][:]

In [23]:
figure(figsize=(12,8))
latb = slice.coord(axis='Y').points
lonb = slice.coord(axis='X').points
subplot(111,aspect=(1.0/cos(mean(latb)*pi/180.0)))

pcolormesh(lonb,latb,ma.masked_invalid(slice.data),vmin=-200,vmax=0)
colorbar()
contour(lonb,latb,ma.masked_invalid(slice.data),[-100, -50, 0],colors=['k','k','k'])
plot(lon,lat,'mo',markersize=12)


Out[23]:
[<matplotlib.lines.Line2D at 0x9c37b10>]

In [24]:
long_name='STAND. DEV. (PRESS)'

In [25]:
lat


Out[25]:
array([ 43.70033264], dtype=float32)

In [26]:
url='http://geoport.whoi.edu/thredds/dodsC/ECOHAB_II/5211psd-a1h.nc'
ncd = netCDF4.Dataset(url)
nc = ncd.variables


---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-26-9711cb19dd11> in <module>()
      1 url='http://geoport.whoi.edu/thredds/dodsC/ECOHAB_II/5211psd-a1h.nc'
----> 2 ncd = netCDF4.Dataset(url)
      3 nc = ncd.variables

/home/local/python27_epd/lib/python2.7/site-packages/netCDF4.so in netCDF4.Dataset.__init__ (netCDF4.c:15904)()

RuntimeError: NetCDF: Malformed or inaccessible DAP DDS

In [ ]:
nc.keys()

In [ ]:
print nc['SDP_850']

In [ ]:
dap_urls

In [ ]:
ncd

In [ ]:
('WATER_DEPTH' in ncd.ncattrs()) or ('water_depth' in ncd.ncattrs())

In [ ]: