2.1. Download a PNG plot of data from a CTD | from onc.onc import ONC onc = ONC('YOUR_TOKEN_HERE')
filters = { 'locationCode': 'BIIP', 'deviceCategoryCode': 'CTD', 'dataProductCode': 'TSSP', 'extension': 'png', 'dateFrom': '2019-06-20T00:00:00.000Z', 'dateTo': '2019-06-20T00:30:00.000Z', 'dpo_qualityControl': '1', 'dpo_resample': 'none' } result = onc.orderDataProduct(filters, includeMetadataFile=False) onc.print(result) |
| |
2.2. Download time series readings from a device in CSV format | from onc.onc import ONC onc = ONC('YOUR_TOKEN_HERE')
filters = { 'locationCode':'BACAX', 'deviceCategoryCode':'ADCP2MHZ', 'dataProductCode':'TSSD', 'extension':'csv', 'dateFrom':'2016-07-27T00:00:00.000Z', 'dateTo':'2016-08-01T00:00:00.000Z', 'dpo_qualityControl':1, 'dpo_resample':'none', 'dpo_dataGaps':0 } results = onc.orderDataProduct(filters) onc.print(results) |
| |
2.3. Download 6 months of hydrophone files, 1 hour at a time | # If your data is in the ONC archive, the archive files example 7 # might be noticeably faster for downloading files
from datetime import datetime, timedelta from dateutil.parser import parse from onc.onc import ONC
onc = ONC('YOUR_TOKEN')
# start and end date dateFrom = parse('2019-01-01T00:00:00.000Z') dateTo = parse('2019-06-01T00:00:00.000Z')
# time to add to dateFrom step = timedelta(hours=1)
# use a loop to download 1 hour at a time while dateFrom < dateTo: txtDate = dateFrom.strftime("%Y-%m-%dT%H:%M:%S.000Z") print("\nDownloading data from: {:s}\n".format(txtDate))
filters = { 'dataProductCode' : 'AD', 'locationCode' : 'BACND', 'deviceCategoryCode': 'HYDROPHONE', 'dateFrom' : txtDate, 'dateTo' : 'PT1H', 'extension' : 'wav', 'dpo_hydrophoneDataDiversionMode': 'OD' } result = onc.orderDataProduct(filters, includeMetadataFile=False) dateFrom += step
print("\nFinished!") | % If your data is in the ONC archive, the archive files example 7 % might be noticeably faster for downloading files
onc = ONC('YOUR_TOKEN')
% start and end date dateFrom = datenum('2019-01-01T00:00:00.000Z','yyyy-mm-ddTHH:MM:SS.FFFZ'); dateTo = datenum('2019-06-01T00:00:00.000Z','yyyy-mm-ddTHH:MM:SS.FFFZ');
% time to add to dateFrom step = hours(1);
% use a loop to download 1 hour at a time while dateFrom < dateTo txtDate = datestr(dateFrom,'yyyy-mm-ddTHH:MM:SS.FFFZ'); disp(['Downloading data from: ',txtDate]); filters = { 'dataProductCode' , 'AD' 'locationCode' , 'BACND' 'deviceCategoryCode', 'HYDROPHONE' 'dateFrom' , txtDate 'dateTo' , 'PT1H' 'extension' , 'wav' 'dpo_hydrophoneDataDiversionMode', 'OD' }; result = onc.orderDataProduct(filters, 'includeMetadataFile', false); dateFrom = dateFrom + step; end
disp("Finished!"); | # If your data is in the ONC archive, the archive files example 7 # might be noticeably faster for downloading files
onc = ONC('YOUR_TOKEN') # start and end date dateFrom = parse('2019-01-01T00:00:00.000Z') dateTo = parse('2019-06-01T00:00:00.000Z')
# time to add to dateFrom step = timedelta(hours=1)
# use a loop to download 1 hour at a time while dateFrom < dateTo: txtDate = dateFrom.strftime("%Y-%m-%dT%H:%M:%S.000Z")
print("\nDownloading data from: {:s}\n".format(txtDate)) filters <- list( 'dataProductCode' = 'AD', 'locationCode' = 'BACND', 'deviceCategoryCode' = 'HYDROPHONE', 'dateFrom' : txtDate, 'dateTo' = 'PT1H', 'extension' = 'wav', 'dpo_hydrophoneDataDiversionMode' = 'OD' ) result = onc.orderDataProduct(filters, includeMetadataFile=False) dateFrom += step
print("\nFinished!") |
| |