auscophub.client

Functions for client programs to access to the AusCopernicusHub server. Initially this is centred around accessing the THREDDS server, but other client access methods could go in here as well.

These routines can be used to build client-side applications for searching and downloading data.

exception auscophub.client.AusCopHubClientError
class auscophub.client.ThreddsCatalogRefEntry(catalogRefNode, baseUrl)

Details of a <catalogRef> tag in the catalog.xml

class auscophub.client.ThreddsDatasetEntry(datasetNode)

Details of a <dataset> tag in the catalog.xml

class auscophub.client.ThreddsServerDirList(urlOpener, subdirUrl)

Connect to the THREDDS server and create an object which lists the “interesting” pieces of the catalog.xml for the given subdirectory.

subdirs

list of ThreddsCatalogRefEntry objects, for subdirectories under this one, i.e. <catalogRef> tags

datasets

list of ThreddsDatasetEntry objects, for datasets in this subdir, i.e. <dataset> tags

auscophub.client.decodeDegreesStr(valStr)

Return a signed latitude/longitude value from a string. Only copes with the integer values used in grid cell names.

auscophub.client.getDescriptionMetaFromThreddsByBounds(urlOpener, sentinelNumber, instrumentStr, productId, startDate, endDate, longLatBoundingBox)

Search the THREDDS server and return a list of AusCopHubMeta objects for the given sentinel number, the given product, and are within the time and location bounds given. These can be filtered further.

Parameters:
  • urlOpener – Object as created by the makeUrlOpener() function

  • sentinelNumber (int) – an integer (i.e. 1, 2 or 3), identifying which Sentinel family

  • instrumentStr (str) – Which instrument - specific to each Sentinel family. Possible values are - Sentinel-1: C-SAR; Sentinel-2: MSI; Sentinel-3: one of {OLCI, SLSTR, SRAL, MWR}.

  • productId (str) – Which data product - specific to each Sentinel family. Possible values are - Sentinel-1: one of {SLC, GRD}; Sentinel-2: L1C; Sentinel-3: As yet unknown.

  • startdate (str) – Earliest acquisition date to include, as yyyymmdd

  • endDate (str) – Latest acquisition date to include, as yyyymmdd

  • boundingBox (tuple) – Search region lat/long bounding box in decimal degrees, in the form (westLong, eastLong, southLat, northLat), with negative values for south of equator and west of Greenwich.

In future, support may be added for products RAW and OCN for Sentinel-1, and L2A for Sentinel-2.

Warning

Note that we do not (yet) cope with the boundingBox crossing the international date line

Returns:

A list of tuples of the form (urlStr, metaObj) where urlStr is the URL of the XML file on the server, and metaObj is the AusCopHubMeta object holding the contents of the XML file, read from the server.

auscophub.client.getThreddsCatalogXml(urlOpener, baseUrl, returnXmlString=False)

Get the catalog.xml file for the given baseUrl By default, it will parse the catalog.xml using minidom and return the document object. If the XML fails to parse, then the return value will be None.

If returnXmlString is True, then just return the XML string, without parsing.

auscophub.client.gridCellDirWithinBounds(gridCellDirName, northLat, southLat, westLong, eastLong)

Return True if the given grid cell directory name lies at least partially within the lat/long bounds given.

auscophub.client.loadDatasetDescriptionXmlList(urlOpener, xmlDatasetEntryList)

Given a list of DatasetEntry object, all of which correspond to .xml files on the server, load the XML into AusCopHubMeta objects and return a list of these objects.

auscophub.client.makeUrlOpener(proxy=None)

Use the crazy urllib2 routines to make a thing which can open a URL, with proxy handling if required. Return an opener object, which is used as

reader = opener.open(url)