You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 97 Next »

The ONC Python client library contains a number of classes and functions that access the ONC data, through the Oceans 2.0 API.

Classes

classimportdescription
ONCfrom onc.onc import ONCA wrapper class for access to Oceans 2.0 API web services.
SOSfrom onc.sos import SOSA wrapper class for access to ONC's implementation of Sensor Observation Service (SOS).
ERDDAPfrom onc.dap import ERDDAPA wrapper class for access to datasets published on ONC's ERDDAP (OPeNDAP) server http://qadap.onc.uvic.ca/erddap/index.html.
NERCfrom onc.nerc import NERCA wrapper class for access to controlled vocabularies stored on the NERC vocabulary server http://vocab.nerc.ac.uk/.


ONC Class

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()

ONC(token, production=True, showInfo=False, outPath='c:/temp')

Parameter
Type
Description
Example
Required


tokenstringAll Web Services require a token. Once logged in at https://data.oceannetworks.ca/login, your token can be retrieved or generated at https://data.oceannetworks.ca/Profile. Click on the "Web Services" tab, then click "Generate Token".token=YOUR_TOKEN_HERE
Optional


productionboolean

Indicates whether the ONC Production server URL is used for service requests.

  • Default is True.
  • False is intended for internal ONC testing only.
  • All non-ONC users must use True or leave blank. Non-ONC user IP addresses are blocked from accessing the Oceans 2.0 QA server.
True or False
showInfoboolean

Indicates whether verbose script messages are displayed, such as request url and processing time information.

  • Default is False.
  • True is intended for script debugging.
True or False
outPathstring

The path that downloaded files are saved to.

  • Default is 'c:/Temp'.
  • Full path will be created if it does not already exist.
'c:/ONC/Download'


Usage

from onc.onc import ONC
onc = ONC('YOUR_TOKEN_HERE')

or

from onc.onc import ONC

production = True
showInfo = False
outPath = 'c:/ONC/Data'
onc = ONC('YOUR_TOKEN_HERE',production,showInfo,outPath)


Discovery methods

getLocations()

getLocations(filters={})


Returns a list of locations, as a list of dictionary objects that meet the criteria defined by the input filters.


Parameter
Type
Description
Example
Optional


filtersdictionary

A dictionary of one or more filter criteria, used to return an exclusive set of location elements from the ONC locations endpoint.

{'locationCode':'BACAX'}


Returns

A list of location objects.

[
   {
      "deployments": 50,
      "locationName": "Axis ",
      "depth": 984.3076,
      "bbox": {
         "maxDepth": 987,
         "maxLat": 48.316837,
         "maxLon": -126.050125,
         "minDepth": 981,
         "minLat": 48.316517,
         "minLon": -126.05087
      },
      "description": "Depth: 985 m Latitude: 48.3167 Longitude: -126.0501 Type: Stationary platform Description: Canyon axis: benthic processes, biodiversity, sediment dynamics.",
      "hasDeviceData": "true",
      "lon": -126.05033,
      "locationCode": "BACAX",
      "hasPropertyData": "true",
      "lat": 48.31669,
      "dataSearchURL": "https://data.oceannetworks.ca/DataSearch?location=BACAX"
   }
]
Property
Type
Description
Example
location[]listA list of location dictionaries.

location[].deployments

intThe number of instrument deployments that meet the filter criteria."deployments" 10
location[].locationNamestringThe full name of the location.
"locationName":"Axis (POD 1)"
location[].depthdoubleThe average depth of the deployments.
"depth" 75
location[].bboxdictionaryA Bounding Box dictionary.
location[].bbox.maxDepthdoubleThe maximum depth of the deployments."maxDepth" 100
location[].bbox.maxLatdoubleThe maximum Latitude of bounding box of the deployments."maxLat" 48.476740
location[].bbox.maxLondoubleThe maximum Longitude of the bounding box of the deployments."maxLon" : -123.294904
location[].bbox.minDepthdoubleThe minimum Depth of the deployments."minDepth" 50
location[].bbox.minLatdoubleThe minimum Latitude of bounding box of the deployments."minLat" 48.47670
location[].bbox.minLondoubleThe minimum Longitude of the bounding box of the deployments. "minLon" : -123.294900
location[].descriptionstringThe description of the location.
"description":"Depth: 985 m Latitude: 48.3167 Longitude: -126.0501 Type: Stationary platform 
               Description: Canyon axis: benthic processes, biodiversity, sediment dynamics."
location[].hasDeviceDatastringIndicates that data products can be requested using a device category for the location.
"hasDeviceData": "true"
location[].londoubleThe average longitude of the deployments. "lon" : -123.294902
location[].locationCodestringA code that unquely identifies a location.
"locationCode":"BACAX"
location[].hasPropertyDatastringIndicates that data products can be requested using property code for the location.
"hasPropertyData":"true"
location[].latdoubleThe average latitude of the deployments. "lat" 48.47672
location[].dataSearchUrlstringThe location specific Data Search web page URL.
"dataSearchURL":"https://data.oceannetworks.ca/DataSearch?location=BACAX"
Example - Print all locations in North East Pacific with Hydrophones deployed
from onc.onc import ONC
onc = ONC('YOUR_TOKEN_HERE')

locations = onc.getLocations({'locationCode':'NEP', 'deviceCategoryCode':'HYDROPHONE', 'includeChildren':'true'}) #NEP - North East Pacific
print('Locations')

for location in locations:
    locationCode = location['locationCode']
    locationName = location['locationName']
    hasDeviceData = location['hasDeviceData']
    hasPropertyData = location['hasPropertyData']
    if (len(locationCode.split('.')) == 2):
        parentName = onc.getLocationName(locationCode.split('.')[0])
        if (parentName):
            locationName = '{} / {}'.format(parentName,locationName)
    print('  {0} - {1}'.format(locationCode,locationName))
    print('     Request data product using Device Category (Site Device): {}'.format(hasDeviceData))
    print('     Request data product using Property (Primary Sensor): {}'.format(hasPropertyData))
print('{} locations'.format(len(locations)))

getLocationHierarchy()

getLocationHierarchy(filters={})


Returns a hierarchical subtree of locations whose root is defined by the input filter. In this case the only valid input filter is locationCode. In Oceans 2.0 Instruments and Variables are organized by Location so that users can easily drill down by place name or mobile platform name to find the instruments or properties they are interested in.


Parameter

Type

Description

Example

Optional


filtersdictionary

A dictionary of one or more filter criteria, used to return an exclusive set of location elements from the ONC locations endpoint.

{'locationCode':'BACAX'}


Returns

A list of location objects.

[
   {
      "locationName": "Axis ",
      "children": null,
      "description": "Depth: 985 m Latitude: 48.3167 Longitude: -126.0501 Type: Stationary platform Description: Canyon axis: benthic processes, biodiversity, sediment dynamics.",
      "hasDeviceData": "true",
      "locationCode": "BACAX",
      "hasPropertyData": "true",
   }
]

Property

Type

Description

Example
location[]listA list of location dictionaries.

location[].locationNamestringThe full name of the location.
"locationName":"Axis (POD 1)"
location[].children[]listA list of location dictionaries that are the children of this location dictionary.
"children" : null
location[].descriptionstringThe description of the location.
"description":"Depth: 985 m Latitude: 48.3167 Longitude: -126.0501 Type: Stationary platform 
               Description: Canyon axis: benthic processes, biodiversity, sediment dynamics."
location[].hasDeviceDatastringIndicates that data products can be requested using a device category for the location.
"hasDeviceData": "true"
location[].locationCodestringA code that unquely identifies a location.
"locationCode":"BACAX"
location[].hasPropertyDatastringIndicates that data products can be requested using property code for the location.
"hasPropertyData":"true"
Example - Print all locations in North East Pacific with Hydrophones deployed
from onc.onc import ONC
onc = ONC('YOUR_TOKEN_HERE')

locations = onc.getLocationHierarchy({'locationCode':'NEP'}) #NEP - North East Pacific
print(locations)

print('Locations')
for location in locations:
    locationCode = location['locationCode']
    locationName = location['locationName']
    hasDeviceData = location['hasDeviceData']
    hasPropertyData = location['hasPropertyData']
    if (len(locationCode.split('.')) == 2):
        parentName = onc.getLocationName(locationCode.split('.')[0])
        if (parentName):
            locationName = '{} / {}'.format(parentName,locationName)
    print('  {0} - {1}'.format(locationCode,locationName))
    print('     Request data product using Device Category (Site Device): {}'.format(hasDeviceData))
    print('     Request data product using Property (Primary Sensor): {}'.format(hasPropertyData))
print('{} locations'.format(len(locations)))


getDevices()

getDevices(filters={})


Returns a list of devices, as a list of dictionary objects that meet the criteria defined by the input filters.


Parameter
Type
Description
Example
Optional


filtersdictionary

A dictionary of one or more filter criteria, used to return an exclusive set of device elements from the ONC devices endpoint.

{'deviceCode':'NORTEKADCP9917'}


Returns

A list of device objects.

[
   {
      "cvTerm": {
         "device": [
            {
               "uri": "http://vocab.nerc.ac.uk/collection/L22/current/TOOL0888/",
               "vocabulary": "SeaVoX Device Catalogue"
            }
         ]
      },
      "dataRating": [
         {
            "dateFrom": "2008-11-01T00:00:00.000Z",
            "dateTo": "2010-05-27T19:27:04.000Z",
            "samplePeriod": 1,
            "sampleSize": 1
         },
         {
            "dateFrom": "2010-05-27T19:27:04.000Z",
            "dateTo": "None",
            "samplePeriod": 10,
            "sampleSize": 1
         }
      ],
      "deviceCode": "BC_POD1_AD2M",
      "deviceId": 11302,
      "deviceLink": "https://data.oceannetworks.ca/DeviceListing?DeviceId=11302",
      "deviceName": "Nortek Aquadopp HR-Profiler 2965"
   }
]
Property
Type
Description
Example
device[]listA list of devices.[]
device[].cvTermdictionaryA dictionary of controlled vocabulary terms."cvTerm": []
device[].cvTerm.device[]dictionaryA list of dictionaries of controlled vocabulary term information for the device.
"cvTerm": [ {"device": [] } ]
device[].cvTerm.device[].uristringThe URI of the controlled vocabulary term."uri""http://vocab.nerc.ac.uk/collection/L22/current/TOOL0888/"
device[].cvTerm.device[].vocabularystringThe name of the controlled vocabulary to which the term belongs."vocabulary""SeaVoX Device Catalogue"
device[].dataRating[]listA list of data ratings dictionaries."dataRating" : []
device[].dataRating[].dateFromdatetime string

