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

Compare with Current View Page History

Version 1 Next »

Use Case - Obtain ONC Data

 

A scientific developer who needs to provide near-real-time data to bird behavioural researchers needs to be able to obtain data through the API to be used in their programming languages of choice. The data includes short station weatehr data (wind speed, direction, temperature, etc.), tide heights, wave heights, currents, shore camera data, and chlorophyll.

 

----- below this line to be deleted... -----


This example requires the MATLAB Client Library

o = onc('YOUR_TOKEN_HERE'); %replace YOUR_TOKEN_HERE with your personal token obtained from the 'Web Services API' tab at https://data.oceannetworks.ca/Profile when logged in.

outPath = 'c:\ONC\data';
locationCode = 'NEP'; 					% Northeast Pacific Ocean
deviceCategoryCode = 'HYDROPHONE';		
beginDT = '2017-07-16T00:00:00.000Z';
endDT = '2017-07-22T23:59:59.999Z';
dataProductCode = 'AD';					% Audio data
extension = 'wav';						% Wave File Format

locations = o.getLocations(struct('deviceCategoryCode',deviceCategoryCode,...
							      'locationCode',locationCode,...
							      'dateFrom',beginDT,...
							      'dateTo',endDT,...
							      'includeChildren','true'));

for i=1:numel(locations)
    locationCode = locations(i).locationCode;
	disp(locationCode);
	o.outPath = strcat(outPath,'/',locationCode);
 
	ret = o.orderDataProduct({'locationCode',locationCode,...
                 			  'deviceCategoryCode',deviceCategoryCode,...
                              'dataProductCode',dataProductCode,...
                              'extension',extension,...
                              'dateFrom',beginDT,...
                 			  'dateTo',endDT,...
                 			  'dpo_hydrophoneDataDiversionMode','All'},1000,false,true);
	
end

 

 

 This example requires the Python Client Library

from onc.onc import ONC
onc = ONC('YOUR_TOKEN_HERE')		   # Replace YOUR_TOKEN_HERE with your personal token obtained from the 'Web Services API' tab at https://data.oceannetworks.ca/Profile when logged in.
outPath = 'c:\ONC\data'
locationCode = 'NEP'                   # Northeast Pacific Ocean
deviceCategoryCode = 'HYDROPHONE'     
beginDT = '2017-07-16T00:00:00.000Z'
endDT = '2017-07-22T23:59:59.999Z'
dataProductCode = 'AD'                 # Audio data
extension = 'wav';                     # Wave File Format
 
locations = onc.getLocations({'deviceCategoryCode':deviceCategoryCode,
                              'locationCode':locationCode,
                              'dateFrom':beginDT,
                              'dateTo':endDT,
                              'includeChildren':'true'})
 
for location in locations:
    locationCode = location['locationCode']
    print(locationCode)
    onc.outPath = "{}/{}".format(outPath,locationCode)
    ret = onc.orderDataProduct({'locationCode':locationCode,
                                'deviceCategoryCode':deviceCategoryCode,
                                'dataProductCode':dataProductCode,
                                'extension':extension,
                                'dateFrom':beginDT,
                                'dateTo':endDT,
                                'dpo_hydrophoneDataDiversionMode':'All'},50)

 

 

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

  • No labels