The ONC Python client library contains a number of classes and functions that make access to the ONC data, through the Oceans 2.0 API, quick and easy to use.
Installation
The ONC Python client library can be installed using the pip command found in the Scripts folder of your python install.
$ pip install onc
History
version | Date | Description | Package |
---|---|---|---|
1.0 | 6/9/2017 | Beta version | onc-1.0.tar.gz |
1.1 | 6/12/2016 | Rename onc.dap.DAP class to onc.dap.ERDDAP | onc-1.1.tar.gz |
Classes
class | import | description |
---|---|---|
onc | from onc.onc import ONC | A wrapper class for access to Oceans 2.0 API web services |
sos | from onc.sos import SOS | A wrapper class for access to ONC's implementation of Sensor Observation Service (SOS) |
erddap | from onc.dap import ERDDAP | A wrapper class for access to datasets published on ONC's ERDDAP (OPeNDAP) server http://qadap.onc.uvic.ca/erddap/index.html |
nerc | from onc.nerc import NERC | A wrapper class for access to controlled vocabularies stored on the NERC vocabulary server http://vocab.nerc.ac.uk/ |
onc
Description
This class provides a wrapper for some for the most common Oceans 2.0 API requests, including the discovery services (locations, devices, deviceCategories, properties) and delivery (dataProductDelivery, scalardata and rawdata).
constructor
ONC(token, production=True, showInfo=False, outPath='c:/temp')
Parameter | Type | Description | Example |
---|---|---|---|
Required | |||
token | string | All Web Services require a token. This can be generated at http://dmas.uvic.ca/Profile. Click on the "Web Services" tab and click "Generate Token" | token=5ba514e8-1203-428c-8835-879c8173e387 |
Optional | |||
production | boolean | Indicates if the ONC Production server URL is used for service requests.
| True or False |
showInfo | boolean | Indicates if verbose script messages are displayed, such as request url and processing time information.
| True or False |
outPath | string | The path that downloaded files are saved to.
| 'c:/ONC/Download' |
Usage
from onc.onc import ONC onc = ONC('YOUR_TOKEN_HERE')
Or
from onc.onc import ONC isProduction = True showInfo = False outPath = 'c:/ONC/Data' onc = ONC('YOUR_TOKEN_HERE',isProduction,showInfo,outPath)
methods
getLocations(parameters={})
Returns a list of locations, as a list of dictionary objects.
Parameter | Type | Description | Example |
---|---|---|---|
Optional | |||
parameters | dictionary | A dictionary of parameters, used to filter data from the ONC devices endpoint.
| {'locationCode':'BACAX'} |
getDevices(parameters={})
Returns a list of devices, as a list of dictionary objects.
Parameter | Type | Description | Example |
---|---|---|---|
Optional | |||
parameters | dictionary | A dictionary of parameters, used to filter data from the ONC devices endpoint.
| {'deviceCode':'NORTEKADCP9917'} |
getDeviceCategories(parameters={})
Returns a list of deviceCategories, as a list of dictionary objects.
Parameter | Type | Description | Example |
---|---|---|---|
Optional | |||
parameters | dictionary | A dictionary of parameters, used to filter data from the ONC deviceCategories endpoint.
| {'deviceCategoryCode':'HYDROPHONE'} |
getProperties(parameters={})
Returns a list of properties, as a list of dictionary objects.
Parameter | Type | Description | Example |
---|---|---|---|
Optional | |||
parameters | dictionary | A dictionary of parameters, used to filter data from the ONC properties endpoint.
| {'propertyCode':'seawatertemperature'} |
getDataProducts(parameters={})
Returns a list of data products as a list of dictionary objects.
Parameter | Type | Description | Example |
---|---|---|---|
Optional | |||
parameters | dictionary | A dictionary of parameters, used to filter data from the ONC dataProducts endpoint.
| {'dataProductCode':'TSSD','extension':'json'} |
orderDataProduct(parameters={})
Requests a data product and downloads the generated files to the class's outPath. Status messages
Parameter | Type | Description | Example |
---|---|---|---|
Required | |||
parameters | dictionary | A dictionary of parameters, used to request data as a data product from the ONC dataProductDelivery endpoint.
| {'dataProductCode':'TSSD','extension':'json'} |
orderDataProduct(parameters={}, returnError=False)
runDataProduct(requestId)
downloadDataProduct(runId, fileCount, estimatedProcessingTime=1, maxRetries=100, downloadResultsOnly=False, includeMetadataFile=False, multiThreadMessages=False)
downloadDataProductIndex(runId, url, parameters, downloadResultsOnly, includeMetadataFile, multiThreadMessages,indx=1, fileCount=1, estimatedProcessingTime=1, maxRetries=100)
downloadFile(url, file, multiThreadMessages=False)
getJsonDataProduct(parameters, maxRetries=100)
getJsonFromUrl(url)
getDataProductUrls(parameters, maxRetries=100)