Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

version
Date
Description
Toolbox
Source
1.06/28/2017Alpha version.

onc-1.0.mltbx

 
1.017/18/2017Added getDirectScalar(), getDirectRaw() and getDirectFiles() functions.onc-1.01.mltbxonc-1.02-source.zip
1.027/28/2017

Resolve unhandled exception with invalid parameters.

Resolved naming inconsistencies.

onc-1.02.mltbxonc-1.02-source.zip
1.038/01/2017Added getDataProductUrls(), downloadFile() and decodeJsonFromUrl() functionsonc-1.03.mltbxonc-1.03-source.zip
1.048/03/2017Updated production URL from http://dmas.uvic.ca to http://data.oceannetworks.ca.onc-1.04.mltbxonc-1.04-source.zip
1.058/11/2017Rename 'parameters' parameter to 'filters' in all applicable onc class functions.onc-1.05.mltbxonc-1.04-source.zip
1.068/15/2017Added file parameter defult to the download() function.onc-1.06.mltbxonc-1.06-source.zip
1.078/23/2017

Added getDeployments() function.

Updated QA url from http://qaweb2.neptune.uvic.ca to https://qa.oceannetworks.ca.

Updated production url to https.

onc-1.07.mltbxonc-1.07-source.zip
1.089/28/2017

Updated orderDataProduct() function to handle estimatedProcessingTime string format

Updated downloadDataProduct() function to throttle calls using onc.callsPerSecond when downloadResultsOnly=true

onc-1.08.mltbxonc-1.08-source.zip
1.092018-01-18

Updated Matlab versions of discovery functions to handle empty parameter lists

Added getLocationHerarchy() function to access getTree method of locations service

Fixed file counting bug in getDirectFiles() function

Added getDirectRawBy*() functions for changes in rawdata service

Added initial versions of UserTestCase_EMP_UTC_001.m and UserTestCase_EMP_UTC_002.m

Updated functions to return more meaningful info when URL call fails

onc-1.09.mltbxonc-1.09-source.zip
1.102018-02-02

Added UserTestCase_EMP_UTC*.m scripts to demonstrate use of client library functions

Updated getDirectScalar*() functions for changes in scalardata service

Improved error reporting

onc-1.10.mltbxonc-1.10-source.zip
1.112018-04-16

Added UserTestCase_EMP_UTC_004.m to demonstrate use of archivefiles service

Updated getDirectFiles() for changes in archivefiles service

Improved error handling and reporting in user test case example scripts

Updated user test case scripts for change of begin/end to dateFrom/dateTo

onc-1.11.mltbxonc-1.11-source.zip

...

Info

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.

Classes

...


class
description
oncA wrapper class for access to Oceans 2.0 API web services

...


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

...

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, such as request URL and processing time information, are displayed.

  • 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'
timeoutint

The web service request timeout in seconds

  • Default is 60
30

 


Usage

Code Block
languagepy
themeConfluence
linenumberstrue
o = onc('YOUR_TOKEN_HERE');

...

Code Block
languagepy
linenumberstrue
production = true;
showInfo = false;
outPath = 'c:/ONC/Data';
timeout = 30;
o = onc('YOUR_TOKEN_HERE',production,showInfo,outPath,timeout);

...


Discovery methods

getLocations()

No Format
getLocations(filters)

...


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

...


Parameter
Type
Description
Example
Optional   


filtersstruct or array

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

struct('locationCode','BACAX')

or

{'locationCode','BACAX'}

...


Returns

A list of location objects.

...

Property
Type
Description
Example
location[]listA list structure array of location structureslocations. 

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.
depth75
location[].bboxstructA Bounding Box structure. 
location[].bbox.maxDepthdoubleThe maximum depth of the deployments.maxDepth100
location[].bbox.maxLatdoubleThe maximum Latitude of bounding box of the deployments.maxLat48.476740
location[].bbox.maxLondoubleThe maximum Longitude of the bounding box of the deployments.maxLon: -123.294904
location[].bbox.minDepthdoubleThe minimum Depth of the deployments.minDepth50
location[].bbox.minLatdoubleThe minimum Latitude of bounding box of the deployments.minLat48.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 requrested 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.lat48.47672
location[].dataSearchUrldataSearchURLstringThe location specific Data Search web page URL.
dataSearchURL: "https://data.oceannetworks.ca/DataSearch?location=BACAX"

