Versions Compared

Key

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

...

Use Case #1 - Create Hydrophone LTSA (Long Term Spectral Averages)

 


An ONC Data Team member needs to be able to regularly create Long Term Spectral Averages LTSA spectra from for a 1 week's worth hydrophone audio files in wav file format for all of the deployed hydrophone. The software that they use for generating the spectra is in MATLAB, so for ease of use and simplicity, the audio file download must be done in MATLAB as well. 


This example requires the MATLAB Client Library

Code Block
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,...
							      'deploymentBegindateFrom',beginDT,...
							      'deploymentEnddateTo',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,...
                              'begindateFrom',beginDT,...
                 			  'enddateTo',endDT,...
                 			  'dpo_hydrophoneDataDiversionMode','All'},1000,false,true);
	
end

 

...



Expand
titlePython Example

 This example requires the Python Client Library

Code Block
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,
                              'deploymentBegindateFrom':beginDT,
                              'deploymentEnddateTo':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,
                                'begindateFrom':beginDT,
                                'enddateTo':endDT,
                                'dpo_hydrophoneDataDiversionMode':'All'},50)

...

 




Warning

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