diff --git a/README.md b/README.md index ee6af7a..b8a69a4 100644 --- a/README.md +++ b/README.md @@ -3,13 +3,13 @@ [![View Ocean Networks Canada API Client Library on File Exchange](https://www.mathworks.com/matlabcentral/images/matlab-file-exchange.svg)](https://www.mathworks.com/matlabcentral/fileexchange/74065-ocean-networks-canada-api-client-library) This library facilitates access to scientific data hosted by [Ocean Networks Canada](https://oceannetworks.ca) through the -[Oceans 2.0 API](https://wiki.oceannetworks.ca/display/O2A/Oceans+2.0+API+Home) public web services. +[Oceans 3.0 API](https://wiki.oceannetworks.ca/display/O2A/Oceans+3.0+API+Home) public web services. This repository is synchronized to the [MATLAB ONC API Client Add-On](https://www.mathworks.com/matlabcentral/fileexchange/74065-ocean-networks-canada-api-client-library) which can be installed from the MATLAB Add-on explorer (please search for the "onc" Add-on). ## Documentation -For complete documentation and examples, visit https://wiki.oceannetworks.ca/display/O2A/Client+Libraries +For complete documentation and examples, visit [ONC File Exchange](https://www.mathworks.com/matlabcentral/fileexchange/74065-ocean-networks-canada-api-client-library) ## Maintainers diff --git a/doc/AddOn.png b/doc/AddOn.png new file mode 100644 index 0000000..c6ac1c2 Binary files /dev/null and b/doc/AddOn.png differ diff --git a/doc/ExampleLinks.html b/doc/ExampleLinks.html new file mode 100644 index 0000000..7f13fa9 --- /dev/null +++ b/doc/ExampleLinks.html @@ -0,0 +1,84 @@ + + + + Ocean Networks Canada API Client Library +
+

Example/LiveScript Links

+

Contents

+

These links will only work when you open this page in MATLAB's 'doc' viewer.

+
+ +
+
+ \ No newline at end of file diff --git a/doc/GettingStarted.html b/doc/GettingStarted.html new file mode 100644 index 0000000..4545544 --- /dev/null +++ b/doc/GettingStarted.html @@ -0,0 +1,1260 @@ + + + + Getting Started + +
+

Getting Started

+

Contents

+

To navigate directly to a specific part of the documentation (use the internal links), right-click on the section you're interested and select "Open" or "Open in New Tab".

+
+ +
+

Before using the library

+

You'll need a token to access all the web services.

+
+

How to get a token?

+
    +
  1. Register for an Oceans 3.0 account at https://data.oceannetworks.ca/Registration.
  2. +
  3. Log into your account at https://data.oceannetworks.ca by clicking the Log In link.
  4. +
  5. Click the Profile link (top right corner) to access your account profile.
  6. +
  7. Access the Web Services API tab and click Copy Token.
  8. +
  9. If you forget your token, you can always find it in your Oceans 3.0 account profile.
  10. +
+
+

Then, use the token to create an Onc object like

+ +

For more information about creating an Onc object, see ONC Class

+ +
+

Note

+ +
+ +

General Tutorial - 1. Searching with discovery services

+

Check sections in the left panel for full documentation, source code and examples on each service.

+

To download data from Ocean Networks Canada's database (Oceans 3.0) , you need to specify the type of data you are interested in + and where in particular (i.e. location, from specific instrument (device)) it originates from. + In the Oceans 3.0 API, there are a unique codes that identify every location, device, property, data product type, etc. + You include these codes in a group of filters to retrieve the information you're interested in. + The Oceans 3.0 API Discovery services allow you to explore the hierarchy of ONC's database to obtain the codes required for your filters + to obtain the information/data you are interested in (they work like a "search" function). +

+

The example below uses the getLocations method, which is querying the locations database tables that include "Bullseye" in + their name (i.e. "Clayoquot Slope Bullseye Vent"). It returns a list with all locations that match the search filters provided.

+

Using ONC library

+
% 1. Define your filter parameter
+params = {'locationName', 'Bullseye'};
+% 2. Call methods in the onc library
+onc.getLocations(params)
+
+

Using MATLAB's HTTP library

+
% 1. Define your filter parameter
+params.locationName = 'Bullseye';
+params.token = 'YOUR TOKEN HERE'; % or readToken
+
+% 2. Prepare HTTP request
+request = matlab.net.http.RequestMessage;
+url = 'https://data.oceannetworks.ca/api/locations';
+uri = matlab.net.URI(url);
+uri.Query = matlab.net.QueryParameter(params)
+
+% prepare MATLAB request options
+options = matlab.net.http.HTTPOptions();
+options.ConnectTimeout = 120;
+
+% send request
+response = request.send(uri,options);
+response.Body.Data
+
+
+    ans = struct with fields:
+            deployments: 38
+           locationName: 'Bullseye'
+                  depth: 1.2569e+03
+                   bbox: [1x1 struct]
+            description: ' Bullseye is a location at Clayoquot Slope, where gas hydrates, seafloor cold seeps, and hydrate dynamics are observed.'
+          hasDeviceData: 1
+                    lon: -126.8480
+           locationCode: 'NC89'
+        hasPropertyData: 0
+                    lat: 48.6706
+          dataSearchURL: 'https://data.oceannetworks.ca/DataSearch?location=NC89'
+
+

Each entry of this list contains more meta data information for that location, e.g. the locationName, the geographical coordinates and depth, + a description field and the URL for Oceans 3.0 Data Search tool. The parameter locationCode contains the string "NC89", which is needed for the next steps.

+

1.1 What device categories are available here at the location NC89?

+

Using ONC library

+
% 1. Define your filter parameter
+params = {'locationCode', 'NC89'};
+% 2. Call methods in the onc library
+onc.getDeviceCategories(params)
+ +

Using MATLAB's HTTP library

+
% 1. Define your filter parameter
+params.locationCode = 'NC89';
+params.token = 'YOUR TOKEN HERE'; % or readToken
+    
+% 2. Prepare HTTP request
+request = matlab.net.http.RequestMessage;
+url = 'https://data.oceannetworks.ca/api/deviceCategories';
+uri = matlab.net.URI(url);
+uri.Query = matlab.net.QueryParameter(params)
+    
+% prepare MATLAB request options
+options = matlab.net.http.HTTPOptions();
+options.ConnectTimeout = 120;
+    
+% send request
+response = request.send(uri,options);
+response.Body.Data
+
+
ans = 13×1 struct 
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Fields + + cvTerm + + description + + deviceCategoryCode + + deviceCategoryName + + hasDeviceData + + longDescription +
+ 1 + + 1×1 struct + + 'Acoustic Doppler Current Profiler 55 kHz ' + + 'ADCP55KHZ' + + 'Acoustic Doppler Current Profiler 55 kHz' + + 1 + + ' Acoustic Doppler Current Profilers are hydroacoustic instruments, similar to sonars. ADCPs measure current speed and direction at multiple predetermined depths simultaneously. ADCPs use the Doppler effect of sound waves that are scattered by particles in seawater over a depth range.' +
+ 2 + + 1×1 struct + + 'Acoustic Doppler Current Profiler 75 kHz ' + + 'ADCP75KHZ' + + 'Acoustic Doppler Current Profiler 75 kHz' + + 1 + ' Acoustic Doppler Current Profilers (ADCP) are hydroacoustic instruments, similar to sonars. ADCPs measure current speed and direction at multiple predetermined depths simultaneously. ADCPs use the Doppler effect of sound waves that are scattered by particles in seawater over a depth range.'
31×1 struct'Broadband Seismometer''BBS''Broadband Seismometer'1' Broadband Seismometers measure seismic waves over a broad frequency range depending on the device (e.g. 0.00278 Hz - 250 Hz). A broadband seismometer facilitates measurement of seismic events in the widest frequency band possible.'
41×1 struct'Bottom Pressure Recorder''BPR''Bottom Pressure Recorder'1' Bottom Pressure Recorders (BPR) are instruments that can detect small changes in pressure on the seafloor. '
51×1 struct'Controlled Source Electromagnetic Method''CSEM''Controlled Source Electromagnetic Method'1' The Controlled Source Electromagnetic Method (CSEM) measures sub-surface resistivity structure through the measurement of the electromegnetic fields resulting from stimulation by a towed source.'
61×1 struct'Conductivity Temperature (and Depth Sensor)''CTD''Conductivity Temperature Depth'1' Conductivity Temperature Depth (CTD) is an instrument package that contains sensors for measuring the conductivity, temperature, and pressure of seawater. Salinity, sound velocity, depth and density are variables that can be derived from sensor measurements. CTDs can carry additional instruments and sensors such as oxygen sensors, turbidity sensors and fluorometers.'
71×1 struct'Current Meter''CURRENTMETER''Current Meter'1' Acoustic Current Meters (ACM) measure current speed and direction, using the Doppler Effect. Aquadopp current meters have a sensor head that contains 3 acoustic transducers, a tilt sensor, a temperature sensor and a pressure sensor. The instrument transmits a short pulse of sound, and then listens to its echo to measure the change in pitch or frequency. The change in pitch can determine the velocity of the current.'
81×1 struct'Gravimeter''GRAVIMETER''Gravimeter'1' Gravimeters (or gravity meters) measure the gravity field of the Earth with such a resolution that they can detect very small changes in the underlying or surrounding structures.'
91×1 struct'Junction Box''JB''Junction Box'1' Junction Boxes supply power and communications to deployed instruments. Junction boxes have a number of serial and ethernet ports, including 400V ethernet ports that enable connections to other junction boxes and high-voltage instruments. Junction boxes can convert high voltages to lower voltages (15V, 24V or 48V) required by many instruments.'
101×1 struct'Oxygen Sensor''OXYSENSOR''Oxygen Sensor'1' Oxygen sensors measure dissolved oxygen concentration in seawater.'
111×1 struct'Pan Tilt Lights''PTL''Pan Tilt Lights'1' Pan Tilt Lights are used for cameras and allow remotely controlled operations such as changing the camera's field of view and illuminating the subject matter.'
121×1 struct'Tiltmeter''TILTMTR''Tiltmeter'1' A tiltmeter is a sensitive inclinometer designed to measure very small changes from the vertical level, either on the ground or in structures.'
131×1 struct'Video Camera''VIDEOCAM''Video Camera'1' Video cameras record video of characteristics of the surrounding environments and can be deployed on fixed and mobile platforms.'
+
+

1.2 What properties are available for the device category CTD at this location NC89?

+

Using ONC library

+
% 1. Define your filter parameter
+params = {'locationCode', 'NC89', ...
+          'deviceCategoryCode', 'CTD'};
+% 2. Call methods in the onc library
+onc.getProperties(params)
+
+ +

Using MATLAB's HTTP library

+
% 1. Define your filter parameter
+params.locationCode = 'NC89';
+params.deviceCategoryCode = 'CTD';
+params.token = 'YOUR TOKEN HERE'; % or readToken
+    
+% 2. Prepare HTTP request
+request = matlab.net.http.RequestMessage;
+url = 'https://data.oceannetworks.ca/api/properties';
+uri = matlab.net.URI(url);
+uri.Query = matlab.net.QueryParameter(params)
+    
+% prepare MATLAB request options
+options = matlab.net.http.HTTPOptions();
+options.ConnectTimeout = 120;
+    
+% send request
+response = request.send(uri,options);
+response.Body.Data
+
+
ans = 8×1 struct 
+ + + + + + + + + + + + + + + + + + + + + + + + + +
FieldscvTermdescriptionhasDeviceDatahasPropertyDatapropertyCodepropertyNameuom
11×1 struct'Conductivity: siemens per metre'11'conductivity''Conductivity''S/m'
21×1 struct'Density'11'density''Density''kg/m3'
31×1 struct'Pressure'11'pressure''Pressure''decibar'
41×1 struct'Salinity'11'salinity''Salinity''psu'
51×1 struct'Temperature: sea water'11'seawatertemperature''Sea Water Temperature''C'
61×1 struct'Sigma-t'11'sigmat''Sigma-t''kg/m3'
71×1 struct'Sigma-theta'11'sigmatheta''Sigma-theta''kg/m3'
81×1 struct'Sound Speed: sound velocity sensor'11'soundspeed''Sound Speed''m/s'
+
+

1.3 What data product types are available for the device category CTD at this location NC89?

+

Using ONC library

+
% 1. Define your filter parameter
+params = {'locationCode', 'NC89', ...
+          'deviceCategoryCode', 'CTD'};
+% 2. Call methods in the onc library
+onc.getDataProducts(params)
+
+

Using MATLAB's HTTP library

+
% 1. Define your filter parameter
+params.locationCode = 'NC89';
+params.deviceCategoryCode = 'CTD';
+params.token = 'YOUR TOKEN HERE'; % or readToken
+    
+% 2. Prepare HTTP request
+request = matlab.net.http.RequestMessage;
+url = 'https://data.oceannetworks.ca/api/dataProducts';
+uri = matlab.net.URI(url);
+uri.Query = matlab.net.QueryParameter(params)
+    
+% prepare MATLAB request options
+options = matlab.net.http.HTTPOptions();
+options.ConnectTimeout = 120;
+    
+% send request
+response = request.send(uri,options);
+response.Body.Data
+
+
ans = 9×1 struct 
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
FieldsdataProductCodedataProductNamedataProductOptionsextensionhasDeviceDatahasPropertyDatahelpDocument
1'LF''Log File'3×1 struct'txt'10'https://wiki.oceannetworks.ca/display/DP/4'
2'MSQAQCR''Manual Scalar QAQC Results'2×1 struct'qaqc'10'https://wiki.oceannetworks.ca/display/DP/106'
3'SBCTDRF''Sea-Bird CTD Raw Files'[]'hex'10'https://wiki.oceannetworks.ca/display/DP/78'
4'TSSD''Time Series Scalar Data'8×1 struct'json'10'https://wiki.oceannetworks.ca/display/DP/1'
5'TSSD''Time Series Scalar Data'5×1 struct'csv'10'https://wiki.oceannetworks.ca/display/DP/1'
6'TSSD''Time Series Scalar Data'5×1 struct'mat'10'https://wiki.oceannetworks.ca/display/DP/1'
7'TSSD''Time Series Scalar Data'5×1 struct'txt'10'https://wiki.oceannetworks.ca/display/DP/1'
8'TSSP''Time Series Scalar Plot'5×1 struct'pdf'10'https://wiki.oceannetworks.ca/display/DP/2'
9'TSSP''Time Series Scalar Plot'4×1 struct'png'10'https://wiki.oceannetworks.ca/display/DP/2'
+
+ + +

General Tutorial - 2. Downloading data

+

Check sections in the left panel for full documentation, source code and examples on each service.

+

Once you determine the exact filters that identify the information you are interested in, there are different methods available to download data.

+
+
    +
  1. Near real-time scalar data sensor readings for a given timeframe
  2. +
  3. Near real-time raw data for a given timeframe
  4. +
  5. Download archived files containing raw data or processed data
  6. +
  7. Download data products that are also available via Oceans 3.0 Data Search Tool
  8. +
+
+

2.1 Near real-time scalar data download

+

In this example we want to download one minute of Pressure sensor data from a CTD at location "Bullseye" (locationCode: NC89)

+

Using ONC library

+
% 1. Define your filter parameter
+params = {'locationCode', 'NC89', ...
+        'deviceCategoryCode', 'CTD', ...
+        'dateFrom', '2017-01-20T00:00:00.000Z', ...
+        'propertyCode', 'pressure', ...
+        'dateTo', '2017-01-20T00:01:00.000Z', ...
+         };
+
+% 2. Call methods in the onc library
+result = onc.getDirectByLocation(params);
+
+

Using MATLAB's HTTP library

+
% 1. Define your filter parameter
+params.locationCode = 'NC89';
+params.deviceCategoryCode = 'CTD';
+params.dateFrom = '2017-01-20T00:00:00.000Z';
+params.propertyCode = 'pressure';
+params.dateTo = '2017-01-20T00:01:00.000Z';
+params.token = 'YOUR TOKEN HERE'; % or readToken
+    
+% 2. Prepare HTTP request
+request = matlab.net.http.RequestMessage;
+url = 'https://data.oceannetworks.ca/api/scalardata/location';
+uri = matlab.net.URI(url);
+uri.Query = matlab.net.QueryParameter(params)
+    
+% prepare MATLAB request options
+options = matlab.net.http.HTTPOptions();
+options.ConnectTimeout = 120;
+
+% send request
+result = request.send(uri,options);
+
+
% 3. Return the field names of the query to get a sense what is contained in your returned message
+fieldnames(result)
+
ans = 6×1 cell
'citations'
'messages'
'next'
'parameters'
'queryUrl'
'sensorData'
+
% 4. Read the data from parameter "sensorData" - this is the data from your requested "Pressure" sensor
+struct2table(result.sensorData(1).data)
+
+
ans = 240×3 table 
+ + + + + + + + + + + + + + + + + + + + + + + +
 qaqcFlagssampleTimesvalues
11'2017-01-20T00:00:00.025Z'1.2707e+03
21'2017-01-20T00:00:00.275Z'1.2707e+03
31'2017-01-20T00:00:00.525Z'1.2707e+03
41'2017-01-20T00:00:00.775Z'1.2707e+03
51'2017-01-20T00:00:01.025Z'1.2707e+03
61'2017-01-20T00:00:01.275Z'1.2707e+03
71'2017-01-20T00:00:01.525Z'1.2707e+03
81'2017-01-20T00:00:01.775Z'1.2707e+03
91'2017-01-20T00:00:02.025Z'1.2707e+03
101'2017-01-20T00:00:24.775Z'1.2707e+03
+

2.2 Near real-time raw data readings

+

In this example we want to download one minute of raw data from a CTD at location "Bullseye" (locationCode: NC89)

+

Using ONC library

+
% 1. Define your filter parameter
+params = {'locationCode', 'NC89', ...
+    'deviceCategoryCode', 'CTD', ...
+    'dateFrom', '2020-06-20T00:00:00.000Z', ...
+    'dateTo', '2020-06-20T00:01:00.000Z', ...
+   };
+% 2. Call methods in the onc library
+result = onc.getDirectRawByLocation(params);
+
+ +

Using MATLAB's HTTP library

+
% 1. Define your filter parameter
+params.locationCode = 'NC89';
+params.deviceCategoryCode = 'CTD';
+params.dateFrom = '2020-06-20T00:00:00.000Z';
+params.dateTo = '2020-06-20T00:01:00.000Z';
+params.token = 'YOUR TOKEN HERE'; % or readToken
+    
+% 2. Prepare HTTP request
+request = matlab.net.http.RequestMessage;
+url = 'http://data.oceannetworks.ca/api/rawdata/location';
+uri = matlab.net.URI(url);
+uri.Query = matlab.net.QueryParameter(params)
+    
+% prepare MATLAB request options
+options = matlab.net.http.HTTPOptions();
+options.ConnectTimeout = 120;
+    
+% send request
+result = request.send(uri,options);
+
+
% 3. Return the dictionary keys (fields) of the query to get a sense what is contained in your returned message
+fieldnames(result)
+
ans = 7×1 cell
'citations'
'data'
'messages'
'metadata'
'next'
'outputFormat'
'queryUrl'
+
% 4. Read the data as a table
+struct2table(result.data)
+
+
ans = 60×3 table 
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 lineTypesreadingstimes
1' ''<?xml version="1.0"?><datapacket><hdr><mfg>Sea-Bird</mfg><model>19plus</model><sn>01907035</sn></hdr><data><t1>  2.8523</t1><c1> 3.16666</c1><p1>1269.229</p1><ser1><type>sbe63</type><oxph>38.099</oxph><oxtv>1.089869</oxtv></ser1><sal> 34.4819</sal><sv>1482.011</sv></data></datapacket>''2020-06-20T00:00:00.843Z'
2' ''<?xml version="1.0"?><datapacket><hdr><mfg>Sea-Bird</mfg><model>19plus</model><sn>01907035</sn></hdr><data><t1>  2.8523</t1><c1> 3.16666</c1><p1>1269.223</p1><ser1><type>sbe63</type><oxph>38.096</oxph><oxtv>1.089873</oxtv></ser1><sal> 34.4821</sal><sv>1482.011</sv></data></datapacket>''2020-06-20T00:00:01.842Z'
3' ''<?xml version="1.0"?><datapacket><hdr><mfg>Sea-Bird</mfg><model>19plus</model><sn>01907035</sn></hdr><data><t1>  2.8523</t1><c1> 3.16667</c1><p1>1269.217</p1><ser1><type>sbe63</type><oxph>38.096</oxph><oxtv>1.089870</oxtv></ser1><sal> 34.4820</sal><sv>1482.011</sv></data></datapacket>''2020-06-20T00:00:02.840Z'
4' ''<?xml version="1.0"?><datapacket><hdr><mfg>Sea-Bird</mfg><model>19plus</model><sn>01907035</sn></hdr><data><t1>  2.8524</t1><c1> 3.16667</c1><p1>1269.223</p1><ser1><type>sbe63</type><oxph>38.096</oxph><oxtv>1.089870</oxtv></ser1><sal> 34.4820</sal><sv>1482.011</sv></data></datapacket>''2020-06-20T00:00:03.838Z'
5' ''<?xml version="1.0"?><datapacket><hdr><mfg>Sea-Bird</mfg><model>19plus</model><sn>01907035</sn></hdr><data><t1>  2.8525</t1><c1> 3.16669</c1><p1>1269.216</p1><ser1><type>sbe63</type><oxph>38.096</oxph><oxtv>1.089874</oxtv></ser1><sal> 34.4822</sal><sv>1482.012</sv></data></datapacket>''2020-06-20T00:00:04.837Z'
6' ''<?xml version="1.0"?><datapacket><hdr><mfg>Sea-Bird</mfg><model>19plus</model><sn>01907035</sn></hdr><data><t1>  2.8526</t1><c1> 3.16670</c1><p1>1269.225</p1><ser1><type>sbe63</type><oxph>38.097</oxph><oxtv>1.089869</oxtv></ser1><sal> 34.4822</sal><sv>1482.013</sv></data></datapacket>''2020-06-20T00:00:05.837Z'
.........
+
+ +

2.2.1. Downloading more data

+
+

Pagination of response due to too many data rows

+

If the row of the data is above 100,000, not all the data will be returned. The rest of the data can be queried based on the next key in the response.

+
    +
  1. If you use onc library.

    getDirectRawByLocation supports a boolean allPages parameter. When set to True, it will try to retrieve all the pages.

  2. +
  3. If you use MATLAB's HTTP library.

    You have to manually query the next pages until the next key in the response json is None, and concatenate all the data together.

  4. +
+
+

Using ONC library

+
% 1. Define your filter parameter with a longer date range (2 days of data)
+paramsLongerRange = {'locationCode', 'NC89', ...
+    'deviceCategoryCode', 'CTD', ...
+    'dateFrom', '2020-06-20T00:00:00.000Z', ...
+    'dateTo', '2020-06-22T00:00:00.000Z', ...
+   };
+% 2. Call methods in the onc library
+result = onc.getDirectRawByLocation(paramsLongerRange, 'allPages', true)
+struct2table(result.data)
+
+
+    
Data size is greater than the row limit and will be downloaded in multiple pages. + Estimated approx. 1 pages + Estimated approx. 5.79 seconds to complete + + (100000 samples) Downloading page 2... + (172796 samples) Completed in 2.25 seconds.
+
result = struct with fields:
citations: [1×1 struct] + data: [1×1 struct] + messages: [] + metadata: [1×1 struct] + next: [] + outputFormat: 'array' + queryUrl: 'https://data.oceannetworks.ca/api/rawdata?locationCode=NC89&deviceCategoryCode=CTD&dateFrom=2020-06-20T00:00:00.000Z&dateTo=2020-06-22T00:00:00.000Z&method=getByLocation&token=YOUR_TOKEN' +
+
+
ans = 172796×3 table 
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 lineTypesreadingstimes
1' ''<?xml version="1.0"?><datapacket><hdr><mfg>Sea-Bird</mfg><model>19plus</model><sn>01907035</sn></hdr><data><t1>  2.8523</t1><c1> 3.16666</c1><p1>1269.229</p1><ser1><type>sbe63</type><oxph>38.099</oxph><oxtv>1.089869</oxtv></ser1><sal> 34.4819</sal><sv>1482.011</sv></data></datapacket>''2020-06-20T00:00:00.843Z'
2' ''<?xml version="1.0"?><datapacket><hdr><mfg>Sea-Bird</mfg><model>19plus</model><sn>01907035</sn></hdr><data><t1>  2.8523</t1><c1> 3.16666</c1><p1>1269.223</p1><ser1><type>sbe63</type><oxph>38.096</oxph><oxtv>1.089873</oxtv></ser1><sal> 34.4821</sal><sv>1482.011</sv></data></datapacket>''2020-06-20T00:00:01.842Z'
3' ''<?xml version="1.0"?><datapacket><hdr><mfg>Sea-Bird</mfg><model>19plus</model><sn>01907035</sn></hdr><data><t1>  2.8523</t1><c1> 3.16667</c1><p1>1269.217</p1><ser1><type>sbe63</type><oxph>38.096</oxph><oxtv>1.089870</oxtv></ser1><sal> 34.4820</sal><sv>1482.011</sv></data></datapacket>''2020-06-20T00:00:02.840Z'
4' ''<?xml version="1.0"?><datapacket><hdr><mfg>Sea-Bird</mfg><model>19plus</model><sn>01907035</sn></hdr><data><t1>  2.8524</t1><c1> 3.16667</c1><p1>1269.223</p1><ser1><type>sbe63</type><oxph>38.096</oxph><oxtv>1.089870</oxtv></ser1><sal> 34.4820</sal><sv>1482.011</sv></data></datapacket>''2020-06-20T00:00:03.838Z'
5' ''<?xml version="1.0"?><datapacket><hdr><mfg>Sea-Bird</mfg><model>19plus</model><sn>01907035</sn></hdr><data><t1>  2.8525</t1><c1> 3.16669</c1><p1>1269.216</p1><ser1><type>sbe63</type><oxph>38.096</oxph><oxtv>1.089874</oxtv></ser1><sal> 34.4822</sal><sv>1482.012</sv></data></datapacket>''2020-06-20T00:00:04.837Z'
6' ''<?xml version="1.0"?><datapacket><hdr><mfg>Sea-Bird</mfg><model>19plus</model><sn>01907035</sn></hdr><data><t1>  2.8526</t1><c1> 3.16670</c1><p1>1269.225</p1><ser1><type>sbe63</type><oxph>38.097</oxph><oxtv>1.089869</oxtv></ser1><sal> 34.4822</sal><sv>1482.013</sv></data></datapacket>''2020-06-20T00:00:05.837Z'
7' ''<?xml version="1.0"?><datapacket><hdr><mfg>Sea-Bird</mfg><model>19plus</model><sn>01907035</sn></hdr><data><t1>  2.8528</t1><c1> 3.16670</c1><p1>1269.229</p1><ser1><type>sbe63</type><oxph>38.098</oxph><oxtv>1.089862</oxtv></ser1><sal> 34.4820</sal><sv>1482.013</sv></data></datapacket>''2020-06-20T00:00:06.838Z'
8' ''<?xml version="1.0"?><datapacket><hdr><mfg>Sea-Bird</mfg><model>19plus</model><sn>01907035</sn></hdr><data><t1>  2.8529</t1><c1> 3.16671</c1><p1>1269.226</p1><ser1><type>sbe63</type><oxph>38.098</oxph><oxtv>1.089857</oxtv></ser1><sal> 34.4820</sal><sv>1482.014</sv></data></datapacket>''2020-06-20T00:00:07.842Z'
9' ''<?xml version="1.0"?><datapacket><hdr><mfg>Sea-Bird</mfg><model>19plus</model><sn>01907035</sn></hdr><data><t1>  2.8530</t1><c1> 3.16672</c1><p1>1269.224</p1><ser1><type>sbe63</type><oxph>38.099</oxph><oxtv>1.089849</oxtv></ser1><sal> 34.4819</sal><sv>1482.014</sv></data></datapacket>''2020-06-20T00:00:08.837Z'
+
+

Using MATLAB's HTTP library

+
% 1. Define your filter parameter
+paramsLongerRange.locationCode = 'NC89';
+paramsLongerRange.deviceCategoryCode = 'CTD';
+paramsLongerRange.dateFrom = '2020-06-20T00:00:00.000Z';
+paramsLongerRange.dateTo = '2020-06-22T00:00:00.000Z';
+paramsLongerRange.token = 'YOUR TOKEN HERE'; % or readToken
+    
+% 2. Prepare HTTP request (the url is still the same)
+request = matlab.net.http.RequestMessage;
+url = 'http://data.oceannetworks.ca/api/rawdata/location';
+uri = matlab.net.URI(url);
+uri.Query = matlab.net.QueryParameter(paramsLongerRange);
+    
+% prepare MATLAB request options
+options = matlab.net.http.HTTPOptions();
+options.ConnectTimeout = 120;
+    
+% send request
+result = request.send(uri,options);
+
+ +
% 4. Read the data as a table
+struct2table(result.Body.Data.data) 
+
+
ans = 100000×3 table 
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 lineTypesreadingstimes
1' ''<?xml version="1.0"?><datapacket><hdr><mfg>Sea-Bird</mfg><model>19plus</model><sn>01907035</sn></hdr><data><t1>  2.8523</t1><c1> 3.16666</c1><p1>1269.229</p1><ser1><type>sbe63</type><oxph>38.099</oxph><oxtv>1.089869</oxtv></ser1><sal> 34.4819</sal><sv>1482.011</sv></data></datapacket>''2020-06-20T00:00:00.843Z'
2' ''<?xml version="1.0"?><datapacket><hdr><mfg>Sea-Bird</mfg><model>19plus</model><sn>01907035</sn></hdr><data><t1>  2.8523</t1><c1> 3.16666</c1><p1>1269.223</p1><ser1><type>sbe63</type><oxph>38.096</oxph><oxtv>1.089873</oxtv></ser1><sal> 34.4821</sal><sv>1482.011</sv></data></datapacket>''2020-06-20T00:00:01.842Z'
3' ''<?xml version="1.0"?><datapacket><hdr><mfg>Sea-Bird</mfg><model>19plus</model><sn>01907035</sn></hdr><data><t1>  2.8523</t1><c1> 3.16667</c1><p1>1269.217</p1><ser1><type>sbe63</type><oxph>38.096</oxph><oxtv>1.089870</oxtv></ser1><sal> 34.4820</sal><sv>1482.011</sv></data></datapacket>''2020-06-20T00:00:02.840Z'
4' ''<?xml version="1.0"?><datapacket><hdr><mfg>Sea-Bird</mfg><model>19plus</model><sn>01907035</sn></hdr><data><t1>  2.8524</t1><c1> 3.16667</c1><p1>1269.223</p1><ser1><type>sbe63</type><oxph>38.096</oxph><oxtv>1.089870</oxtv></ser1><sal> 34.4820</sal><sv>1482.011</sv></data></datapacket>''2020-06-20T00:00:03.838Z'
5' ''<?xml version="1.0"?><datapacket><hdr><mfg>Sea-Bird</mfg><model>19plus</model><sn>01907035</sn></hdr><data><t1>  2.8525</t1><c1> 3.16669</c1><p1>1269.216</p1><ser1><type>sbe63</type><oxph>38.096</oxph><oxtv>1.089874</oxtv></ser1><sal> 34.4822</sal><sv>1482.012</sv></data></datapacket>''2020-06-20T00:00:04.837Z'
6' ''<?xml version="1.0"?><datapacket><hdr><mfg>Sea-Bird</mfg><model>19plus</model><sn>01907035</sn></hdr><data><t1>  2.8526</t1><c1> 3.16670</c1><p1>1269.225</p1><ser1><type>sbe63</type><oxph>38.097</oxph><oxtv>1.089869</oxtv></ser1><sal> 34.4822</sal><sv>1482.013</sv></data></datapacket>''2020-06-20T00:00:05.837Z'
7' ''<?xml version="1.0"?><datapacket><hdr><mfg>Sea-Bird</mfg><model>19plus</model><sn>01907035</sn></hdr><data><t1>  2.8528</t1><c1> 3.16670</c1><p1>1269.229</p1><ser1><type>sbe63</type><oxph>38.098</oxph><oxtv>1.089862</oxtv></ser1><sal> 34.4820</sal><sv>1482.013</sv></data></datapacket>''2020-06-20T00:00:06.838Z'
8' ''<?xml version="1.0"?><datapacket><hdr><mfg>Sea-Bird</mfg><model>19plus</model><sn>01907035</sn></hdr><data><t1>  2.8529</t1><c1> 3.16671</c1><p1>1269.226</p1><ser1><type>sbe63</type><oxph>38.098</oxph><oxtv>1.089857</oxtv></ser1><sal> 34.4820</sal><sv>1482.014</sv></data></datapacket>''2020-06-20T00:00:07.842Z'
9' ''<?xml version="1.0"?><datapacket><hdr><mfg>Sea-Bird</mfg><model>19plus</model><sn>01907035</sn></hdr><data><t1>  2.8530</t1><c1> 3.16672</c1><p1>1269.224</p1><ser1><type>sbe63</type><oxph>38.099</oxph><oxtv>1.089849</oxtv></ser1><sal> 34.4819</sal><sv>1482.014</sv></data></datapacket>''2020-06-20T00:00:08.837Z'
+
+

Now check the parameter field "next"

+
+result.Body.Data.next
+result.Body.Data.next.parameters
+
+
ans = struct with fields:
parameters: [1×1 struct] + url: 'https://data.oceannetworks.ca/api/rawdata/location?dateTo=2020-06-22T00%3A00%3A00.000Z&locationCode=NC89&deviceCategoryCode=CTD&dateFrom=2020-06-21T03%3A46%3A42.044Z&token=YOUR_TOKEN' +
+ans = struct with fields:
dateTo: '2020-06-22T00:00:00.000Z' + locationCode: 'NC89' + deviceCategoryCode: 'CTD' + dateFrom: '2020-06-21T03:46:42.044Z' + token: 'YOUR_TOKEN' +
+
+

Update the dateFrom parameter to get the next page

+
+paramsLongerRange.dateFrom = result.Body.Data.next.parameters.dateFrom;
+uri.Query = matlab.net.QueryParameter(paramsLongerRange);
+result = request.send(uri,options);
+struct2table(result.Body.Data.data)
+
+
ans = 72796×3 table 
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 lineTypesreadingstimes
1' ''<?xml version="1.0"?><datapacket><hdr><mfg>Sea-Bird</mfg><model>19plus</model><sn>01907035</sn></hdr><data><t1>  2.8635</t1><c1> 3.16756</c1><p1>1269.622</p1><ser1><type>sbe63</type><oxph>38.117</oxph><oxtv>1.089511</oxtv></ser1><sal> 34.4807</sal><sv>1482.064</sv></data></datapacket>''2020-06-21T03:46:43.045Z'
2' ''<?xml version="1.0"?><datapacket><hdr><mfg>Sea-Bird</mfg><model>19plus</model><sn>01907035</sn></hdr><data><t1>  2.8636</t1><c1> 3.16755</c1><p1>1269.626</p1><ser1><type>sbe63</type><oxph>38.124</oxph><oxtv>1.089509</oxtv></ser1><sal> 34.4806</sal><sv>1482.064</sv></data></datapacket>''2020-06-21T03:46:44.044Z'
3' ''<?xml version="1.0"?><datapacket><hdr><mfg>Sea-Bird</mfg><model>19plus</model><sn>01907035</sn></hdr><data><t1>  2.8637</t1><c1> 3.16757</c1><p1>1269.629</p1><ser1><type>sbe63</type><oxph>38.125</oxph><oxtv>1.089508</oxtv></ser1><sal> 34.4807</sal><sv>1482.065</sv></data></datapacket>''2020-06-21T03:46:45.043Z'
4' ''<?xml version="1.0"?><datapacket><hdr><mfg>Sea-Bird</mfg><model>19plus</model><sn>01907035</sn></hdr><data><t1>  2.8637</t1><c1> 3.16758</c1><p1>1269.626</p1><ser1><type>sbe63</type><oxph>38.123</oxph><oxtv>1.089506</oxtv></ser1><sal> 34.4808</sal><sv>1482.065</sv></data></datapacket>''2020-06-21T03:46:46.043Z'
5' ''<?xml version="1.0"?><datapacket><hdr><mfg>Sea-Bird</mfg><model>19plus</model><sn>01907035</sn></hdr><data><t1>  2.8637</t1><c1> 3.16758</c1><p1>1269.629</p1><ser1><type>sbe63</type><oxph>38.122</oxph><oxtv>1.089506</oxtv></ser1><sal> 34.4808</sal><sv>1482.065</sv></data></datapacket>''2020-06-21T03:46:47.047Z'
6' ''<?xml version="1.0"?><datapacket><hdr><mfg>Sea-Bird</mfg><model>19plus</model><sn>01907035</sn></hdr><data><t1>  2.8637</t1><c1> 3.16758</c1><p1>1269.620</p1><ser1><type>sbe63</type><oxph>38.123</oxph><oxtv>1.089511</oxtv></ser1><sal> 34.4809</sal><sv>1482.065</sv></data></datapacket>''2020-06-21T03:46:48.048Z'
7' ''<?xml version="1.0"?><datapacket><hdr><mfg>Sea-Bird</mfg><model>19plus</model><sn>01907035</sn></hdr><data><t1>  2.8637</t1><c1> 3.16757</c1><p1>1269.624</p1><ser1><type>sbe63</type><oxph>38.123</oxph><oxtv>1.089504</oxtv></ser1><sal> 34.4807</sal><sv>1482.065</sv></data></datapacket>''2020-06-21T03:46:49.044Z'
8' ''<?xml version="1.0"?><datapacket><hdr><mfg>Sea-Bird</mfg><model>19plus</model><sn>01907035</sn></hdr><data><t1>  2.8637</t1><c1> 3.16758</c1><p1>1269.630</p1><ser1><type>sbe63</type><oxph>38.121</oxph><oxtv>1.089502</oxtv></ser1><sal> 34.4807</sal><sv>1482.065</sv></data></datapacket>''2020-06-21T03:46:50.058Z'
9' ''<?xml version="1.0"?><datapacket><hdr><mfg>Sea-Bird</mfg><model>19plus</model><sn>01907035</sn></hdr><data><t1>  2.8637</t1><c1> 3.16756</c1><p1>1269.632</p1><ser1><type>sbe63</type><oxph>38.120</oxph><oxtv>1.089501</oxtv></ser1><sal> 34.4806</sal><sv>1482.065</sv></data></datapacket>''2020-06-21T03:46:51.042Z'
+
+

Now check the parameter field "next" again

+
+result.Body.Data.next
+
+
ans =
+
+    []
+
+

2.3. Downloading archived files

+

A faster way to download data products and processed data files that are available in Oceans 3.0 (if it suits your needs) is to leverage how ONC scripts +auto-generate and archive data products of different types at set time intervals. You can directly download these data product files from our files archive, as long as you know their unique filename.

+

In the following example, we get the list of archived files available for a camera (deviceCategoryCode: VIDEOCAM) at Ridley Island (locationCode: RISS) for 5-minute timerange.

+

Using ONC library

+
% 1. Define your filter parameter
+params = {'locationCode', 'RISS', ...
+    'deviceCategoryCode', 'VIDEOCAM', ...
+    'dateFrom', '2016-12-01T00:00:00.000Z', ...
+    'dateTo', '2016-12-01T00:05:00.000Z', ...
+    };
+% 2. Call methods in the onc library
+result = onc.getListByLocation(params);
+result.files
+
+
ans = 4×1 cell
+
'AXISQ6044PTZACCC8E334C53_20161201T000000.000Z.mp4'
'AXISQ6044PTZACCC8E334C53_20161201T000000.000Z.an'
'AXISQ6044PTZACCC8E334C53_20161201T000000.000Z-VideoQAQCResults.an'
'AXISQ6044PTZACCC8E334C53_20161201T000001.000Z.jpg'
+
+

Using MATLAB's HTTP library

+
% 1. Define your filter parameter
+params = struct();
+params.locationCode = 'RISS';
+params.deviceCategoryCode = 'VIDEOCAM';
+params.dateFrom = '2016-12-01T00:00:00.000Z';
+params.dateTo = '2016-12-01T00:05:00.000Z';
+params.token = 'YOUR TOKEN HERE'; % or readToken
+        
+% 2. Prepare HTTP request (the url is still the same)
+request = matlab.net.http.RequestMessage;
+url = 'https://data.oceannetworks.ca/api/archivefile/location';
+uri = matlab.net.URI(url);
+uri.Query = matlab.net.QueryParameter(params);
+        
+% 3. prepare MATLAB request options
+options = matlab.net.http.HTTPOptions();
+options.ConnectTimeout = 120;
+        
+% 4. send request
+result = request.send(uri,options);
+result.Body.Data.files
+
+
ans = 4×1 cell
'AXISQ6044PTZACCC8E334C53_20161201T000000.000Z.mp4'
'AXISQ6044PTZACCC8E334C53_20161201T000000.000Z.an'
'AXISQ6044PTZACCC8E334C53_20161201T000000.000Z-VideoQAQCResults.an'
'AXISQ6044PTZACCC8E334C53_20161201T000001.000Z.jpg'
+
+

Once we have the file names, you can use the method "getFile()" to download individual files:

+

Using ONC library

+
% 1. Call methods in the onc library with the filename. The file is downloaded in the output folder.
+onc.getFile('AXISQ6044PTZACCC8E334C53_20161201T000001.000Z.jpg', 'overwrite', true)
+
+
Downloading file "AXISQ6044PTZACCC8E334C53_20161201T000001.000Z.jpg"... + [==================================================] 100% + File was downloaded to "AXISQ6044PTZACCC8E334C53_20161201T000001.000Z.jpg"
+ans = struct with fields:
url: 'https://data.oceannetworks.ca/api/archivefiles?method=getFile&filename=AXISQ6044PTZACCC8E334C53_20161201T000001.000Z.jpg&token=YOUR_TOKEN' + status: 'completed' + size: 113511 + downloadTime: 0.8380 + file: "AXISQ6044PTZACCC8E334C53_20161201T000001.000Z.jpg" +
+
+

Using MATLAB's HTTP library

+
% 1. Define your filter parameter with the filename
+params.filename = 'AXISQ6044PTZACCC8E334C53_20161201T000001.000Z.jpg';
+params.token = 'YOUR TOKEN HERE'; % or readToken
+% 2. Define your base url for this query
+url_location = 'https://data.oceannetworks.ca/api/archivefile/download';
+request = matlab.net.http.RequestMessage;
+uri = matlab.net.URI(url_location);
+uri.Query = matlab.net.QueryParameter(params);
+    
+% 3. prepare MATLAB request options
+options = matlab.net.http.HTTPOptions();
+options.ConnectTimeout = 120;
+    
+% 4. send request
+result = request.send(uri,options);
+% 5. Save the file
+% f = fopen(fullPath, 'w','n','ISO-8859-1');
+% if f ~= -1
+%     fwrite(f, char(dataToWrite));
+% end
+
+

2.4 Downloading data products

+

Other than using Oceans 3.0 Data Search, we can request the ONC server to generate a data product. This is done through the data product delivery services methods.

+
+

Hint

+

This service should ONLY be used when the requested files are not already provided using the ArchiveFiles services (see 2.3 above). + The data product delivery services will re-generate files using ONC's web machines and this process can often take very long time to generate these results. + If you request data files for very long-time ranges and large file sizes, ONCs system will sometimes slow down and stall and requires some manual actions.

+

We therefore encourage you to check other services before requesting data through this service. If you are unsure what to use feel free to contact u.

+
+

This process will require three steps before you will be able to see the downloaded data product on your computer:

+
+
    +
  1. Request the data.
  2. +
  3. Run the Request.
  4. +
  5. Download the data.
  6. +
+
+

The following example downloads two PNG files with plots for 30 minutes of data from a CTD (find them in the "output" folder beside this jupyter notebook). + The filter includes codes for location, deviceCategory, and dataProduct, as well as the file extension and a time interval. + They also include a couple of filters to configure this specific data product type (starting with the "dpo_" prefix) which can be obtained from the Data Product Options documentation. You can download more than 120 different types of data products including audio & video.

+

Using ONC library

+

ONCs library contains all three steps (methods) in one call. So this is the preferred library to use over the requests library.

+
% 1. Define your filter parameter
+params = {'locationCode', 'NC89', ...
+    'deviceCategoryCode', 'CTD', ...
+    'dataProductCode', 'TSSP', ...
+    'extension', 'png', ...
+    'dateFrom', '2017-01-19T00:00:00.000Z', ...
+    'dateTo', '2017-01-19T00:30:00.000Z', ...
+    'dpo_qualityControl', '1', ...
+    'dpo_resample', 'none', ...
+    };
+% 2. Call methods in the onc library
+result = onc.orderDataProduct(params)
+
+
Requesting data product... +Request Id: 18690549 +Estimated File Size: 185 kB +Estimated Processing Time: 20 s + +To cancel this data product, visit url: + https://data.oceannetworks.ca/api/dataProductDelivery?method=cancel&token=YOUR_TOKEN&dpRequestId=18690549 + + queued + data product running....... + complete + +Downloading data product files with runId 40531301... + + Search complete, waiting on the file system to synchronize (ClayoquotSlope_Bullseye_ConductivityTemperatureDepth_20170119T000000Z_20170119T003000Z-clean.png).... + Downloaded "ClayoquotSlope_Bullseye_ConductivityTemperatureDepth_20170119T000000Z_20170119T003000Z-clean.png" + + Downloaded "ClayoquotSlope_Bullseye_ConductivityTemperatureDepth_20170119T000000Z_20170119T003000Z-clean_PNG_META.xml" + +Download process finished. + + +Total run time: 0.17 seconds +Total download Time: 0.688 seconds +2 files (124.37 KB) downloaded
+
result = struct with fields:
downloadResults: [1×2 struct] + stats: [1×1 struct] +
+
% display results
+downloadResults1 = result.downloadResults(1)
+downloadResults2 = result.downloadResults(2)
+stats = result.stats
+
+
+
downloadResults1 = struct with fields: +
url: 'https://data.oceannetworks.ca/api/dataProductDelivery?method=download&token=YOUR_TOKEN&dpRunId=40531301&index=1' + status: 'complete' + statusCode: OK + size: 111106 + file: 'ClayoquotSlope_Bullseye_ConductivityTemperatureDepth_20170119T000000Z_20170119T003000Z-clean.png' + index: '1' + downloaded: 1 + requestCount: 6 +fileDownloadTime: 0.3850 +
+
+downloadResults2 = struct with fields:
url: 'https://data.oceannetworks.ca/api/dataProductDelivery?method=download&token=YOUR_TOKEN&dpRunId=40531301&index=meta' + status: 'complete' + statusCode: OK + size: 13264 + file: 'ClayoquotSlope_Bullseye_ConductivityTemperatureDepth_20170119T000000Z_20170119T003000Z-clean_PNG_META.xml' + index: 'meta' + downloaded: 1 + requestCount: 1 +fileDownloadTime: 0.3030 +
+
+
stats = struct with fields: +
+
runTime: 0.1710 + downloadTime: 0.6880 + requestCount: 17 + totalSize: 124370 +
+
+

Using MATLAB's HTTP library

+
% 1. Define your filter parameter with the filename
+params = struct();
+params.locationCode = 'NC89';
+params.deviceCategoryCode = 'CTD';
+params.dataProductCode = 'TSSP';
+params.extension = 'png';
+params.dateFrom = '2017-01-19T00:00:00.000Z';
+params.dateTo = '2017-01-19T00:30:00.000Z';
+params.dpo_qualityControl = '1';
+params.dpo_resample = 'none';
+params.token = readToken; 
+% 2. Define your base url for this query
+url_location = 'https://data.oceannetworks.ca/api/dataProductDelivery/request';
+request = matlab.net.http.RequestMessage;
+uri = matlab.net.URI(url_location);
+uri.Query = matlab.net.QueryParameter(params);
+    
+% 3. prepare MATLAB request options
+options = matlab.net.http.HTTPOptions();
+options.ConnectTimeout = 120;
+    
+% 4. send request
+requestResponse = request.send(uri,options);
+result = requestResponse.Body.Data
+
+
+
result = struct with fields:
citations: [1×1 struct] + disclaimer: 'Software Developers are implementing estimates of processing times and file sizes for data requests. These are extremely rough to begin with, but bear with us. We expect these estimates will gradually improve.' + dpRequestId: 18690550 + estimatedFileSize: '185 kB' +estimatedProcessingTime: '20 s' + messages: [] + queryPids: 25848930 + queryURL: 'https://data.oceannetworks.ca/api/dataProductDelivery/request?locationCode=NC89&deviceCategoryCode=CTD&dataProductCode=TSSP&extension=png&dateFrom=2017-01-19T00:00:00.000Z&dateTo=2017-01-19T00:30:00.000Z&token=YOUR_TOKEN&dpo_resample=none&dpo_resample=none&dpo_qualityControl=1' +
+
+
+%% requests continued
+% Run the request
+% Note: you have to execute this cell multiple times until the return shows the "status": "complete"
+% Note: Depending on your request, you can have more than one file ('fileCount').
+%       You will need to individually download these files by using the index parameter.
+url_run = 'https://data.oceannetworks.ca/api/dataProductDelivery/run';
+
+requestID = requestResponse.Body.Data.dpRequestId;
+params_run = struct();
+params_run.dpRequestId = requestID;
+params_run.token = readToken; 
+ 
+request = matlab.net.http.RequestMessage;
+uri = matlab.net.URI(url_run);
+uri.Query = matlab.net.QueryParameter(params_run);
+runResponse = request.send(uri,options);
+result = runResponse.Body.Data
+
+
result = struct with fields:
dpRunId: 40531302 + fileCount: 0 + status: 'queued' +
+
+
%% requests continued
+% Find the RunID for the next step
+runId = response(1).dpRunId
+
+
runId = 40531302
+
+
%% requests continued
+% 3. Download the data
+url_download = 'https://data.oceannetworks.ca/api/dataProductDelivery/download';
+params_download = struct();
+params_download.dpRunId = runId;
+params_download.token = readToken;
+params_download.index = '1';
+request = matlab.net.http.RequestMessage;
+uri = matlab.net.URI(url_download);
+uri.Query = matlab.net.QueryParameter(params_download);
+ 
+% Start - Rerun this part until the response code is 200.
+downloadResponse = request.send(uri,options);
+result = downloadResponse.Body.Data
+responseCode = double(downloadResponse.StatusCode)
+% End - Rerun this part until the response code is 200.
+ 
+% %downloadResponse.Headers has field Content-Disposition, 
+% %and Content-Disposition has the format "attachement; filename=XXX.png"
+% contentDisposition = char(downloadResponse.Header.getFields('Content-Disposition').Value);
+% filename = contentDisposition(23:end);
+% imwrite(downloadResponse.Body.Data, filename);
+% %Use other download functions if content type is not png/jpg
+
+
result = struct with fields:
message: 'Running' + status: 'running' +
+
responseCode = 202
+
+
+

Another option to get the data

+

Obtain your downloads from your user FTP directory (More -> User Directory) in Oceans 3.0. Navigate to the folder that contains the runId: You will see the files in this folder.

+ +
+
+ + diff --git a/doc/HowToUse.html b/doc/HowToUse.html new file mode 100644 index 0000000..954f11a --- /dev/null +++ b/doc/HowToUse.html @@ -0,0 +1,81 @@ + + + + Ocean Networks Canada API Client Library +
+

How to use this library

+

Contents

+
+ +
+
+ \ No newline at end of file diff --git a/doc/Info.html b/doc/Info.html new file mode 100644 index 0000000..24d3200 --- /dev/null +++ b/doc/Info.html @@ -0,0 +1,158 @@ + + + + Ocean Networks Canada API Client Library +
+

Ocean Networks Canada API Client Library

+

This library serves as a toolbox to access ONC Web Services which allows users to discover and retrieve Ocean Networks Canada's 12+ years of oceanographic data in raw, text, image, audio, video or any other format available. This codebase provides a class that wraps web service calls, complex workflows, and business logic so that users can download data with a single line of code.

+

Check left panel for more documentation and code examples. You can also find code examples under Examples section from here

+

Introduction to ONC Web Services/API

+

What are ONC Web Services?

+

A group of public web services that can be used to explore and download ONC data.

+

Documentation pages

+

https://wiki.oceannetworks.ca/display/O2A/Oceans+3.0+API+Home

+

https://data.oceannetworks.ca/OpenAPI

+

Tutorial Page

+

Web API Tutorial

+

Oceans 3.0 API overview

+

Check here for more information.

+

Glossary of terms

+

Check here for more information.

+

Main documentation

+

Check left panel to select and view documentation of each service and function.

+
+ diff --git a/doc/Onc.html b/doc/Onc.html new file mode 100644 index 0000000..a0d6a6f --- /dev/null +++ b/doc/Onc.html @@ -0,0 +1,146 @@ + + + + + Onc + +
+

The ONC class

+

The ONC class provides a wrapper for Oceans 3.0 API requests. All the client library’s functionality is provided as methods of this class. Create an ONC object to access this library’s functionalities.

+

Parameters:

+
    * token ([char]) - The ONC API token, which could be retrieved at https://data.oceannetworks.ca/Profile once logged in.
+    * production (logical, optional, default = True) - Whether the ONC Production server URL is used for service requests.
+            True: Use the production server. 
+            False: Use the internal ONC test server (reserved for ONC staff IP addresses).
+    * showInfo (logical, optional, default = false) - Whether verbose script messages are displayed, such as request url and processing time information.
+            True: Print all information and debug messages (intended for debugging).
+            False: Only print information messages.
+    * outPath ([char], optional, default = 'output') - Output path for downloaded files. The directory will be created if it does not exist during the download.
+    * timeout (int, optional, default = 60) - Number of seconds before a request to the API is canceled
+
+

Returns: The Onc object created.

+

Examples:

+
+onc = ONC("YOUR_TOKEN_HERE", 'showInfo', true, 'outPath', 'myOutPath');
+
+

For detailed information and usage examples, run doc command or visit MATLAB's help browser https://www.mathworks.com/help/matlab/ then find Ocean Networks Canada API Client under supplemental software

+

Source code:

+
function this = Onc(token, varargin)
+    p = inputParser;
+    addRequired(p, 'token', @ischar);
+    addOptional(p, 'production', true, @islogical);
+    addOptional(p, 'showInfo', false, @islogical);
+    addOptional(p, 'outPath', 'output', @ischar);
+    addOptional(p, 'timeout', 60, @isnumeric);
+    parse(p, token, varargin{:});
+
+    this.token      = strtrim(p.Results.token);
+    this.production = p.Results.production;
+    this.showInfo   = p.Results.showInfo;
+    this.timeout    = p.Results.timeout;
+
+    % sanitize outPath
+    opath = strtrim(p.Results.outPath);
+    if strlength(opath) > 0
+        opath = strrep(opath, '\', '/');
+        if opath(end) == '/'
+            opath = opath(1:end-1);
+        end
+    end
+        this.outPath = opath;
+
+    if not(this.production)
+        this.baseUrl = 'https://qa.oceannetworks.ca/';
+    end
+
+    %If a search tree file exists, load it.  If not, generate and save one
+    [source_path,~,~] = fileparts(which('Onc.m'));
+    tree_path = fullfile(source_path,'onc_tree.mat');
+    if ~exist(tree_path,'file')
+        fprintf('\n Loading ONC search tree.  Accessible with onc.tree \n');
+        tree = util.extract_tree(this);
+        save(tree_path, 'tree')
+    elseif exist(tree_path,'file')
+        %Check if it's more than a week old. If so, update it:
+        dir_files = dir(source_path);
+        filenames = {dir_files(:).name};
+        [~,idx] = ismember('onc_tree.mat',filenames);
+        treeFileDate = dir_files(idx).datenum;
+        if now - treeFileDate > 7
+            fprintf('\n Updating ONC search tree.  Accessible with onc.tree \n');
+            tree = util.extract_tree(this);
+            save(tree_path, 'tree')
+        end
+    end
+    temp = load(tree_path);
+    this.tree = temp.tree;
+    %These codes can then be used for input to onc.getDevices by
+    %providing the locationCodes
+end
+
+ \ No newline at end of file diff --git a/doc/OncArchive.html b/doc/OncArchive.html new file mode 100644 index 0000000..755db51 --- /dev/null +++ b/doc/OncArchive.html @@ -0,0 +1,432 @@ + + + + + OncArchive + +
+

ONC Archive Files methods

+

Contents

+

To navigate directly to a specific part of the documentation (use the internal links), right-click on the section you're interested and select "Open" or "Open in New Tab".

+ + +

ONC Archive File Service

+

Contains the functionality that wraps API archivefile services To be inherited by the Onc class These methods allow users to directly download previously generated data product files from our archive.

+

ONC systems auto-generate and archive files of different types at set time intervals. These archived files can be downloaded without waiting for a generation process to finish (potentially faster than Data product download methods).

+
+

Note

+

Archived files have a unique filename (e.g. “NAXYS_HYD_007_20091231T235919.476Z-spect.png”) that includes the device code (“NAXYS_HYD_007”) and the UTC date-time when the data in the file started being measured (“20091231T235919.476Z”). The filename might contain additional information.

+
+

+
+

Caution

+

Due to security regulations, some very recent files (e.g. hydrophone.wav files in the last hour) might not be made immediately available.

+
+

GetListByLocation(filters, allPages)

+

Get a list of files for a given location and device category filtered by other optional parameters.

+

Input: +

+

Output: +

+

+

The API endpoint is /archivefile/location.

+

Parameters in filter: Query string parameters in the API request. Supported parameters are: +

    * locationCode: char array 
+    * deviceCategoryCode: char array   
+    * dateFrom: char array   
+    * dateTo: char array   
+    * .....
+
+

Returns([struct]): API response. Each struct returned contains following fields:

+
    * citations: struct   
+    * files: char array   
+    * queryUrl: struct   
+    * ......
+
+

See https://data.oceannetworks.ca/OpenAPI#get-/archivefile/location for full structure of response and all available filters.

+

Check https://wiki.oceannetworks.ca/display/O2A/Glossary+of+Terms for more information.

+

Example:

+
params = struct(...
+    'locationCode', 'NCBC', ...
+    'deviceCategoryCode', 'BPR', ...
+    'dateFrom', '2019-11-23T00:00:00.000Z', ...
+    'dateTo', '2019-11-26T00:00:00.000Z', ...
+    'dateArchivedFrom', '2019-11-24T00:00:00.000Z', ...
+    'dateArchivedTo', '2019-11-27T00:00:00.000Z', ...
+    'fileExtension', 'txt', ...
+    'rowLimit', 80000, ...
+    'page', 1 ...
+    ); 
+result = onc.getListByLocation(params);
+
+

For more examples, see Onc Archive example live script

+

Source code:

+
function fileList = getListByLocation(this, filters, varargin)
+    [allPages] = util.param(varargin, 'allPages', false);
+    fileList = this.getList(filters, 'location', allPages);
+end
+
+

GetListByDevice(filters, allPages)

+

Get a list of files for a given device filtered by other optional parameters.

+

Input: +

+

Output: +

+

The API endpoint is /archivefile/location.

+

Parameters in filter: Query string parameters in the API request. Supported parameters are:

+
    * deviceCode: char array   
+    * dateFrom: char array   
+    * dateTo: char array   
+    * dateArchivedFrom: char array   
+    * dateArchivedTo: char array   
+    * .....
+

Returns([struct]): API response. Each struct returned contains following fields:

+
    * citations: struct   
+    * files: char array   
+    * queryUrl: struct   
+    * ......
+

See https://data.oceannetworks.ca/OpenAPI#get-/archivefile/location for full structure of response and all available filters.

+

Check https://wiki.oceannetworks.ca/display/O2A/Glossary+of+Terms for more information.

+

Example:

+
params = struct(...
+    'deviceCode', 'BPR-Folger-59', ...
+    'dateFrom', '2019-11-23T00:00:00.000Z', ...
+    'dateTo', '2019-11-26T00:00:00.000Z', ...
+    'dateArchivedFrom', '2019-11-24T00:00:00.000Z', ...
+    'dateArchivedTo', '2019-11-27T00:00:00.000Z', ...
+    'fileExtension', 'txt', ...
+    'rowLimit', 80000, ...
+    'page', 1 ...
+    ); 
+result = onc.getListByDevice(params);
+
+

For more examples, see Onc Archive example live script

+

Source code:

+
function r = getListByDevice(this, filters, varargin)
+    [allPages] = util.param(varargin, 'allPages', false);
+    r = this.getList(filters, 'device', allPages);
+end
+
+

GetFile(filename, overwrite)

+

Download the archive file identified by filename

+

Input: +

+

Output: +

+

The API endpoint is /archivefile/download.

+

Returns(struct): API response. Each struct returned contains following fields:

+
    * url: char array   
+    * status: char array   
+    * file: char array   
+    * ......
+
+

See https://data.oceannetworks.ca/OpenAPI#get-/archivefile/download for full structure of response and all available filters.

+

Check https://wiki.oceannetworks.ca/display/O2A/Glossary+of+Terms for more information.

+

Example:

+
filename = 'BPR-Folger-59_20191123T000000.000Z.txt'; 
+downloadInfo = onc.getFile(filename);
+

For more examples, see Onc Archive example live script

+

Source code:

+
function fileInfo = getFile(this, filename, varargin)
+    if ~exist('filename', 'var')
+        filename = '';
+    end
+    [overwrite, showMsg] = util.param(varargin, 'overwrite', false, 'showMsg', true);
+
+    url = this.serviceUrl('archivefiles');
+    filters = struct('token', this.token,'method', 'getFile', 'filename', filename);
+
+    if showMsg, fprintf('Downloading file "%s"...\n', filename); end
+
+    [response, info] = ...
+    util.do_request(url, filters, 'timeout', this.timeout, 'showInfo', this.showInfo, ...
+                'showProgress', true);
+
+    if not(info.status == 200)
+        fileInfo = response;
+        return;
+    end
+
+    outPath    = this.outPath;
+    saveStatus = util.save_as_file(response, outPath, filename, overwrite);
+
+    txtStatus  = 'error';
+    if info.status == 200
+        if saveStatus == 0
+            txtStatus = 'completed';
+            if showMsg, fprintf('   File was downloaded to "%s"\n', filename); end
+        end
+
+        fullUrl = this.getDownloadUrl(filename);
+        fileInfo = struct(             ...
+            'url'         , fullUrl,   ...
+            'status'      , txtStatus, ...
+            'size'        , info.size, ...
+            'downloadTime', round(info.duration, 3), ...
+            'file'        , filename);
+
+        return;
+    end
+
+    fileInfo = struct( ...
+        'url'         , "",        ...
+        'status'      , txtStatus, ...
+        'size'        , 0,         ...
+        'downloadTime', 0,         ...
+        'file'        , "");
+end
+
+

GetDirectFiles(filters, allPages, overwrite)

+

Downloads all archive files that match the filters Uses geListByDevice or getListByLocation to get a file list, then getFile's everything.

+

Input: +

+

Output: +

+

Parameters in filter: Query string parameters in the API request. Supported parameters are:

+
    * locationCode: char array   
+    * deviceCode: char array   
+    * dateFrom: char array   
+    * dateTo: char array   
+    * dateArchivedFrom: char array   
+    * dateArchivedTo: char array   
+    * .....
+
+

Returns(struct): API response.

+
    * downloadResults: struct array. Each struct in the array contains following fields: 
+        * url: char array
+        * status: char array
+        * file: char array
+        * ......
+    * stats: struct
+        * totalSize: double       
+        * fileCount: double       
+        * downloadTime: double
+
+

See https://data.oceannetworks.ca/OpenAPI#get-/archivefile/location and https://data.oceannetworks.ca/OpenAPI#get-/archivefile/device all available filters and https://data.oceannetworks.ca/OpenAPI#get-/archivefile/download for full structure of response.

+

Check https://wiki.oceannetworks.ca/display/O2A/Glossary+of+Terms for more information.

+

Example:

+
params = struct(...
+    'deviceCode', 'BPR-Folger-59', ...
+    'dateFrom', '2019-11-23T00:00:00.000Z', ...
+    'dateTo', '2019-11-26T00:00:00.000Z', ...
+    'dateArchivedFrom', '2019-11-24T00:00:00.000Z', ...
+    'dateArchivedTo', '2019-11-27T00:00:00.000Z', ...
+    'fileExtension', 'txt', ...
+    'rowLimit', 80000, ...
+    'page', 1 ...
+    ); 
+results = onc.getDirectFiles(params);
+
+

For more examples, see Onc Archive example live script

+

Source code:

+
function results = getDirectFiles(this, filters, varargin)
+    [overwrite, allPages] = util.param(varargin, 'overwrite', false, 'allPages', false);
+
+    % Sanitize filters
+    filters = util.sanitize_filters(filters);
+
+    % make sure we only get a simple list of files
+    if isfield(filters, 'returnOptions')
+        filters = rmfield(filters, 'returnOptions');
+    end
+
+    % Get a list of files
+    if isfield(filters, 'locationCode') && isfield(filters, 'deviceCategoryCode')
+        dataRows = this.getListByLocation(filters, allPages);
+    elseif isfield(filters, 'deviceCode')
+        dataRows = this.getListByDevice(filters, allPages);
+    else
+        msg = 'ERROR: getDirectFiles filters require either a combination of (locationCode)';
+        msg = [msg ' and (deviceCategoryCode), or a (deviceCode) present.'];
+        error('Archive:InvalidFilters', msg);
+    end
+
+    n = length(dataRows.files);
+    fprintf('Obtained a list of %d files to download.\n', n);
+
+    % Download the files obtained
+    tries = 1;
+    successes = 0;
+    size = 0;
+    time = 0;
+    downInfos = [];
+    for i = 1 : numel(dataRows.files)
+        firstCell = dataRows.files(i);
+        filename  = firstCell{1};
+
+        % only download if file doesn't exist (or overwrite is True)
+        outPath  = this.outPath;
+        filePath = sprintf('%s/%s', outPath, filename);
+        fileExists = isfile(filePath);
+
+        if not(fileExists) || (fileExists && overwrite)
+            fprintf('   (%d of %d) Downloading file: "%s"\n', tries, n, filename);
+            downInfo = this.getFile(filename, overwrite, 'showMsg', false);
+
+            % Skip this file if the request failed
+            if util.is_failed_response(downInfo)
+                fprintf('   Skipping "%s" due to an error.\n', filename);
+                tries = tries + 1;
+                errorInfo = struct( ...
+                    'url'         , this.getDownloadUrl(filename), ...
+                    'status'      , 'error', ...
+                    'size'        , 0,       ...
+                    'downloadTime', 0,       ...
+                    'file'        , "");
+                downInfos = [downInfos, errorInfo];
+                continue;
+            end
+
+            size  = size + downInfo.size;
+            time  = time + downInfo.downloadTime;
+            tries = tries + 1;
+
+            if strcmp(downInfo.status, 'completed')
+                successes = successes + 1;
+            end
+            downInfos = [downInfos, downInfo];
+        else
+            fprintf('   Skipping "%s": File already exists.\n', filename);
+            downInfo = struct( ...
+                'url'         , getDownloadUrl(this, filename), ...
+                'status'      , 'skipped', ...
+                'size'        , 0,         ...
+                'downloadTime', 0,         ...
+                'file'        , filename);
+            downInfos = [downInfos, downInfo];
+        end
+    end
+
+    fprintf('%d files (%s) downloaded\n', successes, util.format_size(size));
+    fprintf('Total Download Time: %s\n', util.format_duration(time));
+
+    results = struct( ...
+        'downloadResults', downInfos, ...
+        'stats', struct(              ...
+            'totalSize'   , size,     ...
+            'downloadTime', time,     ...
+            'fileCount'   , successes));
+end
+
+
\ No newline at end of file diff --git a/doc/OncDelivery.html b/doc/OncDelivery.html new file mode 100644 index 0000000..11743e4 --- /dev/null +++ b/doc/OncDelivery.html @@ -0,0 +1,466 @@ + + + + + OncDelivery + + +

ONC Delivery methods

Contents

+

To navigate directly to a specific part of the documentation (use the internal links), right-click on the section you're interested and select "Open" or "Open in New Tab".

+
+ +
+ +

ONC Delivery Service

+

Functionality that wraps the API data product delivery services. To be inherited by the Onc class Data product download methods allow you to request and download more than 120 different types of ONC data products, with granular control over what data to obtain, from where, and in what time frame. They are comparable to the download functionality from ONC’s Data Search tool. Examples of usage include:

+
+ +
+
+

Note

+

If the data product requested doesn’t exist in our archive, it will be generated by our servers before your download starts.

+
+

OrderDataProduct(filters, maxRetries, downloadResultsOnly, ...)

+

Request, run and download a data product as described by the filters

+

Input: +

+

Output: +

+

The API endpoint is /dataProductDelivery.

+

Parameters in filter: Query string parameters in the API request. Supported parameters are:

+
    * dataProductCode: char array   
+    * extension: char array   
+    * dateFrom: char array   
+    * dateTo: char array   
+    * .....
+
+

Returns(struct): API response. Each struct returned contains following fields:

+
    * dpRequestId: double
+    * estimatedFileSize: char array
+    * ......
+
+

Check https://wiki.oceannetworks.ca/display/O2A/Glossary+of+Terms for more information.

+

Example:

+
params = struct(...
+    'locationCode', 'SEVIP', ...
+    'deviceCategoryCode', 'CTD', ...
+    'dataProductCode', 'TSSP', ...
+    'extension', 'png', ...
+    'dateFrom', '2019-06-20T00:00:00.000Z', ...
+    'dateTo', '2019-06-21T00:00:00.000Z', ...
+    'dpo_qualityControl', '1', ...
+    'dpo_resample', 'none' ...
+    ); 
+result = onc.orderDataProduct(params);
+
+

For more examples, see Onc Delivery example live script

+

Source code:

+
function [r, status] = orderDataProduct(this, filters, varargin)
+    [maxRetries, downloadResultsOnly, metadata, overwrite] = util.param(varargin, ...
+    'maxRetries', 0, 'downloadResultsOnly', false, 'includeMetadataFile', true, 'overwrite', false);
+    fileList = [];
+    % Request the product
+    [rqData, ~] = this.requestDataProduct(filters);
+    
+    % Run the product request
+    [runData, status] = this.runDataProduct(rqData.dpRequestId);
+    if downloadResultsOnly
+        % Only run and return links
+        for i = 1 : numel(runData.runIds)
+            runId = runData.runIds(i);
+            fileList = [fileList, this.infoForProductFiles(runId, runData.fileCount, metadata)];
+        end
+    else
+        % Run and download files
+        for i = 1 : numel(runData.runIds)
+            runId = runData.runIds(i);
+            fileList = [fileList, this.downloadProductFiles(runId, metadata, maxRetries, overwrite)];
+        end
+    end
+
+    fprintf('\n');
+    this.printProductOrderStats(fileList, runData);
+    r = this.formatResult(fileList, runData);
+end
+
+

RequestDataProducts(filters, maxRetries, ...)

+

Request a data product generation described by the filters

+

Input: +

+

Output: +

+

+

The API endpoint is /dataProductDelivery/request.

+

Parameters in filter: Query string parameters in the API request. Supported parameters are:

+
    * dataProductCode: char array   
+    * extension: char array   
+    * dateFrom: char array   
+    * dateTo: char array   
+    * deviceCode: char array   
+    * .....
+
+

Returns(struct): API response. Each struct returned contains following fields:

+
    * dpRequestId: double   
+    * estimatedFileSize: char array   
+    * messages: cell array   
+    * ...... 
+
+

See https://data.oceannetworks.ca/OpenAPI#get-/dataProductDelivery/request for full structure of response and all available filters.

+

Check https://wiki.oceannetworks.ca/display/O2A/Glossary+of+Terms for more information.

+

Example:

+
params = struct(...
+    'dataProductCode', 'TSSD', ...
+    'extension', 'csv', ...
+    'dateFrom', '2019-11-23T00:00:00.000Z', ...
+    'dateTo', '2019-11-24T00:00:00.000Z', ...
+    'deviceCode', 'BPR-Folger-59', ...
+    'dpo_minMaxAvg', 60, ...
+    'dpo_resample', 'minMaxAvg' ...
+    ); 
+result = onc.requestDataProduct(params);
+
+

For more examples, see Onc Delivery example live script

+

Source code:

+
function [r, status] = requestDataProduct(this, filters)
+    filters = util.sanitize_filters(filters);
+    filters.method = 'request';
+    filters.token  = this.token;
+
+    url = sprintf('%sapi/dataProductDelivery', this.baseUrl);
+    fprintf('Requesting data product...\n');
+    [r, info] = this.doRequest(url, filters);
+    status = info.status;
+    this.estimatePollPeriod(r);
+    this.printProductRequest(r);
+end
+
+

RunDataProduct(dpRequestId, waitComplete)

+

Run a data product generation request

+

Input: +

+

+

Output: +

+

+

The API endpoint is /dataProductDelivery/run.

+

Returns(struct): API response. Each struct returned contains following fields:

+
    * runIds: double   
+    * fileCount: double   
+    * runTime: double   
+    * ......
+
+

See https://data.oceannetworks.ca/OpenAPI#get-/dataProductDelivery/run for full structure of response and all available filters.

+

Check https://wiki.oceannetworks.ca/display/O2A/Glossary+of+Terms for more information.

+

Example:

+
+result = onc.runDataProduct(params);
+
+

For more examples, see Onc Delivery example live script

+

Source code:

+
function [r, status] = runDataProduct(this, dpRequestId, waitComplete)
+    if ~exist('waitComplete','var'), waitComplete = true; end
+    url = sprintf('%sapi/dataProductDelivery', this.baseUrl);
+    log = onc.DPLogger();
+
+    r = struct('runIds', [], 'fileCount', 0, 'runTime', 0, 'requestCount', 0);
+    filters = struct('method', 'run', 'token', this.token, 'dpRequestId', dpRequestId);
+
+    % run timed run request
+    tic
+    cancelUrl = url + "?method=cancel&token="+string(this.token)+"&dpRequestId=" + string(dpRequestId);
+    if waitComplete
+        fprintf('\nTo cancel this data product, visit url:\n   %s\n', cancelUrl);
+    else
+        fprintf('\nTo cancel this data product, please execute command ''onc.cancelDataProduct(%d)''\n', dpRequestId)
+    end
+    flag = 'queued';
+    while ~strcmp(flag,'complete') && ~strcmp(flag,'cancelled')
+        [response, info] = this.doRequest(url, filters);
+        status = info.status;
+        r.requestCount = r.requestCount + 1;
+
+        % repeat only if waitComplete
+        if waitComplete
+            log.printResponse(response);
+            if status == 202
+                pause(this.pollPeriod);
+            end
+        else
+            break;
+        end
+        flag = response.status;
+    end
+    duration = toc;
+    fprintf('\n')
+
+    % prepare response
+    r.fileCount = response(1).fileCount;
+    r.runTime   = round(duration, 3);
+
+    % gather a list of runIds
+    for i = 1 : numel(response)
+        run = response(i);
+        r.runIds = [r.runIds, run.dpRunId];
+    end
+end
+
+

CheckDataProduct(dpRequestId)

+

Check the status of a data product

+

Input: +

+

Output: +

+

The API endpoint is /dataProductDelivery/status.

+

Returns(struct): API response. Each struct returned contains following fields:

+
    * description: char array   
+    * modifyDate: char array   
+    * status: char array   
+    * ......
+
+

See https://data.oceannetworks.ca/OpenAPI#get-/dataProductDelivery/status for full structure of response and all available filters.

+

Check https://wiki.oceannetworks.ca/display/O2A/Glossary+of+Terms for more information.

+

Example:

+
+response = onc.checkDataProduct(dpRequestId);
+
+

For more examples, see Onc Delivery example live script

+

Source code:

+
function response = checkDataProduct(this, dpRequestId)
+    url = sprintf('%sapi/dataProductDelivery', this.baseUrl);
+    filters = struct('method', 'status', 'token', this.token, 'dpRequestId', dpRequestId);
+    response = this.doRequest(url, filters);
+end
+

CancelDataProduct(dpRequestId)

+

Cancel a running data product

+

Input: +

+

Output: +

+

The API endpoint is /dataProductDelivery/cancel.

+

Returns: API response. Each response(struct) returned contains following fields:

+
    * dpRunId: char array   
+    * status: char array
+

See https://data.oceannetworks.ca/OpenAPI#get-/dataProductDelivery/cancel for full structure of response and all available filters.

+

Check https://wiki.oceannetworks.ca/display/O2A/Glossary+of+Terms for more information.

+

Example:

+
+cancelResponse = onc.cancelDataProduct(dpRequestId);
+
+

For more examples, see Onc Delivery example live script

+

Source code:

+
function [response, info] = cancelDataProduct(this, dpRequestId)
+    url = sprintf('%sapi/dataProductDelivery', this.baseUrl);
+    filters = struct('method', 'cancel', 'token', this.token, 'dpRequestId', dpRequestId);
+    [response, info] = this.doRequest(url, filters);
+    if isfield(response, 'status') && strcmp(response.status, 'cancelled') && info.status == 200
+        fprintf("The data product with request id %d and run id %d has been successfully cancelled.\n", dpRequestId, response.dpRunId);
+    else
+        fprintf("Failed to cancel the data Product.\n");
+    end
+end
+
+

DownloadDataProduct(runId, maxRetries, downloadResultsOnly, ...)

+

Download a data product manually with a runId. Can optionally return just the download links

+

Input: +

+

+

Output: +

+

The API endpoint is /dataProductDelivery/download.

+

Returns: API response. Each response(struct) returned contains following fields:

+
    * url: char array   
+    * status: char array   
+    * statusCode: integer   
+    * file: char array   
+    * downloaded: logical   
+    * ...... 
+
+

See https://data.oceannetworks.ca/OpenAPI#get-/dataProductDelivery/download for full structure of response and all available filters.

+

Check https://wiki.oceannetworks.ca/display/O2A/Glossary+of+Terms for more information.

+

Example:

+
+downloadResult = onc.downloadDataProduct(runResult.runIds);
+
+

For more examples, see Onc Delivery example live script

+

Source code:

+
function fileData = downloadDataProduct(this, runId, varargin)
+    [maxRetries, downloadResultsOnly, metadata, overwrite] = util.param(varargin, ...
+        'maxRetries', 0, 'downloadResultsOnly', false, 'includeMetadataFile', true, 'overwrite', false);
+
+    if downloadResultsOnly
+        fileData = this.infoForProductFiles(runId, 0, metadata);
+    else
+        fileData = this.downloadProductFiles(runId, metadata, maxRetries, overwrite);
+    end
+end
+

RestartDataProduct(dpRequestId, waitComplete)

+

Restart a cancelled data product

+

Input: +

+

Output: +

+

The API endpoint is /dataProductDelivery/restart.

+

Returns: API response. Each response(struct) returned contains following fields:

+
    * dpRunId: char array   
+    * status: char array
+
+

See https://data.oceannetworks.ca/OpenAPI#get-/dataProductDelivery/restart for full structure of response and all available filters.

+

Check https://wiki.oceannetworks.ca/display/O2A/Glossary+of+Terms for more information.

+

Example:

+
+restartResult = onc.restartDataProduct(runResult.runIds);
+
+

For more examples, see Onc Delivery example live script

+

Source code:

+
function [response, info] = restartDataProduct(this, dpRequestId, waitComplete)
+    if ~exist('waitComplete','var'), waitComplete = true; end
+    url = sprintf('%sapi/dataProductDelivery', this.baseUrl);
+    filters = struct('method', 'restart', 'token', this.token, 'dpRequestId', dpRequestId);
+    [response, info] = this.doRequest(url, filters);
+    if isfield(response, 'status') && (strcmp(response.status, 'data product running') || strcmp(response.status, 'queued')) && info.status == 200
+        fprintf("The data product with request id %d and run id %d has been successfully restarted.\n", dpRequestId, response.dpRunId);
+    else
+        fprintf("Failed to restart the data product.\n");
+    end
+    if waitComplete
+        [response, info] = this.runDataProduct(dpRequestId, true);
+    end
+end
+
+
+ \ No newline at end of file diff --git a/doc/OncDiscovery.html b/doc/OncDiscovery.html new file mode 100644 index 0000000..a3234ba --- /dev/null +++ b/doc/OncDiscovery.html @@ -0,0 +1,459 @@ + + + + + OncDiscovery + + + + +

ONC Discovery methods

Contents

+

To navigate directly to a specific part of the documentation (use the internal links), right-click on the section you're interested and select "Open" or "Open in New Tab".

+
+ +
+ +

ONC Discovery methods

+

Contains the functionality that wraps the API discovery services To be inherited by the Onc class Discovery methods can be used to search for available locations, deployments, device categories, devices, properties, and data products. They support numerous filters and might resemble an "advanced search” function for ONC data sources.

+

Use discovery methods to:

+
+ +
+ +
+

Note

+ +
+ +

GetLocations(filters)

+

Obtain a filtered list of locations

+

Input: filters(cell array, optional) - Describes the data origin

+

Output: array of structs - Array of Locations

+

The API endpoint is /locations.

+

See https://data.oceannetworks.ca/OpenAPI#get-/locations for usage and available query string parameters.

+

Parameters: filters(cell array, optional) - Query string parameters in the API request. Return all locations available if None. Supported parameters are:

+
    * locationCode
+    * deviceCategoryCode
+    * propertyCode
+    * dataProductCode
+    * dateFrom
+    * dateTo
+    * locationName
+    * deviceCode
+    * includeChildren
+
+

Returns([struct]): API response. Each location returned in the array is a struct with following fields.

+
   * deployments: double
+    * locationName: char array
+    * depth: double
+    * bbox: dict
+        * bbox.maxDepth: double
+        * bbox.maxLat: double
+        * bbox.maxLon: double
+        * bbox.minDepth: double
+        * bbox.minLat: double
+        * bbox.minLon: double
+    * description: char array
+    * hasDeviceData: logical
+    * lon: double
+    * locationCode: char array
+    * hasPropertyData: logical
+    * lat: double
+    * dataSearchURL: char array
+
+

Check https://wiki.oceannetworks.ca/display/O2A/Glossary+of+Terms for more information.

+

Example:

+
params = {...
+    'locationCode', 'FGPD', ...
+    'dateFrom', '2005-09-17T00:00:00.000Z', ...
+    'dateTo', '2020-09-17T13:00:00.000Z' ...
+    }; 
+onc.getLocations(params)
+
+

For more examples, see Onc Discovery Location example live script

+

Source code:

+
function r = getLocations(this, varargin)
+    filters = this.getFilters(varargin);
+    r = this.discoveryRequest(filters, 'locations');
+end 
+ +

GetLocationHierarchy(filters)

+

Obtain a location tree

+

Input: filters(cell array, optional) - Describes the data origin

+

Output: struct - Location tree

+

The API endpoint is /locations/tree.

+

Return a hierarchical representation of the ONC Search Tree Nodes. The Search Tree is used in Oceans 3.0 to organize instruments and variables 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.

+

See https://data.oceannetworks.ca/OpenAPI#get-/locations/tree for usage and available query string parameters.

+

Parameters: filters(cell array, optional) - Query string parameters in the API request. Return all locations available if None. Supported parameters are:

+
   * locationCode
+    * deviceCategoryCode
+    * propertyCode
+    * dataProductCode
+    * dateFrom
+    * dateTo
+    * locationName
+    * deviceCode
+    * includeChildren
+
+

Returns([struct]): API response. Each location returned in the array is a struct with following fields.

+
    * locationName: char array
+    * children: struct | None
+    * description: char array
+    * hasDeviceData: logical
+    * locationCode: char array
+    * hasPropertyData: logical
+
+

Check https://wiki.oceannetworks.ca/display/O2A/Glossary+of+Terms for more information.

+

Example:

+
params = {'locationCode', 'BACCC'}; 
+onc.getLocationHierarchy(params)
+
+

For more examples, see Onc Discovery Location example live script

+

Source code:

+
function r = getLocationHierarchy(this, varargin)
+    filters = this.getFilters(varargin);
+    r = this.discoveryRequest(filters, 'locations', 'method', 'getTree');
+end
+
+ +

GetDeployments(filters)

+

Obtain an array of device deployments.

+

Input: filters(cell array, optional) - Describes the data origin

+

Output: array of structs - Deployments found

+

The API endpoint is /deployments.

+

Return all deployments defined in Oceans 3.0 which meet the filter criteria, where a deployment is the installation of a device at a location. The deployments service assists in knowing when and where specific types of data are available. +The primary purpose for the deployments service is to find the dates and locations of deployments and use the dateFrom and dateTo datetimes when requesting a data product using the dataProductDelivery web service.

+

See https://data.oceannetworks.ca/OpenAPI#get-/deployments for usage and available query string parameters.

+

Parameters: filters(cell array, optional) - Query string parameters in the API request. Return a tree of all available locations available if None. Supported parameters are:

+
   * locationCode
+    * deviceCategoryCode
+    * deviceCode
+    * propertyCode
+    * dateFrom
+    * dateTo
+

Returns([struct]): API response. Each deployment returned in the array is a struct with the following structure.

+
    * begin: char array
+    * citation: struct
+    * depth: double
+    * deviceCategoryCode: char array
+    * deviceCode: char array
+    * end: char array | None
+    * hasDeviceData: logical
+    * heading: double | None
+    * lat: double
+    * locationCode: char array
+    * lon: double
+    * pitch: double | None
+    * roll: double | None
+

Check https://wiki.oceannetworks.ca/display/O2A/Glossary+of+Terms for more information.

+

Example:

+
params = {...
+    'locationCode', 'BACAX', ...
+    'deviceCategoryCode', 'CTD', ...
+    'dateFrom', '2015-09-17', ...
+    'dateTo', '2015-09-17T13:00:00.000Z'...
+    }; 
+onc.getDeployments(params)
+

For more examples, see Onc Discovery Deployments example live script

+

Source code:

+
function r = getDeployments(this, varargin)
+    filters = this.getFilters(varargin);
+    r = this.discoveryRequest(filters, 'deployments');
+end
+ +

GetDevices(filters)

+

Obtain a filtered list of devices

+

Input: filters(cell array, optional) - Describes the data origin

+

Output: array of structs - Devices found

+

The API endpoint is /devices.

+

Return all the devices defined in Oceans 3.0 that meet a set of filter criteria. + Devices are instruments that have one or more sensors that observe a property or phenomenon with a goal of producing an + estimate of the value of a property. Devices are uniquely identified by a device code and can be deployed at multiple + locations during their lifespan. The primary purpose of the devices service is to find devices that have the data you are interested in + and use the deviceCode when requesting a data product using the dataProductDelivery web service.

+

See https://data.oceannetworks.ca/OpenAPI#get-/devices for usage + and available filters. +

Parameters: filters(cell array, optional) - Query string parameters in the API request. Return all devices available if None. Supported parameters are:

+
    * locationCode
+    * deviceCategoryCode
+    * deviceCode
+    * propertyCode
+    * dateFrom
+    * dateTo
+

Returns([struct]): API response. Each device returned in the array is a struct with following fields.

+
    * cvTerm: struct
+    * cvTerm.device: array of structs
+        * cvTerm.device().uri: char array
+        * cvTerm.device().vocabulary: char array
+    * dataRating: array of structs
+        * dataRating().dateFrom: char array
+        * dataRating().dateTo: char array | None
+        * dataRating().samplePeriod: double
+        * dataRating().sampleSize: double
+    * deviceCategoryCode: char array
+    * deviceCode: char array
+    * deviceId: double
+    * deviceLink: char array
+    * deviceName: char array | None
+    * hasDeviceData: logical
+

Check https://wiki.oceannetworks.ca/display/O2A/Glossary+of+Terms + for more information.

+

Example:

+
params = {...
+    'deviceCode', 'BPR-Folger-59', ...
+    'dateFrom', '2005-09-17T00:00:00.000Z', ...
+    'dateTo', '2020-09-17T13:00:00.000Z' ...
+    };
+onc.getDevices(params)
+

For more examples, see Onc Discovery Devices example live script

+

Source code:

+
function r = getDevices(this, varargin)
+    filters = this.getFilters(varargin);
+    r = this.discoveryRequest(filters, 'devices');
+end
+
+ +

GetDeviceCategories(filters)

+

Obtain a filtered list of device categories

+

Input: filters(cell array, optional) - Describes the data origin

+

Output: array of structs - Device categories found

+

The API endpoint is /deviceCategories.

+

Return all device categories defined in Oceans 3.0 that meet a filter criteria. A Device Category represents an instrument type +classification such as CTD (Conductivity, Temperature & Depth Instrument) or BPR (Bottom Pressure Recorder). +Devices from a category can record data for one or more properties (variables). The primary purpose of this service is to find +device categories that have the data you want to access; the service provides the +deviceCategoryCode you can use when requesting a data product via the dataProductDelivery web service.

+

See https://data.oceannetworks.ca/OpenAPI#get-/deviceCategories + for usage and available filters.

+

Parameters: filters(cell array, optional) - Query string parameters in the API request. Return all device categories available if None. Supported parameters are:

+
   * deviceCategoryCode
+    * deviceCategoryName
+    * description
+    * locationCode
+    * propertyCode
+

Returns([struct]): API response. Each device returned in the array is a struct with following fields.

+
   * cvTerm: struct
+        * cvTerm.deviceCategory: array of structs
+        * cvTerm.deviceCategory().uri: char array
+        * cvTerm.deviceCategory().vocabulary: char array
+   * description: char array
+   * deviceCategoryCode: char array
+   * deviceCategoryName: char array
+   * hasDeviceData: logical
+   * longDescription: char array
+

Check https://wiki.oceannetworks.ca/display/O2A/Glossary+of+Terms + for more information.

+

Example:

+
params = {...
+    'deviceCategoryCode', 'CTD', ...
+    'deviceCategoryName', 'Conductivity', ...
+    'description', 'Temperature' ...
+    };
+onc.getDeviceCategories(params)
+

For more examples, see Onc Discovery Device Categories example live script

+

Source code:

+
function r = getDeviceCategories(this, varargin)
+    filters = this.getFilters(varargin);
+    r = this.discoveryRequest(filters, 'deviceCategories');
+end
+ +

GetProperties(filters)

+

Obtain a filtered list of properties

+

Input: filters(cell array, optional) - Describes the data origin

+

Output: array of structs - Properties found

+

The API endpoint is /properties.

+

Return all properties defined in Oceans 3.0 that meet a filter criteria. Properties are observable phenomena (aka, variables) are the + common names given to sensor types (i.e., oxygen, pressure, temperature, etc). + The primary purpose of this service is to find the available properties of the data you want to access; + the service provides the propertyCode that you can use to request a data product via the dataProductDelivery web service.

+

See https://data.oceannetworks.ca/OpenAPI#get-/properties for usage + and available filters.

+

Parameters: filters(cell array, optional) - Query string parameters in the API request. Return all properties available if None. Supported parameters are:

+
    * propertyCode
+    * propertyName
+    * description
+    * locationCode
+    * deviceCategoryCode
+    * deviceCode
+

Returns([struct]): API response. Each device returned in the array is a struct with following fields.

+
   * cvTerm: struct
+    * cvTerm.property: array of structs
+        * cvTerm.property().uri: char array
+        * cvTerm.property().vocabulary: char array
+    * cvTerm.uom: array of structs
+        * cvTerm.uom().uri: char array
+        * cvTerm.uom().vocabulary: char array
+   * description: char array
+   * hasDeviceData: logical
+   * hasPropertyData: logical
+   * propertyCode: char array
+   * propertyName: char array
+   * uom: char array
+

Check https://wiki.oceannetworks.ca/display/O2A/Glossary+of+Terms + for more information.

+

Example:

+
params = {...
+    'propertyCode', 'conductivity', ...
+    'locationCode', 'BACAX', ...
+    'deviceCategoryCode', 'CTD' ...
+    }; 
+onc.getProperties(params)
+
+

For more examples, see Onc Discovery Properties example live script

+

Source code:

+
function r = getProperties(this, varargin)
+    filters = this.getFilters(varargin);
+    r = this.discoveryRequest(filters, 'properties');
+end
+ +

GetDataProducts(filters)

+

Obtain a list of available data products for the filters

+

Input: filters(cell array, optional) - Describes the data origin

+

Output: array of structs - Data products found

+

The API endpoint is /dataProducts.

+

Return all data products defined in Oceans 3.0 that meet a filter criteria. Data Products are downloadable representations of ONC + observational data, provided in formats that can be easily ingested by analytical or visualization software. The primary purpose of this + service is to identify which data products and formats (file extensions) are available for the locations, devices, device categories or + properties of interest. Use the dataProductCode and extension when requesting a data product via the dataProductDelivery web service.

+

See https://data.oceannetworks.ca/OpenAPI#get-/dataProducts for usage + and available filters.

+

Parameters: filters(cell array, optional) - Query string parameters in the API request. Return all data products available if None. Supported parameters are:

+
   * dataProductCode
+    * extension
+    * dataProductName
+    * propertyCode
+    * locationCode
+    * deviceCategoryCode
+    * deviceCode
+

Returns([struct]): API response. Each device returned in the array is a struct with following fields.

+
   * dataProductCode: char array
+    * dataProductName: char array
+    * dataProductOptions: array of structs
+        * dataProductOptions().allowableRange: array of structs | None
+            * dataProductOptions().allowableRange.lowerBound: char array
+            * dataProductOptions().allowableRange.onlyIntegers: logical
+            * dataProductOptions().allowableRange.unitOfMeasure: char array | None
+            * dataProductOptions().allowableRange.upperBound: char array
+        * dataProductOptions[].allowableValues: array of structs
+        * dataProductOptions[].defaultValues: char array
+        * dataProductOptions[].documentation: array of structs
+        * dataProductOptions[].option: char array
+        * dataProductOptions[].suboptions: array of structs | None
+    * extension: char array
+    * hasDeviceData: logical
+    * hasPropertyData: logical
+    * helpDocument: char array
+

Check https://wiki.oceannetworks.ca/display/O2A/Glossary+of+Terms + for more information.

+

Example:

+
params = {'dataProductCode', 'SHV'}; 
+onc.getProperties(params)
+

For more examples, see Onc Discovery Data Products example live script

+

Source code:

+
function r = getDataProducts(this, varargin)
+    filters = this.getFilters(varargin);
+    r = this.discoveryRequest(filters, 'dataProducts');
+end
+
+ +
\ No newline at end of file diff --git a/doc/OncRealTime.html b/doc/OncRealTime.html new file mode 100644 index 0000000..57dc933 --- /dev/null +++ b/doc/OncRealTime.html @@ -0,0 +1,306 @@ + + + + + OncRealTime + +
+

ONC Real-time data methods

+

Contents

+

To navigate directly to a specific part of the documentation (use the internal links), right-click on the section you're interested and select "Open" or "Open in New Tab".

+
+ +
+ +

Near Real-Time data service

+

Contains the functionality that wraps API real-time services. To be inherited by the Onc class Near real-time (as fast as they get into our database) data access methods allow the extraction of sensor data as time-series, either as processed scalar data with Quality Assurance and Control flags (QAQC) or directly as raw data obtained from the device in its specific output format. In contrast to the Data product download methods, this data can be downloaded directly without waiting for any kind of generation process.

+

Common use cases include:

+
+ +
+
+

Note

+
    +
  1. The methods getDirectByLocation() and getDirectRawByLocation() obtain data readings from a location no matter what device it came from (hence the need to specify a device category code instead of a single device code). You might want to obtain data by location instead of by device, as individual devices are often replaced/repositioned.
  2. +
  3. Each request to our API can return a maximum of 100,000 samples; larger data requests must be downloaded as a sequence of pages. Use the allPages parameter to automatically download all pages required for your requested time frame.
  4. +
+
+

GetDirectByLocation(filters, allPages)

+

Obtains scalar data from a location, from the source described by the filters

+

Input: +

+

+

Output:

+

The API endpoint is /scalardata/location.

+

Parameters in filter: Query string parameters in the API request. Supported parameters are:

+
    * locationCode: char array
+    * deviceCategoryCode: char array
+    * propertyCode: char array
+    * sensorCategoryCodes: char array
+    * .....
+
+

Returns(struct): API response. Each struct returned contains following fields:

+
    * parameters: struct   
+    * message: char array   
+    * metadata: struct   
+    * ......
+
+

See https://data.oceannetworks.ca/OpenAPI#get-/scalardata/location for full structure of response and all available filters.

+

Check https://wiki.oceannetworks.ca/display/O2A/Glossary+of+Terms for more information.

+

Example:

+
params = struct(...
+    'locationCode', 'NCBC', ...
+    'deviceCategoryCode', 'BPR', ...
+    'propertyCode', 'seawatertemperature,totalpressure', ...
+    'rowLimit', 80000, ...
+    'dateFrom', '2019-11-23T00:00:00.000Z', ...
+    'dateTo', '2019-11-23T00:01:00.000Z' ...
+    ); 
+result = onc.getDirectByLocation(params);
+
+

For more examples, see Onc Real Time Data example live script

+

Source code:

+
function r = getDirectByLocation(this, filters, varargin)
+    [allPages] = util.param(varargin, 'allPages', false);
+    r = this.getDirectAllPages(filters, 'scalardata', 'getByLocation', allPages);
+end
+
+

GetDirectByDevice(filters, allPages)

+

Obtains scalar data from a device, as described by the filters

+

Input: +

+

+

Output: +

+

+

The API endpoint is /scalardata/device.

+

Parameters in filter: Query string parameters in the API request. Supported parameters are: +

    * deviceCode: char array   
+    * sensorCategoryCodes: char array   
+    * dateFrom: char array   
+    * dateTo: char array   
+    * .....
+
+

Returns(struct): API response. Each struct returned contains following fields: +

    * parameters: struct   
+    * message: char array   
+    * metadata: struct   
+    * ......
+
+

See https://data.oceannetworks.ca/OpenAPI#get-/scalardata/device for full structure of response and all available filters.

+

Check https://wiki.oceannetworks.ca/display/O2A/Glossary+of+Terms for more information.

+

Example:

+
params = struct(...
+    'deviceCode', 'BPR-Folger-59', ...
+    'rowLimit', 80000, ...
+    'dateFrom', '2019-11-23T00:00:00.000Z', ...
+    'dateTo', '2019-11-23T00:01:00.000Z' ...
+    ); 
+result = onc.getDirectByDevice(params);
+
+

For more examples, see Onc Real Time Data example live script

+

Source code:

+
function r = getDirectByDevice(this, filters, varargin)
+    [allPages] = util.param(varargin, 'allPages', false);
+    r = this.getDirectAllPages(filters, 'scalardata', 'getByDevice', allPages);
+end
+
+

GetDirectRawByLocation(filters, allPages)

+

Obtains raw data from a location, from the source described by the filters

+

Input: +

+

Output: +

+

The API endpoint is /rawdata/location.

+

Parameters in filter: Query string parameters in the API request. Supported parameters are: +

    * locationCode: char array   
+    * deviceCategoryCode: char array   
+    * dateFrom: char array   
+    * dateTo: char array   
+    * .....
+
+

Returns(struct): API response. Each struct returned contains following fields: +

    * citation: struct   
+    * message: char array   
+    * next(struct):       
+        * parameters: struct       
+        * url: char array   
+    * ......
+    
+
+

See https://data.oceannetworks.ca/OpenAPI#get-/rawdata/location for full structure of response and all available filters.

+

Check https://wiki.oceannetworks.ca/display/O2A/Glossary+of+Terms for more information.

+

Example:

+
params = struct(...
+    'locationCode', 'NCBC', ...
+    'deviceCategoryCode', 'BPR', ...
+    'rowLimit', 80000, ...
+    'dateFrom', '2019-11-23T00:00:00.000Z', ...
+    'dateTo', '2019-11-23T00:01:00.000Z', ...
+    'sizeLimit', 20, ...
+    'convertHexToDecimal', false ...
+    ); 
+result = onc.getDirectRawByLocation(params);
+
+

For more examples, see Onc Real Time Data example live script

+

Source code:

+
function r = getDirectRawByLocation(this, filters, varargin)
+    [allPages] = util.param(varargin, 'allPages', false);
+    r = this.getDirectAllPages(filters, 'rawdata', 'getByLocation', allPages);
+end
+
+

GetDirectRawByDevice(filters, allPages)

+

Obtains raw data from a device, as described by the filters

+

Input: +

+

+

Output: +

+

+

The API endpoint is /rawdata/device.

+

Parameters in filter: Query string parameters in the API request. Supported parameters are: +

    * deviceCode: char array   
+    * dateFrom: char array   
+    * dateTo: char array   
+    * .....
+
+

Returns(struct): API response. Each struct returned contains following fields: +

    * citation: struct   
+    * message: char array   
+    * next(struct):       
+        * parameters: struct       
+        * url: char array   
+    * ......
+
+

See https://data.oceannetworks.ca/OpenAPI#get-/rawdata/device for full structure of response and all available filters.

+

Check https://wiki.oceannetworks.ca/display/O2A/Glossary+of+Terms for more information.

+

Example:

+
params = struct(...
+    'deviceCode', 'BPR-Folger-59', ...
+    'rowLimit', 80000, ...
+    'dateFrom', '2019-11-23T00:00:00.000Z', ...
+    'dateTo', '2019-11-23T00:01:00.000Z', ...
+    'sizeLimit', 20, ...
+    'convertHexToDecimal', false ...
+    ); 
+result = onc.getDirectRawByDevice(params);
+
+

For more examples, see Onc Real Time Data example live script

+

Source code:

+
function r = getDirectRawByDevice(this, filters, varargin)
+    [allPages] = util.param(varargin, 'allPages', false);
+    r = this.getDirectAllPages(filters, 'rawdata', 'getByDevice', allPages);
+end
+
+ \ No newline at end of file diff --git a/doc/UpdateInstruction.html b/doc/UpdateInstruction.html new file mode 100644 index 0000000..50f3601 --- /dev/null +++ b/doc/UpdateInstruction.html @@ -0,0 +1,151 @@ + + + + How to update to latest version +
+

How to update to latest version

+

When using Ocean Networks Canada API Client Library, you may get a warning about outdated version. Follow the following instruction to update to latest version.

+
+

Note

+

If you would like to download a specific version, visit Ocean Networks Canada API Client Library File Exchange - Version History and then download your preferred version.

+
+

1. Select Manage Add-Ons under Add-Ons from the HOME menu.

+ +

2. Select updates at the top, new releases of installed libraries will show below. Click update to the right of Ocean Networks Canada API Client Library.

+ +
+ diff --git a/doc/UserDirectory.png b/doc/UserDirectory.png new file mode 100644 index 0000000..efb1033 Binary files /dev/null and b/doc/UserDirectory.png differ diff --git a/doc/helptoc.xml b/doc/helptoc.xml new file mode 100644 index 0000000..4b52eb6 --- /dev/null +++ b/doc/helptoc.xml @@ -0,0 +1,28 @@ + + + + ONC Toolbox + + How to use + Getting Started with this library + Onc class + + + Discovery Service + + + Delivery Service + + + Archive Service + + + Near Real Time Service + + + Examples/Live Scripts + + How to update to latest version + + + \ No newline at end of file diff --git a/doc/update.png b/doc/update.png new file mode 100644 index 0000000..4d23447 Binary files /dev/null and b/doc/update.png differ diff --git a/info.xml b/info.xml new file mode 100644 index 0000000..3442751 --- /dev/null +++ b/info.xml @@ -0,0 +1,23 @@ + + + + + + + + 2022b + + ONC + + + toolbox + + + + + doc + + + + \ No newline at end of file diff --git a/onc/examples/OncArchive.mlx b/onc/examples/OncArchive.mlx new file mode 100644 index 0000000..9153fba Binary files /dev/null and b/onc/examples/OncArchive.mlx differ diff --git a/onc/examples/OncDeliveryDataProducts.mlx b/onc/examples/OncDeliveryDataProducts.mlx new file mode 100644 index 0000000..9b8ffe6 Binary files /dev/null and b/onc/examples/OncDeliveryDataProducts.mlx differ diff --git a/onc/examples/OncDiscoveryDataProducts.mlx b/onc/examples/OncDiscoveryDataProducts.mlx new file mode 100644 index 0000000..a0de425 Binary files /dev/null and b/onc/examples/OncDiscoveryDataProducts.mlx differ diff --git a/onc/examples/OncDiscoveryDeployments.mlx b/onc/examples/OncDiscoveryDeployments.mlx new file mode 100644 index 0000000..21364f7 Binary files /dev/null and b/onc/examples/OncDiscoveryDeployments.mlx differ diff --git a/onc/examples/OncDiscoveryDeviceCategories.mlx b/onc/examples/OncDiscoveryDeviceCategories.mlx new file mode 100644 index 0000000..861e33a Binary files /dev/null and b/onc/examples/OncDiscoveryDeviceCategories.mlx differ diff --git a/onc/examples/OncDiscoveryDevices.mlx b/onc/examples/OncDiscoveryDevices.mlx new file mode 100644 index 0000000..878d9aa Binary files /dev/null and b/onc/examples/OncDiscoveryDevices.mlx differ diff --git a/onc/examples/OncDiscoveryLocations.mlx b/onc/examples/OncDiscoveryLocations.mlx new file mode 100644 index 0000000..e18f764 Binary files /dev/null and b/onc/examples/OncDiscoveryLocations.mlx differ diff --git a/onc/examples/OncDiscoveryProperties.mlx b/onc/examples/OncDiscoveryProperties.mlx new file mode 100644 index 0000000..9eeca64 Binary files /dev/null and b/onc/examples/OncDiscoveryProperties.mlx differ diff --git a/onc/examples/OncRealTime.mlx b/onc/examples/OncRealTime.mlx new file mode 100644 index 0000000..fa9c453 Binary files /dev/null and b/onc/examples/OncRealTime.mlx differ