...

No Format
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   


filtersstruct or array

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

  • A list of filter/value pairs in the following format struct('<filter_1>','<value_1>','<filter_2>','<value_2>',...) or {'<filter_1>','<value_1>','<filter_2>','<value_2>',...}.
  • If excluded, all locations are returned.
  • Valid filters: locationCode
  • See locations Discovery Service for more information on filter usage.
struct('locationCode','BACAX')

or

{'locationCode','BACAX'}

 


Returns

A hierarchy of location objects.

...

Property

Type

Description

Example
location[]listA list of location structures. 
location[].locationNamestringThe full name of the location.
locationName: "Axis (POD 1)"
location[].children[]listA list of location structures that are the children of this location structure.children: null
location[].depthdoubleThe average depth of the deployments.
depth75
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 requrested 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"

...

Code Block
languagepy
titleExample - Print locations at Barkley Upper South Slope
linenumberstrue
collapsetrue
o = onc('YOUR_TOKEN_HERE');

locations = o.getLocationHierarchy({'locationCode','BACUS'});
if isfield( locations, 'children' )
    for i = 1 : numel( locations.children )
        locations.children(i)
    end
end

 

...



getDevices()

No Format
getDevices(filters)

 


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

...


Parameter
Type
Description
Example
Optional   


filtersstruct or array

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

struct('deviceCode','NORTEKADCP9917')

or

{'deviceCode','NORTEKADCP9917'}

 


Returns

A list of device objects

...

Code Block
languagepy
titleExample - Print all devices deployed at Barkley Canyon - Axis, between June 1, 2016 and May 31, 2017
linenumberstrue
collapsetrue
o = onc('YOUR_TOKEN_HERE');

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

for i=1:numel(devices)
    disp(devices(i));
end

...


getDeployments()

Panel
getDeployments(filters={})

...


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

...


Parameter
Type
Description
Example
Optional   


filtersstruct or array

A comma separated list of one or more filter criteria, used to return an exclusive set of deployment elements from the ONC deployments endpoint.

{'deviceCode':'NORTEKADCP9917'}

 


Returns

A list of deployment objects.

...

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'.

dateFrom: '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'.

dateTo: '2016-08-01T00:00:00.000Z'

deployment[].hasDeviceData

stringIndicates that data products can be requested using a device category code for the deployment.
hasDeviceData: 1
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 pitch of the device deployment.roll: null

...

No Format
getDeviceCategories(filters)

...


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

 


Parameter
Type
Description
Example
Optional   


filtersstruct or array

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

struct('deviceCategoryCode','HYDROPHONE')

or

{'deviceCategoryCode','HYDROPHONE'}

...


Returns

A list of device category objects.

...

Property
Type
Description
Example
deviceCategory[]listA list of device categories. 
deviceCategory[].cvTermstructA structure of controlled vocabulary terms.
cvTerm: [1×1 struct]
deviceCategory[].cvTerm.deviceCategory[]structA list of structure of controlled vocabulary term information for the device category.
deviceCategory: [1×1 struct]
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. '

...

Code Block
languagepy
titleExample - Print all device categories available at Barkley Canyon - Upper Slope
linenumberstrue
collapsetrue
o = ONC('YOUR_TOKEN_HERE');

deviceCategories = o.getDeviceCategories({'locationCode','NCBC'});    #NCBC - Barkely Canyon / Upper Slope

for i=1:numel(deviceCategories)
    disp(deviceCategories(i));
end

...


getProperties()

No Format
getProperties(filters)

 


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

 


Parameter
Type
Description
Example
Optional   


filtersstruct or array

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

struct('propertyCode','seawatertemperature')

or

{'propertyCode','seawatertemperature'}

 


Returns

A list of property objects.

...

Property
Type
Description
Example
property[]listA list of properties. 