The starting datetime for a data rating.

"dateFrom": "2008-11-01T00:00:00.000Z",
device[].dataRating[].dateTodatetime string

The ending datetime for a data rating.

  • If None, the data rating was still in affect when the request was made.
  • Date Time format: yyyy-MM-dd'T'HH:mm:ss.SSS'Z'.
  • datetime is represented in Coordinated Universal Time (UTC).

"dateTo": "2010-05-27T19:27:04.000Z"
device[].dataRating[].samplePerioddoubleThe sample period, in seconds, for the data rating."samplePeriod" 1
device[].dataRating[].sampleSizeintThe size of the data sample for the data rating.
"sampleSize": 1
device[].deviceCodestringA code that unquely identifes a device.
"deviceCode": "BC_POD1_AD2M"
device[].deviceIdintA numeric id that uniquely identifies a device.
"deviceId": 11302
device[].deviceLinkstringThe URL link to the Devices Listing page for the specific device.
"deviceLink": "https://data.oceannetworks.ca/DeviceListing?DeviceId=11302"
device[].deviceNamestringThe name of the device.
"deviceName": "Nortek Aquadopp HR-Profiler 2965"
Example - Print all devices deployed at Barkley Canyon - Axis, between June 1, 2016 and May 31, 2017
from onc.onc import ONC
onc = ONC('YOUR_TOKEN_HERE')

devices = onc.getDevices({'locationCode':'BACAX','dateFrom':'2016-06-01T00:00:00.000Z','dateTo':'2017-05-31T23:59:59.999Z'})  #BACAX - Barkley Canyon / Axis

print('Devices:')

for device in devices:
    deviceCode = device['deviceCode']
    deviceName = device['deviceName']
    print('  {} - {}'.format(deviceCode,deviceName))
print('{} devices'.format(len(devices)))


getDeployments()

getDeployments(filters={})


Returns a list of deployments, as a list of dictionary objects that meet the criteria defined by the input filters.


Parameter
Type
Description
Example
Optional


filtersdictionary

A dictionary of one or more filter criteria, used to return an exclusive set of device elements from the ONC devices endpoint.

{'deviceCode':'NORTEKADCP9917'}


Returns

A list of deployment objects.

[
   {
      "begin": "2016-06-14T08:58:41.000Z",
      "depth": 982,
      "deviceCode": "WLFLNTU1087",
      "end": "None",
      "hasDeviceData": true,
      "heading": "None",
      "lat": 48.31658,
      "locationCode": "BACAX",
      "lon": -126.0508,
      "pitch": "None",
      "roll": "None"
   },
   {
      "begin": "2016-06-14T06:05:24.000Z",
      "depth": 985,
      "deviceCode": "BC_POD1_ROTSONAR",
      "end": "None",
      "hasDeviceData": true,
      "heading": 90,
      "lat": 48.3166,
      "locationCode": "BACAX",
      "lon": -126.0508,
      "pitch": "None",
      "roll": "None"
   },
   {
      "begin": "2016-06-14T06:05:24.000Z",
      "depth": 985,
      "deviceCode": "NORTEKSIGNATURE550056",
      "end": "None",
      "hasDeviceData": true,
      "heading": 340,
      "lat": 48.3166,
      "locationCode": "BACAX",
      "lon": -126.0508,
      "pitch": "None",
      "roll": "None"
   },...
]



Property
Type
Description
Example
deployment[]

[]
deployment[].locationCodestringThe locationCode for the deployment location.
"locationCode":"BACAX"
deployment[].deviceCodestringThe deviceCode for a deployed device.
"deviceCode":"SBECTD19p6813"
deployment[].begindatetime

The beginning datetime of the deployment.

Date Time format: yyyy-MM-dd'T'HH:mm:ss.SSS'Z'

"begin":2010-07-27T00:00:00.000Z
deployment[].enddatetime

The ending datetime of the deployment.

  • If the deployment is current, the value is null.

Date Time format: yyyy-MM-dd'T'HH:mm:ss.SSS'Z'

"end":2016-08-01T00:00:00.000Z

deployment[].hasDeviceData

stringIndicates that data products can be requested using a device category code for the deployment.
"hasDeviceData":"true
deployment[].depthdoubleThe depth of the device deployment."depth":982
deployment[].latdouble

The latitude of the device deployment.

"lat":48.31658
deployment[].londoubleThe longitude of the device deployment."lon":-126.0508
deployment[].headingdoubleThe heading of the device deployment."heading":244
deployment[].pitchdoubleThe pitch of the device deployment."pitch":null
deployment[].rolldoubleThe roll of the device deployment."roll":null
Example - Print all devices deployed at Barkley Canyon - Axis, between June 1, 2016 and May 31, 2017
from onc.onc import ONC
onc = ONC('YOUR_TOKEN_HERE')

deployments = onc.getDeployments({'locationCode':'BACAX','dateFrom':'2016-06-01T00:00:00.000Z','dateTo':'2017-05-31T23:59:59.999Z'})  #BACAX - Barkley Canyon / Axis

print('Deployments:')

for deployment in deployments:
	locationCode = deployment['locationCode']
    deviceCode = deployment['deviceCode']
    dtBegin = deployment['begin']
	dtEnd = deployment['end']
    print('  {} - {} - {} to {}'.format(locationCode,deviceCode,dtBegin,dtEnd))
print('{} deployments'.format(len(deployments)))


getDeviceCategories()

getDeviceCategories(filters={})


Returns a list of deviceCategories, as a list of dictionary objects that meet the criteria defined by the input filters.


Parameter
Type
Description
Example
Optional


filtersdictionary

A dictionary of one or more filter criteria, used to return an exclusive set of deviceCategory elements from the ONC deviceCategories endpoint.

{'deviceCategoryCode':'HYDROPHONE'}


Returns

A list of device category objects.

 [
   {
      "cvTerm": {
         "deviceCategory": [
            {
               "uri": "http://vocab.nerc.ac.uk/collection/L05/current/130/",
               "vocabulary": "SeaDataNet device categories"
            }
         ]
      },
      "description": "Conductivity Temperature (and Depth Sensor)",
      "deviceCategoryCode": "CTD",
      "deviceCategoryName": "CTD",
      "hasDeviceData": "true",
      "longDescription": " Conductivity Temperature Depth (CTD) is an abbreviated name for an instrument package that contains sensors for measuring the conductivity, temperature, and pressure of seawater. Salinity, sound velocity, and density are variables derived from sensor measurements. CTDs can carry additional instruments and sensors such as oxygen sensors, turbidity sensors and fluorometers. "
   }
]
Property
Type
Description
Example
deviceCategory[]listA list of device categories.
[]
deviceCategory[].cvTermdictionaryA dictionary of controlled vocabulary terms.
"cvTerm": { }
deviceCategory[].cvTerm.deviceCategory[]dictionaryA list of dictionaries of controlled vocabulary term information for the device category.
"deviceCategory": [ { } ]
deviceCategory[].cvTerm.deviceCategory[].uristringThe URI of the controlled vocabulary term.
"uri": "http://vocab.nerc.ac.uk/collection/L05/current/130/"
deviceCategory[].cvTerm.deviceCategory[].vocabularystringThe name of the controlled vocabulary to which the term belongs.
"vocabulary": "SeaDataNet device categories"
deviceCategory[].descriptionstringThe short description of the device category.
"description": "Conductivity Temperature (and Depth Sensor)"
deviceCategory[].deviceCategoryCodestringA code to uniquely identify a device category.
"deviceCategoryCode": "CTD"
deviceCategory[].deviceCategoryNamestringThe name of the device category.
"deviceCategoryName": "CTD"
deviceCategory[].hasDeviceDatastringIndicates that data products can be requested using the device category for a location.
"hasDeviceData": "true"
deviceCategory[].longDescriptionstringThe long description of the device category.
"longDescription": " Conductivity Temperature Depth (CTD) is an abbreviated 
name for an instrument package that contains sensors for
measuring the conductivity, temperature, and pressure of
seawater. Salinity, sound velocity, and density are variables
derived from sensor measurements. CTDs can carry additional
instruments and sensors such as oxygen sensors, turbidity
sensors and fluorometers. "
Example - Print all device categories available at Barkley Canyon - Upper Slope
from onc.onc import ONC
onc = ONC('YOUR_TOKEN_HERE')

deviceCategories = onc.getDeviceCategories({'locationCode':'NCBC'})    #NCBC - Barkely Canyon / Upper Slope

print('Device Categories:')

for deviceCategory in deviceCategories:
    deviceCategoryCode = deviceCategory['deviceCategoryCode']
    deviceCategoryName = deviceCategory['deviceCategoryName']
    print('  {} - {}'.format(deviceCategoryCode,deviceCategoryName))
print('{} device categories'.format(len(deviceCategories)))


getProperties()

getProperties(filters={})


Returns a list of properties, as a list of dictionary objects that meet the criteria defined by the input filters.


Parameter
Type
Description
Example
Optional


filtersdictionary

A dictionary of one or more filter criteria, used to return an exclusive set of property elements from the ONC properties endpoint.

{'propertyCode':'seawatertemperature'}


Returns

