Skip to content

Commit 93e2dd1

Browse files
authored
Merge pull request #49 from OceanNetworksCanada/update-example
doc: update example with new method names, improve downloadDirectArch…
2 parents ef48319 + 12b6d57 commit 93e2dd1

File tree

3 files changed

+89
-31
lines changed

3 files changed

+89
-31
lines changed

doc/source/Code_Examples/Discover_Locations.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ onc.getLocations(params)
8787

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

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

9393
```python
@@ -158,5 +158,8 @@ Return the location hierarchy from the "**MOBP**" ("Mobile Platforms") node and
158158
params = {
159159
"locationCode": "MOBP",
160160
}
161-
onc.getLocationHierarchy(params)
161+
onc.getLocationsTree(params)
162+
163+
# Alias method name
164+
# onc.getLocationHierarchy(params)
162165
```

doc/source/Code_Examples/Download_Archived_Files.md

Lines changed: 49 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,13 @@ params = {
2020
"dateTo": "2019-06-08T00:00:00.000Z",
2121
}
2222

23-
onc.getListByDevice(params)
23+
onc.getArchivefile(params)
24+
25+
# Longer method name
26+
# onc.getArchivefileByDevice(params)
27+
28+
# Alias method name
29+
# onc.getListByDevice(params)
2430
```
2531

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

39-
onc.getListByDevice(params)
45+
onc.getArchivefile(params)
46+
47+
# Longer method name
48+
# onc.getArchivefileByDevice(params)
49+
50+
# Alias method name
51+
# onc.getListByDevice(params)
4052
```
4153

4254
### Download a file by its filename
4355

4456
```python
45-
onc.getFile("RDIADCP600WH25471_20190607T120000.555Z.rdi", overwrite=True)
57+
58+
onc.downloadArchivefile("ICLISTENHF1560_20181005T000403.000Z-spect.mat", overwrite=True)
59+
60+
# Alias method name
61+
# onc.getFile("ICLISTENHF1560_20181005T000403.000Z-spect.mat", overwrite=True)
4662
```
4763

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

63-
onc.getListByLocation(params)["files"]
79+
onc.getArchivefile(params)
80+
81+
# Longer method name
82+
# onc.getArchivefileByLocation(params)
83+
84+
# Alias method name
85+
# onc.getListByLocation(params)
6486
```
6587

6688
### 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
6789

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

7193
```python
7294
params = {
7395
"deviceCategoryCode": "HYDROPHONE",
7496
"locationCode": "SEVIP",
75-
"extension": "wav",
76-
"dateFrom": "2017-01-01T00:00:00.000Z",
77-
"dateTo": "2019-12-31T00:00:00.000Z",
97+
"extension": "mat",
98+
"dateFrom": "2018-10-05T00:05:00.000Z",
99+
"dateTo": "2018-10-05T00:06:00.000Z",
78100
}
79101

80-
onc.getListByLocation(params)["files"]
102+
onc.getArchivefile(params)
103+
104+
# Longer method name
105+
# onc.getArchivefileByLocation(params)
106+
107+
# Alias method name
108+
# onc.getListByLocation(params)
81109
```
82110

83111
## Download archived files that match the parameters
84112

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

88115
```python
89-
import datetime
90-
91-
# Get the current ISO8601 timestamp, without milliseconds
92-
now = datetime.datetime.utcnow().replace(microsecond=0).isoformat() + ".000Z"
93-
94116
params = {
95-
"locationCode": "SEVIP", # Strait of Georgia East
96-
"deviceCategoryCode": "HYDROPHONE", # Hydrophones
97-
"dateFrom": "-PT2H", # Minus 2 hours from dateTo
98-
"dateTo": now,
99-
"extension": "wav",
117+
"deviceCategoryCode": "HYDROPHONE",
118+
"locationCode": "SEVIP",
119+
"extension": "mat",
120+
"dateFrom": "2018-10-05T00:05:00.000Z",
121+
"dateTo": "2018-10-05T00:06:00.000Z",
100122
}
101123

102-
# Download available files (will throw an exception if there are no deployments for the device during the last two hours)
124+
onc.downloadDirectArchivefile(params)
125+
126+
# Alias method name
103127
# onc.getDirectFiles(params)
128+
104129
```

doc/source/Code_Examples/Request_Real_Time_Data.md

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@ params = {
1919
"getLatest": "true",
2020
}
2121

22-
onc.getDirectByLocation(params)
22+
onc.getScalardata(params)
23+
24+
# Longer method name
25+
# onc.getScalardataByLocation(params)
26+
27+
# Alias method name
28+
# onc.getDirectByLocation(params)
2329
```
2430

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

35-
onc.getDirectByLocation(params)
41+
onc.getScalardata(params)
42+
43+
# Longer method name
44+
# onc.getScalardataByLocation(params)
45+
46+
# Alias method name
47+
# onc.getDirectByLocation(params)
3648
```
3749

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

48-
onc.getDirectRawByLocation(params)["data"]["readings"]
60+
onc.getRawdata(params)["data"]["readings"]
61+
62+
# Longer method name
63+
# onc.getRawdataByLocation(params)["data"]["readings"]
64+
65+
# Alias method name
66+
# onc.getDirectRawByLocation(params)["data"]["readings"]
4967
```
5068

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

62-
onc.getDirectByDevice(params)
80+
onc.getRawdata(params)
81+
82+
# Longer method name
83+
# onc.getRawdataByDevice(params)
84+
85+
# Alias method name
86+
# onc.getDirectRawByDevice(params)
6387
```
6488

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

74-
onc.getDirectByDevice(params)
98+
onc.getScalardata(params)
99+
100+
# Longer method name
101+
# onc.getScalardataByDevice(params)
102+
103+
# Alias method name
104+
# onc.getDirectByDevice(params)
75105
```

0 commit comments

Comments
 (0)