property[].cvTermstructA structure of controlled vocabulary terms.
cvTerm: [1×1 struct]
property[].cvTerm.property[]structA list of structures 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[]structA list of structures of controlled vocabulary term information for the unit of measure.
uom: [1×1 struct]
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 whether data products can be requested using the property code, along with a device category for a location.
hasDeviceData: 'true'
property[].hasPropertyDatastringIndicates whether 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 the property measurements.
uom: 'decibar'

...

Code Block
languagepy
titleExample - Print all properties that are available at Barkley Canyon - Axis
linenumberstrue
collapsetrue
o = onc('YOUR_TOKEN_HERE');

properties = o.getProperties({'locationCode','BACAX'});  #BACAX - Barkley Canyon / Axis

for i=1:numel(properties)
    disp(properties(i));
end

 


getDataProducts()

No Format
getDataProducts(filters)

...


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

 


Parameter
Type
Description
Example
Optional   


filtersstruct or array

A comma separated list of one or more filter criteria, used to return an exclusive set of data product & extension elements from the ONC dataProducts endpoint.

struct('dataProductCode','TSSD', ...
       'extension','json')
or
{'dataProductCode','TSSD', ...
 'extension','json'}

 


Returns

A list of data product objects.

...

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 whether the data product can be requested using a device category code and a location code.
hasDeviceData: 1
dataProduct[].hasPropertyDatastringIndicates whether the data product can be requested using a property code and a location code or device code.
hasPropertyData: 1
dataProduct[].helpDocumentstringA Link URL to the Oceans 2.0 Help documentation for the specific Data Product.
helpDocument: 'https://wiki.oceannetworks.ca/display/DP/1'

 

 



Code Block
languagepy
titleExample - Print all MatLab data product
linenumberstrue
collapsetrue
o = onc('YOUR_TOKEN_HERE');

dataProducts = o.getDataProducts({'extension','mat'}); %mat - MatLab

for i=1:numel(dataProducts)
    disp(dataProducts(i));
end

 


Data Product Download methods

...

No Format
orderDataProduct(filters, maxRetries, downloadResultsOnly, includeMetadataFile)

...


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

...

 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  


filtersstruct or array

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

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

or