A list of property objects.

 [
   {
      "cvTerm": {
         "property": [],
         "uom": [
            {
               "uri": "http://vocab.nerc.ac.uk/collection/P06/current/UPDB/",
               "vocabulary": "BODC data storage units"
            }
         ]
      },
      "description": "Pressure",
      "hasDeviceData": "true",
      "hasPropertyData": "true",
      "propertyCode": "pressure",
      "propertyName": "Pressure",
      "uom": "decibar"
   }
]
Property
Type
Description
Example
property[]listA list of properties.
[]
property[].cvTermdictionaryA dictionary of controlled vocabulary terms.
"cvTerm": { }
property[].cvTerm.property[]dictionaryA list of dictionaries of controlled vocabulary term information for the property.
"property": []
property[].cvTerm.property[].uristringThe Uri of the controlled vocabulary term.
property[].cvTerm.property[].vocabularystringThe name of the controlled vocabulary to which the term belongs.
property[].cvTerm.uom[]dictionaryA list of dictionaries of controlled vocabulary term information for the unit of measure.
"uom": []
property[].cvTerm.uom[].uristringThe Uri of the controlled vocabulary term.
"uri": "http://vocab.nerc.ac.uk/collection/P06/current/UPDB/"
property[].cvTerm.uom[].vocabularystringThe name of the controlled vocabulary to which the term belongs.
"vocabulary": "BODC data storage units"
property[].descriptionstringThe short description of the device category.
"description": "Pressure"
property[].hasDeviceDatastringIndicates that data products can be requested using the property code, along with a device category for a location.
"hasDeviceData": "true"
property[].hasPropertyDatastringIndicates that data products can be requested using the property code for a location.
"hasPropertyData": "true"
property[].propertyCodestringA code that uniquely identifies the property.
"propertyCode": "pressure"
property[].propertyNamestringThe name of the property.
"propertyName": "Pressure"
property[].uomstringThe Unit of Measure used for property measurements.
"uom": "decibar"
Example - Print all properties that are available at Barkley Canyon - Axis
from onc.onc import ONC
onc = ONC('YOUR_TOKEN_HERE')

properties = onc.getProperties({'locationCode':'BACAX'})  #BACAX - Barkley Canyon / Axis

print('Properties:')

for prprty in properties:
    propertyCode = prprty['propertyCode']
    propertyName = prprty['propertyName']
    description = prprty['description']
    print('  {} - {} ({})'.format(propertyCode,propertyName,description))
print('{} properties'.format(len(properties)))


getDataProducts()

getDataProducts(filters={})


Returns a list of data products as a list of dictionary objects that meet the criteria defined by the input filters.


Parameter
Type
Description
Example
Optional


filtersdictionary

A dictionary of one or more filter criteria, used to return an exclusive set of dataProduct & extension elements from the ONC dataProducts endpoint.

{'dataProductCode':'TSSD','extension':'json'}


Returns

A list of data product objects.

[
   {
      "dataProductCode": "TSSD",
      "dataProductName": "Time Series Scalar Data",
      "extension": "json",
      "hasDeviceData": true,
      "hasPropertyData": true,
      "helpDocument": "https://wiki.oceannetworks.ca/display/DP/1"
   }
]



Property
Type
Description
Example
dataProduct[]listA list of data products.
[]
dataProduct[].dataProductCodestringA code that uniquely identifies a data product.
"dataProductCode": "TSSD" 
dataProduct[].dataProductNamestringThe name of the data product.
"dataProductName": "Time Series Scalar Data"
dataProduct[].extensionstringThe file name extension for a data product.
"extension": "json"
dataProduct[].hasDeviceDatastringIndicates that the data product can be requested using a device category code and a location code.
"hasDeviceData": true
dataProduct[].hasPropertyDatastringIndicates that the data product can be requested using a property code and a location code or device code.
"hasPropertyData": true,
dataProduct[].helpDocumentstringA Link URL to the Oceans 2.0 Help documentation for the specific Data Product.
"helpDocument": "https://wiki.oceannetworks.ca/display/DP/1"
Example - Print all MatLab data product
from onc.onc import ONC
onc = ONC('YOUR_TOKEN_HERE')

dataProducts = onc.getDataProducts({'extension':'mat'}) #mat - MatLab

print('Data Products:')

for c in sorted(set([str(dp['dataProductCode']) for dp in dataProducts])):
    name = [dp['dataProductName'] for dp in dataProducts if dp['dataProductCode'] == c][0]
    print ('{} - {}'.format(c,name))
    for e in sorted(set([dp['extension'] for dp in dataProducts if dp['dataProductCode'] == c])):
        print('  {}'.format(e))
print('{} data product extensions'.format(len(dataProducts))) 


Data Product Download methods

orderDataProduct()

orderDataProduct(filters={}, maxRetries=100, downloadResultsOnly=False, includeMetadataFile=True)


Requests a data product and downloads the generated files to the class's outPath.

This method performs the complete data product download workflow by calling additional methods to perform the following steps:

 1. Request a data product, which includes estimates for download size and time.

 2. Run a requested data product, which kicks off a process on the task machine to generate the data product.

 3. Download the data product to disk. The process will continue to poll the web service to determine if the product is ready to download. If it is not ready, status messages will be provided. Once it is ready, it will download the data product to disk.


Parameter
Type
Description
Example
Required


filtersdictionary

A dictionary of filter criteria parameters, used to request data as a data product from the ONC dataProductDelivery endpoint.

{'locationCode':'BACAX',
'deviceCategoryCode':'ADCP2MHZ',
'dataProductCode':'TSSD',
'extension':'csv',
'dateFrom':'2016-07-27T00:00:00.000Z',
'dateTo':'2016-08-01T00:00:00.000Z',
'dpo_qualityControl':1,
'dpo_resample':'none',
'dpo_dataGaps':0}

Option


maxRetriesint

The number of times to retry the service before the function aborts.

  • If excluded, the default of 100 is used.
10
downloadResultsOnlyboolean

Indicates whether the files will be downloaded or if only the URL to the file will be returned.

  • False - Files are downloaded to the ONC class outPath property location.
  • True - Files will not be downloaded. The download URLs are available from the url property for each downloadResult in downloadResults in the returned dictionary.
  • If excluded, the default of False is used.
True
includeMetadataFileboolean

Indicates if the metadata file associated with the data product request will be downloaded

  • False - Metadata file is not downloaded.
  • True - Metadata file is downloaded.
  • If excluded, the default of False is used.

True


Returns

A dictionary of download results and run time statistics.

{'downloadResults': [
    {
        'url': 'https://data.oceannetworks.ca/api/dataProductDelivery?method=download&token=<YOUR_TOKEN>&dpRunId=<YOUR_RUN_ID>&index=1', 
        'message': [
            'Running', 
            'Transferring (BarkleyCanyon_Axis_ADCP2MHz_20160727T000005Z_20160731T235958Z-clean.csv) to the FTP server'
            ], 
        'queuingTime': 0, 
        'runningTime': 1.567234, 
        'transferringTime': 59.616635, 
        'downloadingTime': 0.295575, 
        'requestCount': 40, 
        'status': 'complete', 
        'size': 3060227.0, 
        'file': 'c:/ONC/data/BarkleyCanyon_Axis_ADCP2MHz_20160727T000005Z_20160731T235958Z-clean.csv', 
        'index': 1,
        'downloaded': True}, 
    {
        'url': 'https://data.oceannetworks.ca/api/dataProductDelivery?method=download&token=<YOUR_TOKEN>&dpRunId=<YOUR_RUN_ID>&index=meta', 
        'message': [], 
        'queuingTime': 0, 
        'runningTime': 0, 
        'transferringTime': 0, 
        'downloadingTime': 0.132616, 
        'requestCount': 1, 
        'status': 'complete', 
        'size': 27502.0, 
        'file': 'c:/temp/doctest/BarkleyCanyon_Axis_ADCP2MHz_20160727T000005Z_20160731T235958Z-clean_CSV_META.pdf', 
        'index': 1, 
        'downloaded': True
    }
], 
'stats': {
    'requestRequestTime': 0.328399, 
    'runRequestTime': 1.060785, 
    'queuingTime': 0, 
    'runningTime': 1.567234, 
    'transferringTime': 59.616635, 
    'downloadingTime': 0.428191
    }
}
Property
Type
Description
downloadResultslistA list of download results dictionaries.
downloadResults[].urlstringThe URL used to make the download request.
downloadResults[].messagelistA list of the messages that were returned from the dataProductDelivery download method when it was polled.
downloadResults[].queuingTimefloatThe time duration, in seconds, between the first and last service request, that indicated that the task was queued.
downloadResults[].runningTimefloatThe time duration, in seconds, between the first request that returned a status message that it was running and the time that the request returned that it was transferring or complete.
downloadResults[].transferringTimefloatThe time duration, in seconds, between the first request that returned a status message that it was transferring.
downloadResults[].downloadingTimefloatThe time duration, in seconds, between the start and completion of the file download.
downloadResults[].requestCountintegerThe number of web service request that were made before the download was complete. This includes all of the requests that returned run task status messages.
downloadResults[].statusstring

The status of the download process at the request. Possible values are:

  • "running" - The data product request is running on the Task server.
  • "complete" - The data product request Task has completed and file has been downloaded or URL has been returned.
  • "error" - An error, preventing the task execution or download from completing successfully, has occurred.
downloadResults[].sizefloatThe actual size of the file in bytes.
downloadResults[].filestringThe full path of the file that was downloaded.
downloadResults[].indexstringThe index of the file downloaded. The index can either be a number 1-* or "meta" for the data product metadata file.
downloadResults[].downloadedbooleanIndicates if the file was downloaded. If the filter downloadResultsOnly=True is used, the data product is not downloaded and the value will be False
statslistA summary of individual result statistics.
stats.requestRequestTimefloatThe time to complete the request request for the requested data product.
stats.runRequestTimefloatThe time to complete the run request for the requested data product.
stats.queuingTimefloatA sum of the queueTime times from all of the run requests for the requested data product.
stats.runningTimefloatA sum of the runningTime times from all of the run requests for the requested data product.
stats.transferringTimefloatA sum of the transferringTime times from all of the run requests for the requested data product.
stats.downloadingTimefloatA sum of the downloadTime times from all of the run requests for the requested data product.
Example - Download Time Series Scalar Data Product in CSV format for ADCP 2 MHZ at Barkley Canyon - Axis
from onc.onc import ONC
onc = ONC('YOUR_TOKEN_HERE')

