Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: update begin/end to dateFrom/dateTo

This guide will help experienced users of the Oceans 2.0 web interface understand how to programmatically create Oceans 2.0 API data product requests, using the information available on the Data Search page, when they make an interactive data product request.

Instruments by Location Search

A typical, programmatic request for a data product request for an 'Instruments by Location' search, would use the following orderDataProduct() function call, available in one of the ONC client libraries:

 

Code Block
languagepy
titlePython Example
linenumberstrue
from onc.onc import ONC
onc = ONC('YOUR_TOKEN_HERE')

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


Code Block
languagepy
titleMATLAB Example
linenumberstrue
collapsetrue
o = onc('YOUR_TOKEN_HERE');

results = o.orderDataProduct(struct('locationCode','BACAX',...
                				    'deviceCategoryCode','ADCP2MHZ',...
                				    'dataProductCode','TSSD',...
                				    'extension','csv',...
                				    'begindateFrom','2016-07-27T00:00:00.000Z',...
                				    'enddateTo','2016-08-01T00:00:00.000Z',...
                				    'dpo_qualityControl',1,...
                				    'dpo_resample','none',...
                				    'dpo_dataGaps',0));


Code Block
languagepy
titleR Example
linenumberstrue
collapsetrue
library("onc")
onc = new("onc",token='YOUR_TOKEN_HERE')

results = onc.orderDataProduct(onc,
                               list(locationCode="BACAX",
                				    deviceCategoryCode="ADCP2MHZ",
                				    dataProductCode="TSSD",
                				    extension="csv",
                				    begindateFrom="2016-07-27T00:00:00.000Z",
                				    enddateTo="2016-08-01T00:00:00.000Z",
                				    dpo_qualityControl=1,
                				    dpo_resample="none",
                				    dpo_dataGaps=0))

 

To create the filters needed to order a data product using the API, you can use Data Search to define the data product request interactively,  using the following steps

  1. Open data search http://data.oceannetworks.ca/DataSearch
    1. Select 'Instruments by Location' from the 'Sort by' drop-down
    2. Navigate to the location and device category of your data and click 'Next' (or 'Select Data Product')
    3. Enter a 'Date From' and 'Date To'.
    4. Select the data product and options you are interested in.
  2. Capture the locationCode, deviceCategoryCode from the URL at the top of the browser
  3. Capture the dates from the date section of the page and use 'dateFrom' and 'dateTo' (instead of 'begin' and 'end')
  4. Click on the link for the Data Product you are interested in and use the documentation to retrieve the dataProductCode, extension and all data product options you have identified in the appropriate data product options and codes. The data product documentation includes the API data product option codes for every Data Product Option available on the Data Search page.