Thredds Client for Python
Installing Thredds Client
Anaconda
Thredds client is available as Anaconda package. Install it with the following command:
$ conda install -c birdhouse threddsclient
From github
Prepare a conda environment with the Python dependencies and activate it:
$ conda create python=2.7 lxml beautiful-soup requests -n threddsclient
$ source activate threddsclient
Clone the threddslclient github repo and install the Python module:
$ git clone https://github.com/bird-house/threddsclient.git
$ cd threddsclient
$ python setup.py develop
Using Thredds Client
Read the Thredds tutorial on catalogs: Thredds Catalog Primer
Get download URLs of a catalog
import threddsclient
urls = threddsclient.download_urls('http://example.com/thredds/catalog.xml')
Get OpenDAP URLs of a catalog
import threddsclient
urls = threddsclient.opendap_urls('http://example.com/thredds/catalog.xml')
Navigate in catalog
Start reading a catalog
import threddsclient
cat = threddsclient.read_url('http://example.com/thredds/catalog.xml')
Get a list of references to other catalogs & follow them
refs = cat.references
print refs[0].name
cat2 = refs[0].follow()
Get a list of datasets in this catalog
data = cat.datasets
Get flat list of all direct datasets (data files) in the catalog
datasets = cat.flat_datasets()
Get flat list of all references in the catalog
references = cat.flat_references()