results = onc.orderDataProduct({'locationCode':'BACAX',
		                        'deviceCategoryCode':'ADCP2MHZ',
        		                'dataProductCode':'TSSD',
                		        'extension':'csv',
                        		'dateFrom':'2016-07-27T00:00:00.000Z',
                        		'dateTo':'2016-08-01T00:00:00.000Z',
                        		'dpo_qualityControl':1,
                        		'dpo_resample':'none',
                        		'dpo_dataGaps':0})
print(results)


requestDataProduct()
requestDataProduct(filters={}, returnError=False)


Requests a data product using the dataProductDelivery service and provides request information so that the calling function can decide whether to run the data product.
The dictionary of information it returns includes a requestID, which is used to run the data product, and estimates of the expected download times and file sizes.


Parameter
Type
Description
Example
Required


filtersdictionary

A dictionary of filter criteria parameters, used to request data as a data product from the ONC dataProductDelivery endpoint.

{'locationCode':'BACAX',
'deviceCategoryCode':'ADCP2MHZ',
'dataProductCode':'TSSD',
'extension':'csv',
'dateFrom':'2016-07-27T00:00:00.000Z',
'dateTo':'2016-08-01T00:00:00.000Z',
'dpo_qualityControl':1,
'dpo_resample':'none',
'dpo_dataGaps':0}
Option


returnErrorboolean

Indicates whether error messages from the dataProductDelivery service should be returned.

  • True - error messages from the service call payload will be returned.
  • False - error messages will not be returned, but printed to console.
  • If excluded, the default value of False is used.
True


Returns

A data product request dictionary.

for archived files (AD):

{
    "dpRequestId":2046404,
    "compressedFileSize":12563408,
    "fileSize":70766230,
    "numFiles":4,
    "downloadTimes":{"10Mbps":7.076623,"50Mbps":1.4153247,"150Mbps":0.47177488}
}


for generated files:

{
    "dpRequestId":2046404,
    "estimatedFileSize":8348187,
    "estimatedProcessingTime":16
}
Property
Type
Description
Example
Always contains
dpRequestIdintA unique id for a data product request.
"dpRequestId":2046404
May contain
compressedFileSizeintThe compressed size of the known file(s) in bytes."compressedFileSize":12563408
fileSizeintThe size of known file(s) in bytes."fileSize":70766230
numFilesintThe number of files."numFiles":4
downloadTimesdictA dictionary of estimated download times."downloadTimes":{"10Mbps":7.076623,"50Mbps":1.4153247,"150Mbps":0.47177488}
estimatedFileSizeintThe estimated file size of the generated data product."estimatedFileSize":8348187
estimatedProcessingTimeintThe estimated time, in seconds, that it will take to run the data product request."estimatedProcessingTime":16
from onc.onc import ONC
onc = ONC('YOUR_TOKEN_HERE')

 
requestInfo = onc.requestDataProduct({'locationCode':'BACAX',
			 						  'deviceCategoryCode':'ADCP2MHZ',
			 						  'dataProductCode':'TSSD',
			 						  'extension':'csv',
			 						  'dateFrom':'2016-07-27T00:00:00.000Z',
			 						  'dateTo':'2016-08-01T00:00:00.000Z',
			 						  'dpo_qualityControl':1,
			 						  'dpo_resample':'none',
			 						  'dpo_dataGaps':0})
print(requestInfo)


runDataProduct()
runDataProduct(requestId)


Runs a data product request using the dataProductDelivery service with a Request Id and returns a list of run ids


Parameter
Type
Description
Example
Required


requestIdint

A dataProductDelivery dpRequestId, which is returned by the dataProductDelivery service request method, or as the 'dpRequestId' property in the dpRequest returned by the requestDataProduct() method.

2046404


Returns

A list of runIds.

[ 
	4629218,
 	4629219
]
Example - Run a requested data product
from onc.onc import ONC
onc = ONC('YOUR_TOKEN_HERE')

ids = onc.runDataProduct(YOUR_REQUEST_ID_HERE)
 
print(ids)


downloadDataProduct()
downloadDataProduct(runId, fileCount=0, estimatedProcessingTime=1, maxRetries=100, downloadResultsOnly=False, includeMetadataFile=False, multiThreadMessages=False)


Polls the dataProductDelivery service until data product generation task is complete and downloads all of the files and/or retrieves the file information (URL, file and download status).


Parameter
Type
Description
Example
Required


runIdint

A dataProductDelivery dpRunId, which is returned by the dataProductDelivery service run method, or as the dpRunId property in the list returned by the runDataProduct() method.

4629218
Option


fileCountint

The actual or estimated file count, which is returned from the dataProductDelivery request method.

  • If there is no estimated file count, use 0.
  • If excluded, the default of 0 is used.
1
estimatedProcessingTimeint

The estimated time in seconds, to run the request on the task machine.

  • Used to determine how often the dataProductDelivery service is called to determine whether the task processing is complete.
  • Estimated processing time is provided by the dataProductDelivery request method.
2
maxRetriesint

The number of times to retry the service before the function aborts.

  • If excluded, the default of 100 is used.
10
downloadResultsOnlyboolean

Determines whether the files will be downloaded or if only the url to the file will be returned.

  • False - Files are downloaded to the ONC class outPath property location
  • True - Files will not be downloaded. The download URLs are available from the url property for each downloadResult in downloadResults in the returned dictionary
  • If excluded, the default of False is used
True
includeMetadataFileboolean

Indicates if the metadata file associated with the data product request will be downloaded

  • False - Metadata file is not downloaded.
  • True - Metadata file is downloaded.
  • If excluded, the default of False is used.

True

multiThreadMessagesboolean

Determines how the method and called method should print messages to the console. If downloading data products in a multi-threaded pattern, messages written to the console can overlap and progress dots can be written out of context

  • If excluded, the default of False is used.
True


Returns

A list of download results dictionaries.

[
    {
        'url': 'https://data.oceannetworks.ca/api/dataProductDelivery?method=download&token=<YOUR_TOKEN>&dpRunId=<YOUR_RUN_ID>&index=1', 
        'message': [
            'Running', 
            'Transferring (BarkleyCanyon_Axis_ADCP2MHz_20160727T000005Z_20160731T235958Z-clean.csv) to the FTP server'
            ], 
        'queuingTime': 0, 
        'runningTime': 1.567234, 
        'transferringTime': 59.616635, 
        'downloadingTime': 0.295575, 
        'requestCount': 40, 
        'status': 'complete', 
        'size': 3060227.0, 
        'file': 'c:/ONC/data/BarkleyCanyon_Axis_ADCP2MHz_20160727T000005Z_20160731T235958Z-clean.csv', 
        'index': 1,
        'downloaded': True}, 
    {
        'url': 'https://data.oceannetworks.ca/api/dataProductDelivery?method=download&token=<YOUR_TOKEN>&dpRunId=<YOUR_RUN_ID>&index=meta', 
        'message': [], 
        'queuingTime': 0, 
        'runningTime': 0, 
        'transferringTime': 0, 
        'downloadingTime': 0.132616, 
        'requestCount': 1, 
        'status': 'complete', 
        'size': 27502.0, 
        'file': 'c:/temp/doctest/BarkleyCanyon_Axis_ADCP2MHz_20160727T000005Z_20160731T235958Z-clean_CSV_META.pdf', 
        'index': 'meta', 
        'downloaded': True
    }
]
Property
Type
Description
urlstringThe URL used to make the download request.
messagelistA list of the messages that were returned from the dataProductDelivery download method when it was polled.
queuingTimefloatThe time duration, in seconds, between the first and last service request, that indicated that the task was queued.
runningTimefloatThe time duration, in seconds, between the first and last service request that returned a status message that it was running and the time that the request returned that it was transferring or complete.
transferringTimefloatThe time duration, in seconds, between the first abd last service request that returned a status message that it was transferring.
downloadingTimefloatThe time duration, in seconds, between the start and completion of the file download.
requestCountintegerThe number of web service requests that were made before the download was complete. This includes all of the requests that returned run task status messages.
statusstring

The status of the download process at the request. Possible values are:

  • "running" - The data product request is running on the Task server.
  • "complete" - The data product request Task has completed and file has been downloaded or URL has been returned.
  • "error" - An error, preventing the task execution or download from completing successfully, has occurred.
sizefloatThe actual size of the file in bytes.
filestringThe full path of the file that was downloaded.
indexstringThe index of the file downloaded. The index can either be a number 1-* or "meta" for the data product metadata file.
downloadedbooleanIndicates whether the file was downloaded. If the filter downloadResultsOnly=True is used, the data product is not downloaded and the value will be False
Example - Download the results of requested data product run
from onc.onc import ONC
onc = ONC('YOUR_TOKEN_HERE')

results = onc.downloadDataProduct(YOUR_RUN_ID_HERE, 1)
 
print(result)


getDataProdutUrls()

getDataProductUrls(filters, maxRetries=100)


Orders a data product and return only the URLs, for download at a later time. URLs can be used with the downloadFile() or getJsonFromUrl() methods.


Parameter
Type
Description
Example
Required


filtersdictionary

A dictionary of filter criteria parameters, used to request data as a data product from the ONC dataProductDelivery endpoint.

{'locationCode':'BACAX',
'deviceCategoryCode':'ADCP2MHZ',
'dataProductCode':'TSSD',
'extension':'csv',
'dateFrom':'2016-07-27T00:00:00.000Z',
'dateTo':'2016-08-01T00:00:00.000Z',
'dpo_qualityControl':1,
'dpo_resample':'none',
'dpo_dataGaps':0}
Option


maxRetriesint

The number of times to retry the service before the function aborts.

  • If excluded, the default of 100 is used
10


Returns

A list of URLs

[
 'https://data.oceannetworks.ca/api/dataProductDelivery?method=download&token=<YOUR_TOKEN>&dpRunId=<YOUR_RUN_ID>&index=1', 
 'https://data.oceannetworks.ca/api/dataProductDelivery?method=download&token=<YOUR_TOKEN>&dpRunId=<YOUR_RUN_ID>&index=2'
]
Example - Order a data product and get a list of the download urls
from onc.onc import ONC
onc = ONC('YOUR_TOKEN_HERE')
 
