Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: update example with new method names, improve downloadDirectArch… #49

Merged
merged 1 commit into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions doc/source/Code_Examples/Discover_Locations.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ onc.getLocations(params)

### Get all locations with instruments that have a specific device category and a specific property

Return all locations with at least one instrument that has the device category "**BPR**" and property code
Return all locations with at least one instrument that has the device category "**BPR**" and property code.
"**totalpressure**".

```python
Expand Down Expand Up @@ -158,5 +158,8 @@ Return the location hierarchy from the "**MOBP**" ("Mobile Platforms") node and
params = {
"locationCode": "MOBP",
}
onc.getLocationHierarchy(params)
onc.getLocationsTree(params)

# Alias method name
# onc.getLocationHierarchy(params)
```
73 changes: 49 additions & 24 deletions doc/source/Code_Examples/Download_Archived_Files.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@ params = {
"dateTo": "2019-06-08T00:00:00.000Z",
}

onc.getListByDevice(params)
onc.getArchivefile(params)

# Longer method name
# onc.getArchivefileByDevice(params)

# Alias method name
# onc.getListByDevice(params)
```

### Get a list of all archived files available from a specific device for a specific time-range with a specific extension
Expand All @@ -36,13 +42,23 @@ params = {
"dateTo": "2019-06-08T00:00:00.000Z",
}

onc.getListByDevice(params)
onc.getArchivefile(params)

# Longer method name
# onc.getArchivefileByDevice(params)

# Alias method name
# onc.getListByDevice(params)
```

### Download a file by its filename

```python
onc.getFile("RDIADCP600WH25471_20190607T120000.555Z.rdi", overwrite=True)

onc.downloadArchivefile("ICLISTENHF1560_20181005T000403.000Z-spect.mat", overwrite=True)

# Alias method name
# onc.getFile("ICLISTENHF1560_20181005T000403.000Z-spect.mat", overwrite=True)
```

## [/archivefile/location](https://data.oceannetworks.ca/OpenAPI#get-/archivefile/location)
Expand All @@ -56,49 +72,58 @@ _locationCode_:"**SEVIP**")
params = {
"deviceCategoryCode": "HYDROPHONE",
"locationCode": "SEVIP",
"dateFrom": "2017-01-01T00:00:00.000Z",
"dateTo": "2019-12-31T00:00:00.000Z",
"dateFrom": "2018-10-05T00:05:00.000Z",
"dateTo": "2018-10-05T00:06:00.000Z",
}

onc.getListByLocation(params)["files"]
onc.getArchivefile(params)

# Longer method name
# onc.getArchivefileByLocation(params)

# Alias method name
# onc.getListByLocation(params)
```

### Get a list of all archived files available from a specific location and a device category for a specific time-range with a specific file extension

Return the archived files for a device with _deviceCategoryCode_ "**HYDROPHONE**" at location Straight of Georgia East (
_locationCode_:"**SEVIP**") with file extension "**wav**".
_locationCode_:"**SEVIP**") with file extension "**mat**".

```python
params = {
"deviceCategoryCode": "HYDROPHONE",
"locationCode": "SEVIP",
"extension": "wav",
"dateFrom": "2017-01-01T00:00:00.000Z",
"dateTo": "2019-12-31T00:00:00.000Z",
"extension": "mat",
"dateFrom": "2018-10-05T00:05:00.000Z",
"dateTo": "2018-10-05T00:06:00.000Z",
}

onc.getListByLocation(params)["files"]
onc.getArchivefile(params)

# Longer method name
# onc.getArchivefileByLocation(params)

# Alias method name
# onc.getListByLocation(params)
```

## Download archived files that match the parameters

Download all "wav" files from a hydrophone at Straight of Georgia East (_locationCode_:"**SEVIP**") from the last 2
hours
Download all "mat" files from a hydrophone at Straight of Georgia East (_locationCode_:"**SEVIP**") using the parameter above.

```python
import datetime

# Get the current ISO8601 timestamp, without milliseconds
now = datetime.datetime.utcnow().replace(microsecond=0).isoformat() + ".000Z"

params = {
"locationCode": "SEVIP", # Strait of Georgia East
"deviceCategoryCode": "HYDROPHONE", # Hydrophones
"dateFrom": "-PT2H", # Minus 2 hours from dateTo
"dateTo": now,
"extension": "wav",
"deviceCategoryCode": "HYDROPHONE",
"locationCode": "SEVIP",
"extension": "mat",
"dateFrom": "2018-10-05T00:05:00.000Z",
"dateTo": "2018-10-05T00:06:00.000Z",
aschlesin marked this conversation as resolved.
Show resolved Hide resolved
}

# Download available files (will throw an exception if there are no deployments for the device during the last two hours)
onc.downloadDirectArchivefile(params)

# Alias method name
# onc.getDirectFiles(params)

```
40 changes: 35 additions & 5 deletions doc/source/Code_Examples/Request_Real_Time_Data.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ params = {
"getLatest": "true",
}

onc.getDirectByLocation(params)
onc.getScalardata(params)

# Longer method name
# onc.getScalardataByLocation(params)

# Alias method name
# onc.getDirectByLocation(params)
```

### Get 1 minute of time-series scalar data readings from a a device in a location
Expand All @@ -32,7 +38,13 @@ params = {
"dateTo": "2016-09-01T00:01:00.000Z",
}

onc.getDirectByLocation(params)
onc.getScalardata(params)

# Longer method name
# onc.getScalardataByLocation(params)

# Alias method name
# onc.getDirectByLocation(params)
```

### Get 10 seconds of raw CTD data readings from a location
Expand All @@ -45,7 +57,13 @@ params = {
"dateTo": "2017-05-23T00:00:10.000Z",
}

onc.getDirectRawByLocation(params)["data"]["readings"]
onc.getRawdata(params)["data"]["readings"]

# Longer method name
# onc.getRawdataByLocation(params)["data"]["readings"]

# Alias method name
# onc.getDirectRawByLocation(params)["data"]["readings"]
```

## [/scalardata/device](https://data.oceannetworks.ca/OpenAPI#get-/scalardata/device)
Expand All @@ -59,7 +77,13 @@ params = {
"dateTo": "2019-06-01T00:00:10.000Z",
}

onc.getDirectByDevice(params)
onc.getRawdata(params)

# Longer method name
# onc.getRawdataByDevice(params)

# Alias method name
# onc.getDirectRawByDevice(params)
```

### Get 1 minute of time-series scalar data readings from a specific device
Expand All @@ -71,5 +95,11 @@ params = {
"dateTo": "2016-09-01T00:01:00.000Z",
}

onc.getDirectByDevice(params)
onc.getScalardata(params)

# Longer method name
# onc.getScalardataByDevice(params)

# Alias method name
# onc.getDirectByDevice(params)
```