{'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.
 

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 struct.
  • If excluded, the default of false is used.
 
includeMetadataFileboolean

Indicates whether 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.
 

...



Returns

A structure of download results and run time statistics.

...

Code Block
languagepy
titleExample - Download Time Series Scalar Data Product in CSV format for ADCP 2 MHZ at Barkley Canyon - Axis
linenumberstrue
collapsetrue
o = onc('YOUR_TOKEN_HERE');

results = o.orderDataProduct(struct('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),100,false,true);
            
for i=1:numel(results)
    disp(results{i});
end

...


requestDataProduct()
No Format
requestDataProduct(filters)

...


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 struct 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   


filters

struct or array

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

struct('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)
or
{'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}

 


Returns

A data product request structure

...

Code Block
           dpRequestId: 2046404
    compressedFileSize: 12563408
              fileSize: 70766230
              numFiles: 4
         downloadTimes: {1x3 cell}
 
 
                         10Mbps: 7.076623
                         50Mbps: 1.4153247
                         150Mbps: 0.47177488

...


for generated files:

Code Block
                dpRequestId: 2046404
          estimatedFileSize: 8348187
    estimatedProcessingTime: 16

...

Code Block
languagepy
titleExample - Download Time Series Scalar Data Product in CSV format for ADCP 2 MHZ at Barkley Canyon - Axis
linenumberstrue
collapsetrue
o = onc('YOUR_TOKEN_HERE');

requestInfo = o.requestDataProduct(struct('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));
            
disp(requestInfo);

 


runDataProduct()
No Format
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.

Code Block
    dpRunId: 4659102
     status: 'data product running'

...

Code Block
languagepy
titleExample - Run a requested data product
linenumberstrue
collapsetrue
o = onc('YOUR_TOKEN_HERE');

runs = o.runDataProduct(YOUR_REQUEST_ID_HERE);
 
disp(runs);

 


downloadDataProduct()
No Format
downloadDataProduct(runId, fileCount, estimatedProcessingTime, maxRetries, downloadResultsOnly, includeMetadataFile)

...


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 struct.
  • If excluded, the default of false is used.
true
includeMetadataFileboolean

Indicates whether 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 list of download results struct objects.

...

Code Block
languagepy
titleExample - Download the results of requested data product run
linenumberstrue
collapsetrue
o = onc('YOUR_TOKEN_HERE');

results = o.downloadDataProduct(YOUR_RUN_ID_HERE, 1);
 
for i=1:numel(results)
    disp(results{i});
end

...


getDataProductUrls()

Panel
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   


filtersstruct or array

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

struct('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)
or
{'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.

Code Block
["https://data.oceannetworks.ca/api/dataProductDelivery?method=download&token=<YOUR_TOKEN>&dpRunId=<YOUR_RUN_ID>&index=1"]

...

Code Block
languagepy
titleExample - Order a data product and get a list of the download urls
linenumberstrue
collapsetrue
o = onc('YOUR_TOKEN_HERE');
 
urls = o.getDataProductUrls(struct('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 i=1:numel(urls)
    disp(urls{i});
end

...


downloadFile()

Panel
downloadFile(url, file=[])

 


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

 


Returns

A downloadResults structure.

...

Code Block
languagepy
titleExample - Download a file from a url
linenumberstrue
collapsetrue
o = 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 = o.downloadFile(url, file);
 
disp(downloadResult);

 


decodeJsonFromUrl()

Panel
decodeJsonFromUrl(url)

 


Returns a structure object 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. 


Code Block
languagepy
titleExample - Get dictionary of results from json data product request
linenumberstrue
collapsetrue
o = onc('YOUR_TOKEN_HERE');
 
urls = o.getDataProductUrls(struct('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 i=1:numel(urls)
	object = o.decodeJsonFromUrl(url);
 	disp(object);
end

 


Near Real-Time data product methods

...

No Format
getDirectScalarByStation(filters, outputFormat, metadata, rowLimit) - 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   


filtersstruct or array

A comma separated list of filter criteria parameters, used to request data and metadata from the scalardata endpoint.

struct('locationCode','TWDP', ...

'deviceCategoryCode','TSG', ...
'begin','2016-09-01T00:00:00.000Z', ...
'end','2016-09-01T08:00:00.000Z')

or

{'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 structures 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 structure only.
  • Full - Provides all property information. Response includes both metadata and serviceMetadata structures.
  • 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 structure that contains sensor data that matches the filter criteria defined in the input parameters, metadata and service metadata.

...

No Format
getDirectScalar(filters)

 


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

 


Parameter

Type

Description

Example

Required   


filtersstruct or array

A comma separated list of filter criteria parameters, used to request data and metadata from the scalardata endpoint.

  • A list of filter/value pairs in the following format struct('<filter_1>','<value_1>','<filter_2>','<value_2>',...) or {'<filter_1>','<value_1>','<filter_2>','<value_2>',...}.
  • 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.

struct('locationCode','TWDP', ...

'deviceCategoryCode','TSG', ... 'dateFrom','2016-09-01T00:00:00.000Z', ...
'dateTo','2016-09-01T08:00:00.000Z')

or

{'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 that matches the filter criteria defined in the input parameters, metadata and service metadata.

...

Code Block
languagepy
titleExample - Print 1 hour of Thermosalinograph readings from Tswwassen - Duke Point Ferry
linenumberstrue
collapsetrue
o = onc('YOUR_TOKEN_HERE');
 
result = o.getDirectScalar(struct('locationCode','TWDP','deviceCategoryCode','TSG', 'dateFrom','2016-09-01T00:00:00.000Z', 'dateTo','2016-09-01T01:00:00.000Z'));

disp(result);

 

 



getDirectRawByStation() - deprecated

No Format
getDirectRawByStation(filters, rowLimit) - 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   


filter

struct

or

cell array

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

struct('locationCode','TWDP', ...
'deviceCategoryCode','TSG', ...
'begin','2016-09-01T00:00:00.000Z', ...
'end','2016-09-01T08:00:00.000Z')

or

{'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 structure that contains sensor data matching the filter criteria defined in the input parameters, metadata and service metadata.

...

Property
Type
Description
datastruct 
data[].rawDatastringA raw data string representing a sample at a specific time.
data[].sampleTimedatetime string

The recorded time of the observation.

metadatastructA structure containing metadata.
metadata.dataMetadatastructA 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 chould 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.

...

No Format
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   


filter

struct

or

cell array

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

  • A list of filter/value pairs in the following format struct('<filter_1>','<value_1>','<filter_2>','<value_2>',...) or {'<filter_1>','<value_1>','<filter_2>','<value_2>',...}.
  • Filters must include locationCode and deviceCategoryCode.
  • Filters can optionally Include dateFrom and dateTo (a date range).
  • 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.

struct('locationCode','TWDP', ...
'deviceCategoryCode','TSG', ...
'dateFrom','2016-09-01T00:00:00.000Z', ...
'dateTo','2016-09-01T08:00:00.000Z')

or

{'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.

...

Property

Type

Description

datastruct 
data.readings[]stringA 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.
nextstructA structure containing metadata.
next.parametersstructA 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.

...

Code Block
languagepy
titleExample - Print 1 hour of raw CTD readings from Barkley Canyon Axis
linenumberstrue
collapsetrue
o = onc('YOUR_TOKEN_HERE');
 
payload = o.getDirectRawByLocation(struct('locationCode','BACAX','deviceCategoryCode','CTD','dateFrom','2017-05-23T00:00:00.000Z','dateTo','2017-05-23T01:00:00.000Z'));

disp(payload);

...


getDirectRawByDevice()

No Format
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   


filter

struct

or

cell array

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

  • A list of filter/value pairs in the following format struct('<filter_1>','<value_1>','<filter_2>','<value_2>',...) or {'<filter_1>','<value_1>','<filter_2>','<value_2>',...}.
  • Filters must include deviceCode.
  • Filters can optionally Include dateFrom and dateTo (a date range).
  • 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 and devices Discovery Service for more information on filter usage.

struct('deviceCode','ICLISTENHF1293', ...
'dateFrom','2016-09-01T00:00:00.000Z', ...
'dateTo','2016-09-01T08:00:00.000Z')

or

{'deviceCode','ICLISTENHF1293', ...
'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.

...

Property

Type

Description

datastruct 
data.readings[]stringA raw data string representing a sample at a specific time.
data.times[]datetime string

The recorded time of the observation.

nextstructA structure containing metadata.
next.parametersstructA 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.

...

Code Block
languagepy
titleExample - Print 1 hour of raw CTD readings from Barkley Canyon Axis
linenumberstrue
collapsetrue
o = onc('YOUR_TOKEN_HERE');
 
payload = o.getDirectRawByDevice(struct('deviceCode','BACAX','dateFrom','2017-05-23T00:00:00.000Z','dateTo','2017-05-23T01:00:00.000Z'));

disp(payload);

 

 



getDirectFiles()

No Format
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

struct

or

cell array

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

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

struct('locationCode','TWDP', ...
'deviceCategoryCode','TSG', ...
'dateFrom','2016-09-01T00:00:00.000Z', ...
'dateTo','2016-09-01T08:00:00.000Z')

or

{'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.

...

Property

Type

Description

datastruct 


Code Block
titleExample - Print the last raw instrument reading from the CTD at Barkley Canyon Axis
linenumberstrue
collapsetrue
o = onc('YOUR_TOKEN_HERE');
 
payload = o.getDirectFiles(struct('locationCode','BACAX','deviceCategoryCode','CTD'),1);

disp(payload);

...

Code Block
languagepy
titleExample - Print 1 hour of raw CTD readings from Barkley Canyon Axis
linenumberstrue
collapsetrue
o = onc('YOUR_TOKEN_HERE');
 
payload = o.getDirectFiles(struct('locationCode','BACAX','deviceCategoryCode','CTD','dateFrom','2017-05-23T00:00:00.000Z','dateTo','2017-05-23T01:00:00.000Z'));

disp(payload);

 

 

...




Warning

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

...