urls = onc.getDataProductUrls({'locationCode':'BACAX',
							   'deviceCategoryCode':'ADCP2MHZ',
                               'dataProductCode':'TSSD',
							   'extension':'json',
							   'dateFrom':'2016-07-27T00:00:00.000Z',
							   'dateTo':'2016-08-01T00:00:00.000Z',
							   'dpo_qualityControl':1,
							   'dpo_resample':'none',
							   'dpo_dataGaps':0,
							   'dpo_jsonOutputEncoding':'OM'},100)
 
print(urls)


downloadFile()

downloadFile(url, file, multiThreadMessages=False)


Downloads a file from a URL, write it to a file and return download results information (URL, file, message and download status).


Parameter
Type
Description
Example
Required


urlstring

The URL to be downloaded.

https://data.oceannetworks.ca/api/dataProductDelivery?method=download&token=<YOUR_TOKEN_HERE>
&dpRunId=<YOUR_RUN_ID_HERE>&index=<YOUR_INDEX_HERE>
filestring

The full path of the file download destination.

  • If excluded, the file name from the content disposition in the header is used, along with the ONC class object outPath to create a full file name path.
c:/temp/myDownload.csv
Option


multiThreadMessagesboolean

Determines how the method and called method should print messages to the console. If downloading data products in a multi-threaded pattern, messages written to the console can overlap and progress dots can be written out of context.

  • If excluded, the default of False is used.
True


Returns

A downloadResults dictionary.

{
    'url': 'https://data.oceannetworks.ca/api/dataProductDelivery?method=download&token=<YOUR_TOKEN>&dpRunId=<YOUR_RUN_ID>&index=1', 
    'file': 'c:/temp/myDownload.json', 
    'message': [], 
    'downloaded': True, 
    'downloadingTime': 0.641304
}
Property
Type
Description
urlstringThe URL used to make the download request.
filestringThe full path of the file that was downloaded.
messagelistA list of the messages that were returned from the dataProductDelivery download method when it was polled.
downloadedbooleanIndicates whether the file was downloaded.
downloadingTimefloatThe time duration, in seconds, between the start and completion of the file download.
Example - Download a file from a url
from onc.onc import ONC
onc = ONC('YOUR_TOKEN_HERE')
 
url = 'https://data.oceannetworks.ca/api/dataProductDelivery?method=download&token=<YOUR_TOKEN_HERE>&dpRunId=<YOUR_RUN_ID_HERE>&index=<YOUR_INDEX_HERE>'
file = 'c:/temp/myDownload.csv'

downloadResult = onc.downloadFile(url, file)
 
print(downloadResult)


decodeJsonFromUrl()

decodeJsonFromUrl(url)


Returns a dictionary from the JSON returned from a URL.


Parameter
Type
Description
Example
Required


urlstring

The URL to a JSON data product delivery result.

https://data.oceannetworks.ca/api/dataProductDelivery?method=download&token=<YOUR_TOKEN_HERE>&dpRunId=<YOUR_RUN_ID_HERE>&index=<YOUR_INDEX_HERE>


Returns

A structure encoded from a JSON string.


Example - Get dictionary of results from json data product request
from onc.onc import ONC
onc = ONC('YOUR_TOKEN_HERE')
 
urls = onc.getDataProductUrls({'locationCode':'BACAX',
							   'deviceCategoryCode':'ADCP2MHZ',
                               'dataProductCode':'TSSD',
							   'extension':'json',
							   'dateFrom':'2016-07-27T00:00:00.000Z',
							   'dateTo':'2016-08-01T00:00:00.000Z',
							   'dpo_qualityControl':1,
							   'dpo_resample':'none',
							   'dpo_dataGaps':0,
							   'dpo_jsonOutputEncoding':'OM'},100)
 
for url in urls:
	object = onc.decodeJsonFromUrl(url)
 	print(object)



getListByLocation()

getListByLocation(locationCode, deviceCategoryCode, filters, options)


Get a list of files for a given location code and device category code, optionally filtered by time ranges. 


Parameter

Type

Description

Example

Required


locationCodestring

The code of the location.

'VION'
deviceCategoryCodestringThe code of the device category.
'OCEANOGRAPHICRADAR'
Optional


filtersdictionary

A dictionary representing a JSON object with a set of optional filters, which can include any of the following:

  • dateFrom: Only include files obtained after this date and time.
  • dateTo: Only include files obtained before this date and time.
  • dateArchivedFrom: Only include files archived after this date and time.
  • dateArchivedTo: Only include files archived before this date and time.

Note: All dates in "yyyy-MM-ddTHH:mm:ss.SSSZ" format.


{
	'dateFrom': '2018-11-07T00:00:00.000Z',
	'dateTo': '2018-11-08T00:00:00.000Z'
}
optionsdictionary

A dictionary representing a JSON object with a set of configuration options, which can include any of the following:

  • returnOptions: Set the detail level of the result as follows:
    • "archiveLocation": Return a file list with their archiveLocation (used by www.oceannetworks.ca website)
    • "all": Return a file list with all metadata information (serviceMetadata object).
    • If returnOptions is not specified, return a simple list of filenames.
  • rowLimit: (number) The maximum number of rows to return (100,000 by default), within the constraints of the service. Note this will limit the data starting at the dateFrom time and ending at the row limit, not necessarily at the dateTo time.
  • page: (number) In case that the file list obtained is longer than "rowLimit", results will be split into pages where each would contain at most "rowLimit" rows, and this method will only return the subset of rows for a certain "page" (by default 1). The serviceMetadata.next parameter in the response can be used to get the next page of rows.
{
	'returnOptions': 'all',
	'rowLimit': 100,
	'page': 1
}

Example

getListByLocation() Example: Get a simple file list for location 'VION' and category code 'OCEANOGRAPHICRADAR' obtained in a certain day
from onc.onc import ONC
onc = ONC('YOUR_TOKEN')

filters = {'dateFrom': '2018-11-07T00:00:00.000Z', 'dateTo': '2018-11-08T00:00:00.000Z'}
result = onc.getListByLocation('VION', 'OCEANOGRAPHICRADAR', filters)
print result


Returns

If "returnOption" parameter is set to "all", a list of file names with their metadata information (serviceMetadata object) will be returned.

Example response structure for returnOption: 'all'
{
    "files": [
        {
            "archivedDate": <date>,
            "compression": <string>,
            "dataProductCode": <string>,
            "dateFrom": <date>,
            "dateTo": <date>,
            "deviceCode":<string>,
            "fileSize": <long>,
            "filename": <string>,
            "modifyDate": <date>,
            "uncompressedFileSize": <long>   
        },
        # (...more rows...)
    ],
    "serviceMetadata": { (...) }
}

If "returnOption" parameter is set to "archiveLocation", the list of file names will include the archiveLocation.

Example response with returnOption: "archiveLocation"
{
    "files":[
        {
            "archiveLocation":"/archive/AD/venus/VENUS_UNIQUE/VUNIQUE0007",
            "dateFrom":"2009-09-08T00:00:00.000Z",
            "filename":"BC_POD2_JB_20090908T000000.000Z.txt",
            "path":"00/15/88"
        },
		# (...more rows...)
    ],
    "serviceMetadata": { (...) }
}

If "returnOption" parameter is omitted, the list of file names will not include additional metadata.

Example response with returnOption: "archiveLocation"
{
    "files":[
        {
            "BC_POD2_JB_20090908T000000.000Z.txt",
            "BC_POD2_JB_20090909T000000.000Z.txt",
            "BC_POD2_JB_20090916T000000.000Z.txt",
            "BC_POD2_JB_20090925T000000.000Z.txt",
            "BC_POD2_JB_20090926T000000.000Z.txt"
        },
		# (...more rows...)
    ],
    "serviceMetadata": { (...) }
}


In addition to the "files" array, the response always contains the "serviceMetadata" object with information that includes the "next" parameter, which can be used to obtain the next set of results if the data found exceeds the row limit.

"serviceMetadata" object example
{
    "files":[ (...) ],
    "serviceMetadata":{
        "dateArchivedFrom":null,
        "dateArchivedTo":null,
        "dateFrom":null,
        "dateTo":null,
        "deviceCategoryCode":"JB",
        "locationCode":"BACUS",
        "next":{
            "parameters":{
                "method":"getListByLocation",
                "rowLimit":"5",
                "page":"2",
                "locationCode":"BACUS",
                "deviceCategoryCode":"JB",
                "token":"ffffffff-ffff-ffff-ffff-ffffffffffff"
            },
            "url":"https://data.oceannetworks.ca/api/archivefiles?method=getListByLocation&rowLimit=5&page=2&locationCode=BACUS&deviceCategoryCode=JB&token=ffffffff-ffff-ffff-ffff-ffffffffffff"
        },
        "page":2,
        "returnOptions":"",
        "rowLimit":5
    }
}


In general, the properties in the response can be described as follows:

Property

Type

Description

Example

files.archivedDatedateThe time stamp of current file in AD while it is archived2010-04-21T00:00:00.000Z
files.compressedSizelongFile size, in bytes, after compressed with GZip
files.compressionstringThe file extension if the file is compressedgz
files.dataProductCodestringData product code8
files.dateFromdateThe beginning time stamp the data is recorded in the file2010-04-21T00:00:00.000Z
files.dateModifieddateThe last time stamp of any modification related to the file2010-04-22T01:55:00.000Z
files.dateTodateThe end time stamp the data is recorded in the file2010-04-22T00:00:00.000Z
files.deviceCodestringDevice Code
files.filenamestringThe name of the file "BC_POD2_JB_20090908T000000.000Z.txt"
files.uncompressedSizelongOriginal file size, in bytes, without compressed 156545

next

ObjectAn object containing information for the next service call if the current call was unable to return all the data due to limit restrictions. This is null if there is no more data in the requested range.
  • next.parameters

ObjectAn object containing the set of parameters making up the query to get the next set of data in the requested date range. The parameters will include all parameters passed into the original URL.
    • next.parameters.deviceCategoryCode

StringAs passed into the original call"JB"
    • next.parameters.method

StringAs passed into the original call"getListByLocation"
    • next.parameters.returnOptions

StringAs passed into the original call"archiveLocation"
    • next.parameters.rowLimit

integerAs passed into the original call5
    • next.parameters.page

integerThe page index for next call.1
    • next.parameters.locationCode

StringAs passed into the original call"BACUS"
    • next.parameters.token

StringAs passed into the original call

"ffffffffffffffffffffffffffffffff"

  • next.url

StringThe complete URL that can be used to get the next set of data in the requested range.

queryUrlStringURL of current query


getListByDevice()

getListByDevice(deviceCode, filters, options)


Get a list of files for a given device code, optionally filtered by time ranges. This method has the same filters, options and response format as getListByLocation(), with the only difference being that a deviceCode must be included in the method invocation.


Parameter

Type

Description

Example

Required


deviceCodestring

The code of the device.

'BC_POD2_JB'
Optional


filtersdictionary

Same as getListByLocation()


optionsdictionary

Same as getListByLocation()


Example

getListByDevice() Example: Get a simple file list for device code 'BC_POD2_JB' obtained in a certain date
from onc.onc import ONC
onc = ONC('YOUR_TOKEN')

filters = {'dateFrom': '2018-11-07T00:00:00.000Z', 'dateTo': '2018-11-08T00:00:00.000Z'}
result = onc.getListByDevice('BC_POD2_JB', filters)
print result


Returns

Returns a list of files with the same format described for getListByLocation().

getFile()

getFile(filename)


Download the file at "filename" from DMAS Archiving System and save it in the outPath configured for the ONC library object (usually in the constructor). The file will be downloaded in compressed format if available.


Parameters 

ParameterTypeDescriptionExample
Required
filenamestringA valid name of a file in DMAS Archiving System.'NAXYS_02345_P008_20100107T185747.660Z.wav'

Example

getFile() Example: Download the file with filename 'BC_POD2_JB_20181107T000000.000Z.txt'
from onc.onc import ONC
onc = ONC('YOUR_TOKEN', True, True, 'C:/Downloads')

result = onc.getFile('BC_POD2_JB_20181107T000000.000Z.txt')
print result

Response

This method returns a number with the status code of the operation. A value of 200 usually means that the operation was successful and the file was downloaded and saved. In case of error, setting the "showInfo" property of the ONC library object will print a description of the problem.





Near Real-Time data product methods

getDirectScalarByStation() - deprecated

getDirectScalarByStation(filters={}, outputFormat='Object', metadata='Full', rowLimit=None) - deprecated in favour of getDirectScalar()


Returns scalar data, in JSON Object or Array format, in the response payload that meet the criteria defined by the input filters.


Parameter
Type
Description
Example
Required


filtersdictionary

A dictionary of filter criteria parameters, used to request data and metadata from the ONC scalardata endpoint.

{
'locationCode':'TWDP',
'deviceCategoryCode':'TSG',
'begin':'2016-09-01T00:00:00.000Z',
'end':'2016-09-01T08:00:00.000Z'
}

Option


outputFormatstring

The encoding of the response output.

  • Object - Data are a list of dictionaries with sampleTime, value and qaqcFlag for a given sensor.
  • Array - Data have 3 arrays for a given sensor. Array of sampleTime, array of values and array of qaqcFlags
  • If excluded, the default 'Object' is used.
"outputFormat":"Array"
metadatastring

The amount of metadata detail included in the response output.

  • Minimum - Provides only basic property information. Response includes serviceMetadata dictionary only.
  • Full - Provides all property information. Response includes both metadata and serviceMetadata dictionaries.
  • If excluded, the default 'Minimum' is used.
"metadata":"Full"
rowLimitinteger

The maximum number of rows of scalar data that will be returned for each sensor.

  • Maximum is 100,000.
  • If excluded, the default 100,000 is used.
"rowLimit":5000


Returns

A dictionary that contains sensor data that match the filter criteria defined in the input parameters, metadata and service metadata.

{
    'metadata': {
        'bbox': {
            'maxDepth': 3.0, 
            'maxLat': 49.080909946666665, 
            'maxLon': -123.37824890666667, 
            'minDepth': 3.0, 
            'minLat': 49.080909946666665, 
            'minLon': -123.37824890666667
        }, 
        'depth': 3.0, 
        'deviceCategoryName': 'TSG', 
        'latitude': 49.080909946666665, 
        'longitude': -123.37824890666667, 
        'begin': '2016-09-01T00:00:00.000Z', 
        'end': '2016-09-01T00:00:30.000Z', 
        'locationCode': 'TWDP'
    }, 
    'sensorData': [
        {
            'actualSamples': 1, 
            'data': [
                {
                    'qaqcFlag': 1, 
                    'sampleTime': '2016-09-01T00:00:07.037Z', 
                    'value': 3.44294
                }
             ], 
             'sensor': 'Conductivity', 
             'sensorName': 'Conductivity', 
             'unitOfMeasure': 'S/m'
        }, 
        {
            'actualSamples': 1, 
            'data': [
                {
                    'qaqcFlag': 1, 
                    'sampleTime': '2016-09-01T00:00:07.037Z', 
                    'value': 28.9096
                }
            ], 
            'sensor': 'salinity', 
            'sensorName': 'Practical Salinity', 
            'unitOfMeasure': 'psu'
        },
        {...}
    ], 
    'serviceMetadata': {
        'metadata': 'Full', 
        'nextDateFrom': '2016-09-01T00:00:17.041Z', 
        'outputFormat': 'Object', 
        'rowLimit': None, 
        'sensors': None, 
        'totalActualSamples': 3, 
        'begin': '2016-09-01T00:00:00.000Z', 
        'end': '2016-09-01T00:00:10.000Z', 
        'deviceCategoryCode': 'TSG', 
        'locationCode': 'TWDP'
    }
}
Property
Type
Description
metadatadictionaryA dictionary of metadata, if metadata='Full' input parameter is used.
metadata.bboxdictionaryA Bounding Box dictionary.
metadata.bbox.maxDepthfloatThe maximum depth of the instruments contributing to the results.
metadata.bbox.maxLatfloatThe maximum Latitude of bounding box of the instruments contributing to the results.
metadata.bbox.maxLonfloatThe maximum Longitude of the bounding box of the instruments contributing to the results.
metadata.bbox.minDepthfloatThe minimum Depth of the instruments contributing to the results.
metadata.bbox.minLatfloatThe minimum Latitude of bounding box of the instruments contributing to the results.
metadata.bbox.minLonfloatThe minimum Longitude of the bounding box of the instruments contributing to the results.
sensorDatalistA list of sensor dictionaries.
sensorData[].acutalSamplesintThe number of samples in the data list.
sensorData[].datalistA list of observation dictionaries.
sensorData[].data[].qaqcFlagintThe QAQC Flag for the observation.
sensorData[].data[].sampleTimedatetime string

The recorded time of the observation.

sensorData[].data[].valuefloatThe value of the observation.
sensorData[].sensorstringThe code of the sensor that is being observed.
sensorData[].sensorNamestringThe name of the sensor that is being observed.
sensorData[].unitOfMeasurestringThe unit of measure of the observation.
serviceMetadatadictionaryA dictionary of metadata for the service request.
serviceMetadata.metadatastringThe requested metadata filter.
serviceMetadata.nextDataFromdatetime stringThe begin date for next reading in yyyy-MM-ddTHH:mm:ss.SSSZ format.
serviceMetadata.outputFormatstringThe requested JSON output format.
serviceMetadata.rowLimitintThe requested row limit per sensor.
serviceMetadata.sensorsstringA comma separated list of the requested sensors.
serviceMetadata.totalActualSamplesintThe number of observations expected for all specified sensors.
serviceMetadata.begindatetime stringThe begin date of the request in yyyy-MM-ddTHH:mm:ss.SSSZ format.
serviceMetadata.enddatetime stringThe end date of the request in yyyy-MM-ddTHH:mm:ss.SSSZ format.
serviceMetadata.deviceCategoryCodestringThe Device Category Code of the request. See Available Device Categories for further details.
serviceMetadata.locationCodestringThe Location Code of the request. See Available Locations for further details.
Example - Print the last Thermosalinograph reading from Tswwassen - Duke Point Ferry
o = onc('YOUR_TOKEN_HERE')
 
result = o.getDirectScalarByStation({'locationCode','TWDP','deviceCategoryCode','TSG'});

disp(result)
Example - Print 1 hour of Thermosalinograph readings from Tswwassen - Duke Point Ferry
from onc.onc import ONC
onc = ONC('YOUR_TOKEN_HERE')
 
result = onc.getDirectScalarByStation({'locationCode':'TWDP','deviceCategoryCode':'TSG', 'begin':'2016-09-01T00:00:00.000Z', 'end':'2016-09-01T01:00:00.000Z'})

sensorData = result['sensorData']
if (sensorData):
	print('Properties (variables)')
	for data in sensorData:
		print("  {}".format(data['sensorName']))
		for sample in data['data']:
			print ("    Value = {} ; Sample Time = {}".format(sample['value'],sample['sampleTime']))
 
serviceMetadata = result['serviceMetadata']
if(serviceMetadata):
    print('{} samples'.format(serviceMetadata['totalActualSamples']))
Example - Print 1 hour of Thermosalinograph readings from Tswwassen - Duke Point Ferry as an Array
from onc.onc import ONC
onc = ONC('YOUR_TOKEN_HERE')
 
result = onc.getDirectScalarByStation({'locationCode':'TWDP','deviceCategoryCode':'TSG', 'begin':'2016-09-01T00:00:00.000Z', 'end':'2016-09-01T01:00:00.000Z'},'Array')

if (result):
    sensorData = result['sensorData']
    if (sensorData):
        print('Properties (variables)')
        for data in sensorData:
            print("  {}".format(data['sensorName']))
            samples = data['data']
            for i in range(0,data['actualSamples'] - 1):
                print ("    Value = {} ; Sample Time = {}".format(samples['values'][i],samples['sampleTimes'][i]))
 
serviceMetadata = result['serviceMetadata']
if(serviceMetadata):
    print('{} samples'.format(serviceMetadata['totalActualSamples']))

getDirectScalar()

getDirectScalar(filters={})


Returns scalar data in the response payload that meet the criteria defined by the input filters.


Parameter

Type

Description

Example

Required


filtersdictionary

A dictionary of filter criteria parameters, used to request data and metadata from the ONC scalardata endpoint.

  • Filters must include locationCode and deviceCategoryCode.
  • Filters can optionally Include dateFrom and dateTo (a date range).
  • Filters can optionally specify "metadata" as "minimum" (default) or "full".
    • Minimum provides only basic property information.
    • Full provides all property information. Response includes metadata structure.
  • Filters can optionally specify "rowLimit", the maximum number of rows of data that will be returned for each sensor.
    • The maximum is 100,000. If omitted or a higher or invalid limit is specified, the default of 100,000 is used.
  • See locations Discovery Service and deviceCategories Discovery Service  for more information on filter usage.

{
'locationCode':'TWDP',
'deviceCategoryCode':'TSG',
'dateFrom':'2016-09-01T00:00:00.000Z',
'dateTo':'2016-09-01T08:00:00.000Z'
}


Returns

A dictionary that contains sensor data that match the filter criteria defined in the input parameters, metadata and service metadata.

{
    'metadata': {
        'boundingBox': {
            'maxDepth': 3.0, 
            'maxLat': 49.080909946666665, 
            'maxLon': -123.37824890666667, 
            'minDepth': 3.0, 
            'minLat': 49.080909946666665, 
            'minLon': -123.37824890666667
        }, 
        'depth': 3.0, 
        'deviceCategoryCode': 'Thermosalinograph', 
        'latitude': 49.080909946666665, 
        'longitude': -123.37824890666667, 
        'locationName': 'Tsawwassen - Duke Point'
    }, 
    'sensorData': [
        {
            'data':
                {
                    'qaqcFlag': [...], 
                    'sampleTime': [...], 
                    'value': [...]
                }, 
            'sensor': 'salinity', 
            'sensorName': 'Practical Salinity', 
            'unitOfMeasure': 'psu'
        },
        {...}
    ], 
    'next': {
        'url': 'https://data.oceannetworks.ca/api/scalardata?metadata=full&method=getByLocation&end=2016-09-01T08%3A00%3A00.000Z&rowLimit=10&locationCode=TWDP&deviceCategoryCode=TSG&begin=2016-09-01T00%3A01%3A47.042Z&token=f68bc7e1-f231-481d-b32e-590c5c1e1ee8', 
        'parameters': {
            'metadata': 'Full', 
            'token': 'YOUR_TOKEN_HERE', 
            'rowLimit': 10, 
            'begin': '2016-09-01T00:00:00.000Z', 
            'end': '2016-09-01T00:00:10.000Z', 
            'deviceCategoryCode': 'TSG', 
            'locationCode': 'TWDP'
        }
    }
}

Property

Type

Description

metadatadictionaryA dictionary of metadata, if metadata='Full' input parameter is used.
metadata.boundingBoxdictionaryA Bounding Box dictionary.
metadata.boundingBox.maxDepthfloatThe maximum depth of the instruments contributing to the results.
metadata.boundingBox.maxLatfloatThe maximum Latitude of bounding box of the instruments contributing to the results.
metadata.boundingBox.maxLonfloatThe maximum Longitude of the bounding box of the instruments contributing to the results.
metadata.boundingBox.minDepthfloatThe minimum Depth of the instruments contributing to the results.
metadata.boundingBox.minLatfloatThe minimum Latitude of bounding box of the instruments contributing to the results.
metadata.boundingBox.minLonfloatThe minimum Longitude of the bounding box of the instruments contributing to the results.
sensorDatalistA list of sensor dictionaries.
sensorData[].acutalSamplesintThe number of samples in the data list.
sensorData[].datalistA list of observation dictionaries.
sensorData[].data.qaqcFlags[]intThe QAQC Flag for the observation.
sensorData[].data.sampleTimes[]datetime string

The recorded time of the observation.

sensorData[].data.values[]floatThe value of the observation.
sensorData[].sensorstringThe code of the sensor that is being observed.
sensorData[].sensorNamestringThe name of the sensor that is being observed.
sensorData[].unitOfMeasurestringThe unit of measure of the observation.
nextdictionaryA dictionary of metadata for the service request.
next.urlstringThe request url.
next.parametersdictionaryA dictionary of metadata for the service request.
next.parameters.rowLimitintThe requested row limit per sensor.
next.parameters.tokenstringThe user's token.
next.parameters.methodstring'getByLocation'
next.parameters.begindatetime stringThe begin date of the request in yyyy-MM-ddTHH:mm:ss.SSSZ format.
next.parameters.enddatetime stringThe end date of the request in yyyy-MM-ddTHH:mm:ss.SSSZ format.
next.parameters.deviceCategoryCodestringThe Device Category Code of the request. See Available Device Categories for further details.
next.parameters.locationCodestringThe Location Code of the request. See Available Locations for further details.
Example - Print the last Thermosalinograph reading from Tswwassen - Duke Point Ferry
o = onc('YOUR_TOKEN_HERE')
 
result = o.getDirectScalar({'locationCode','TWDP','deviceCategoryCode','TSG'});

disp(result)
Example - Print 1 hour of Thermosalinograph readings from Tswwassen - Duke Point Ferry
from onc.onc import ONC
onc = ONC('YOUR_TOKEN_HERE')
 
result = onc.getDirectScalar({'locationCode':'TWDP','deviceCategoryCode':'TSG', 'dateFrom':'2016-09-01T00:00:00.000Z', 'dateTo':'2016-09-01T01:00:00.000Z'})

sensorData = result['sensorData']
if (sensorData):
	print('Properties (variables)')
	for data in sensorData:
		print("  {}".format(data['sensorName']))
		for sample in data['data']:
			print ("    Value = {} ; Sample Time = {}".format(sample['value'],sample['sampleTime']))
 
serviceMetadata = result['serviceMetadata']
if(serviceMetadata):
    print('{} samples'.format(serviceMetadata['totalActualSamples']))


getDirectRawByStation() - deprecated

getDirectRawByStation(filters={}, rowLimit=None) - deprecated in favour of getDirectRawByLocation()


Returns raw data from an instrument in the payload, in JSON format that meet the criteria defined by the input filters.


Parameter
Type
Description
Example
Required


filtersdictionary

A dictionary of filter criteria parameters, used to request data and metadata from the ONC rawdata endpoint.

{
'locationCode':'TWDP',
'deviceCategoryCode':'TSG',
'begin':'2016-09-01T00:00:00.000Z',
'end':'2016-09-01T08:00:00.000Z'
}

Option


rowLimitinteger

The maximum number of rows of raw data that will be returned.

  • Maximum is 100,000.
  • If excluded, the default 100,000 is used.
"rowLimit":5000


Returns

A dictionary that contains sensor data matching the filter criteria defined in the input parameters, metadata and service metadata.

{
    'data': [
        {
            'rawData': '!AIVDM,1,1,,A,14eI18gP00G<JMPL<IaCNOv62D1C,0*43', 
            'sampleTime': '2017-06-23T17:18:04.645Z'
        }, 
        {
            'rawData': '!AIVDM,1,1,,A,34eGo=P009G;qPJL:kiv3I6800li,0*5C', 
            'sampleTime': '2017-06-23T17:18:04.698Z'
        }
    ], 
    'metadata': {
        'dataMetadata': {
            'firstTimestamp': '2017-06-23T17:18:04.645Z', 
            'hasMoreDataInRange': True, 
            'lastTimestamp': '2017-06-23T17:18:04.698Z', 
            'numberOfData': 2, 
            'locationCode': 'Iona Shore Station'
        }, 
        'queryMetadata': {
            'rowLimit': 2, 
            'stationCode': 'IONA', 
            'begin': None, 
            'end': None, 
            'deviceCategoryCode': 'AISRECEIVER'
        }
    }
}
Property
Type
Description
datadictionary
data[].rawDatadictionaryA raw data string representing a sample at a specific time.
data[].sampleTimedatetime string

The recorded time of the observation.

metadatadictionaryA structure containing metadata.
metadata.dataMetadatadictionaryA structure containing metadata about the data.
metadata.dataMetadata.firstTimestampdatetime stringThe date time of the first record in yyyy-MM-ddTHH:mm:ss.SSSZ format.
metadata.dataMetadata.hasMoreDataInRangeint

Whether more data are available within the range of the request. For example if 1,000 records are returned (because the rowLimit=1000), but there could be 200,000 rows as defined by the filter criteria.

  • 0 = False
  • 1 = True
metadata.dataMetadata.lastTimestampdatetime stringThe date time of the last record in yyyy-MM-ddTHH:mm:ss.SSSZ format.
metadata.dataMetadata.numberOfDataintThe number of samples in the data list.
metadata.dataMetadata.locationNamestringThe full name of the location.
metadata.queryMetadatastructA structure containing metadata about the data request (query).
metadata.queryMetadata.rowLimitintThe requested row limit per sensor.
metadata.queryMetadata.begindatetime stringThe begin date of the request in yyyy-MM-ddTHH:mm:ss.SSSZ format.
metadata.queryMetadata.enddatetime stringThe end date of the request in yyyy-MM-ddTHH:mm:ss.SSSZ format.
metadata.queryMetadata.deviceCategoryCodestringThe Device Category Code of the request. See Available Device Categories for further details.
metadata.queryMetadata.locationCodestringThe Location Code of the request. See Available Locations for further details.
Example - Print the last raw instrument reading from AIS Reviever at the Underwater Listening Station at IONA
from onc.onc import ONC
onc = ONC('YOUR_TOKEN_HERE')
 
payload = onc.getDirectRawByStation({'locationCode':'IONA','deviceCategoryCode':'AISRECEIVER'},1)


data = payload['data']
if (data):
    for d in data:
        print ("  Raw Data = '{}' ; Sample Time = {}".format(d['rawData'],d['sampleTime']))


metadata = payload['metadata']
if(metadata):
    dataMetadata=metadata['dataMetadata']
    if(dataMetadata):
        print('{} samples'.format(dataMetadata['numberOfData']))
Example - Print 1 hour of raw CTD readings from Barkley Canyon Axis
from onc.onc import ONC
onc = ONC('YOUR_TOKEN_HERE')
 
payload = onc.getDirectRawByStation({'locationCode':'BACAX','deviceCategoryCode':'CTD','begin':'2017-05-23T00:00:00.000Z','end':'2017-05-23T01:00:00.000Z'})


data = payload['data']
if (data):
    for d in data:
        print ("  Raw Data = '{}' ; Sample Time = {}".format(d['rawData'],d['sampleTime']))


metadata = payload['metadata']
if(metadata):
    dataMetadata=metadata['dataMetadata']
    if(dataMetadata):
        print('{} samples'.format(dataMetadata['numberOfData']))


getDirectRawByLocation()

getDirectRawByLocation(filters={})


Returns raw data from an instrument in the payload, in JSON format that meet the criteria defined by the input filters.


Parameter

Type

Description

Example

Required


filtersdictionary

A dictionary of filter criteria parameters, used to request data and metadata from the ONC rawdata endpoint.

{
'locationCode':'TWDP',
'deviceCategoryCode':'TSG',
'dateFrom':'2016-09-01T00:00:00.000Z',
'dateTo':'2016-09-01T08:00:00.000Z'
}


Returns

A dictionary that contains sensor data matching the filter criteria defined in the input parameters, metadata and service metadata.

{
    'data': {...}, 
    'metadata': {...}, 
    'next': {...}
}

Property

Type

Description

datadictionary
data.readings[]dictionaryA raw data string representing a sample at a specific time.
data.times[]datetime string

The recorded time of the observation.

metadata.locationNamestringThe full name of the location.
nextdictionaryA structure containing metadata.
next.parametersdictionaryA structure containing metadata about the data.
next.urlstringA string containing the query url.
next.parameters.rowLimitintThe requested row limit per sensor.
next.parameters.begindatetime stringThe begin date of the request in yyyy-MM-ddTHH:mm:ss.SSSZ format.
next.parameters.enddatetime stringThe end date of the request in yyyy-MM-ddTHH:mm:ss.SSSZ format.
next.parameters.deviceCategoryCodestringThe Device Category Code of the request. See Available Device Categories for further details.
next.parameters.locationCodestringThe Location Code of the request. See Available Locations for further details.
Example - Print the last raw instrument reading from AIS Reviever at the Underwater Listening Station at IONA
from onc.onc import ONC
onc = ONC('YOUR_TOKEN_HERE')
 
payload = onc.getDirectRawByLocation({'locationCode':'IONA','deviceCategoryCode':'AISRECEIVER'},1)

data = payload['data']
Example - Print 1 hour of raw CTD readings from Barkley Canyon Axis
from onc.onc import ONC
onc = ONC('YOUR_TOKEN_HERE')
 
payload = onc.getDirectRawByLocation({'locationCode':'BACAX','deviceCategoryCode':'CTD','dateFrom':'2017-05-23T00:00:00.000Z','dateTo':'2017-05-23T01:00:00.000Z'})

data = payload['data']

getDirectRawByDevice()

getDirectRawByDevice(filters={})


Returns raw data from an instrument in the payload, in JSON format that meet the criteria defined by the input filters.


Parameter

Type

Description

Example

Required


filtersdictionary

A dictionary of filter criteria parameters, used to request data and metadata from the ONC rawdata endpoint.

{
'deviceCode':'SBECTD16p6002',
'dateFrom':'2016-09-01T00:00:00.000Z',
'dateTo':'2016-09-01T08:00:00.000Z'
}


Returns

A dictionary that contains sensor data matching the filter criteria defined in the input parameters, metadata and service metadata.

{
    'data': {...}, 
    'metadata': {...}, 
    'next': {...}
}

Property

Type

Description

datadictionary
data.readings[]dictionaryA raw data string representing a sample at a specific time.
data.times[]datetime string

The recorded time of the observation.

nextdictionaryA structure containing metadata.
next.parametersdictionaryA structure containing metadata about the data.
next.urlstringA string containing the query url.
next.parameters.rowLimitintThe requested row limit per sensor.
next.parameters.begindatetime stringThe begin date of the request in yyyy-MM-ddTHH:mm:ss.SSSZ format.
next.parameters.enddatetime stringThe end date of the request in yyyy-MM-ddTHH:mm:ss.SSSZ format.
next.parameters.deviceCodestringThe Device Code of the request. See Available Device Categories for further details.
metadata.queryMetadata.locationCodestringThe Location Code of the request. See Available Locations for further details.
Example - Print the last raw instrument reading from AIS Reviever at the Underwater Listening Station at IONA
from onc.onc import ONC
onc = ONC('YOUR_TOKEN_HERE')
 
payload = onc.getDirectRawByDevice({'rowLimit':1,'deviceCategoryCode':'DIGITALYACHTAISNET1302-0097-01'})

data = payload['data']
Example - Print 1 hour of raw CTD readings from Barkley Canyon Axis
from onc.onc import ONC
onc = ONC('YOUR_TOKEN_HERE')
 
payload = onc.getDirectRawByDevice({'deviceCode':'SBECTD16p6002','dateFrom':'2017-05-23T00:00:00.000Z','dateTo':'2017-05-23T01:00:00.000Z'})

data = payload['data']

getDirectFiles()

getDirectFiles( filters )


Returns data files from an instrument in the payload, in JSON format that meet the criteria defined by the input filters.

Parameter

Type

Description

Example

Required


filters

dictionary

A dictionary of filter criteria parameters, used to request data and metadata from the rawdata endpoint.

  • A list of filter/value pairs in the following format {'<filter_1>':'<value_1>','<filter_2>':'<value_2>',...}.
  • Filters must include locationCode.
  • Filters can optionally Include dateFrom and dateTo (a date range).
  • See locations Discovery Service for more information on filter usage.


{'locationCode':'TWDP',
'deviceCategoryCode':'TSG',
'dateFrom':'2016-09-01T00:00:00.000Z',
'dateTo':'2016-09-01T08:00:00.000Z'}


Returns

A structure that contains sensor data matching the filter criteria defined in the input parameters, metadata and service metadata.

Example - Print the last raw instrument reading from the CTD at Barkley Canyon Axis
from onc.onc import ONC
onc = ONC('YOUR_TOKEN_HERE')
 
payload = onc.getDirectFiles({'locationCode':'BACAX','deviceCategoryCode':'CTD'})

data = payload['data']
Example - Print the last raw instrument reading from AIS Reviever at the Underwater Listening Station at IONA
from onc.onc import ONC
onc = ONC('YOUR_TOKEN_HERE')
 
payload = onc.getDirectFiles({'locationCode','IONA','deviceCategoryCode','AISRECEIVER'})

data = payload['data']
Example - Print 1 hour of raw CTD readings from Barkley Canyon Axis
from onc.onc import ONC
onc = ONC('YOUR_TOKEN_HERE')
 
payload = onc.getDirectFiles({'locationCode':'BACAX','deviceCategoryCode':'CTD','dateFrom':'2017-05-23T00:00:00.000Z','dateTo':'2017-05-23T01:00:00.000Z'})

data = payload['data']


Please report all issues with the web services, documentation, samples and client libraries to the Oceans 2.0 Help Centre 


Version history

Note: All package versions can be downloaded from the PyPI project at https://pypi.org/project/onc/#history

VersionDateDescription
1.25.428/02/2019
  • Various code improvements to deal with an issue that would throw an InsecureRequestWarning in certain configurations.
1.25.318/12/2018
  • Added timeout parameter to the onc class constructor
  • Solved a bug that would prevent the onc package from updating the code
1.2428/11/2018
  • Added new archivefile API wrapper functions: getListByLocation(), getListByDevice(), getFile()
  • Updated the PyPI deployment scripts to accommodate new PyPI requirements
  • Added Apache 2.0 license (package previously licensed as both Apache 2.0 and MIT)
  • All package versions can be downloaded from the PyPI project at https://pypi.org/project/onc/#history
1.2316/04/2018
  • Added UserTestCase_EMP_UTC_001.py to demonstrate use of discovery services
  • Added UserTestCase_EMP_UTC_004.py to demonstrate use of archivefiles service
  • Updated getDirectFiles() for changes in archivefiles service
  • Updated user test case scripts for change of begin/end to dateFrom/dateTo
1.2202/02/2018
  • Added UserTestCase_EMP_UTC*.py scripts to demonstrate use of client library functions
  • Updated getDirectScalar*() functions for changes in scalardata service
1.2119/01/2018
  • Added getLocationHerarchy() function to access getTree method of locations service
  • Changed string testing for compatibility with Python V2
  • Added getDirectRawBy*() functions for changes in rawdata service
1.1909/28/2017
  • Updated orderDataProduct() function to handle estimatedProcessingTime string format
  • Updated downloadDataProduct() function to throttle calls using onc.callsPerSecond when downloadResultsOnly=True
1.1808/23/2017Added getDeployments() function.Updated QA url from http://qaweb2.neptune.uvic.ca to https://qa.oceannetworks.ca.Updated production url to https.
1.1708/15/2017Added file parameter defult to the download() function.
1.1608/11/2017Rename 'parameters' parameter to 'filters' in all applicable ONC class functions
1.1508/03/2017Updated production url from http://dmas.uvic.ca/ to http://data.oceannetworks.ca.
1.1408/01/2017Resolved issue with getDataProductUrls method.
1.1307/31/2017Renamed getJsonFromUrl() function to decodeJsonFromUrl().
1.1206/23/2017Refactored scalar and raw data access methods.Removed print methods for testing services.Renamed private functions.Added numpy references.
1.1106/13/2017Removed unused numpy dependency.Added python-dateutil dependency to package.
1.106/12/2017Rename onc.dap.DAP class to onc.dap.ERDDAP.
1.006/09/2017Alpha version.

New versions are created to resolve known client library issues, add new functionality or handle changes to the underlying Web Services.

The latest version works with the current deployment of the underlying web services. See API Reference.

  • No labels