Skip to content

Commit 7db56a9

Browse files
authored
Merge pull request #27 from terraref/dlebauer-patch-2
minor updates to listing datasets
2 parents 733bb34 + 30ddc40 commit 7db56a9

1 file changed

Lines changed: 24 additions & 13 deletions

File tree

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,26 @@ from the workbench or Globus.
77
## Getting started
88

99
After installing terrautils, you should be able to import the *product* module.
10-
```
10+
```{python}
1111
from terrautils.products import get_sensor_list, unique_sensor_names
1212
from terrautils.products import get_file_listing, extract_file_paths
1313
```
1414

15-
The get\_sensor\_list and get\_file\_listing both require connection, url,
15+
The `get_sensor_list` and `get_file_listing` functions both require connection, url,
1616
and key parameters. *Connection* can be 'None', the *url* (called host in the
1717
code) should be something like https://terraref.ncsa.illinois.edu/clowder/.
1818
The *key* is a unique access key for the Clowder api.
1919

2020
## Getting the sensor list
21+
2122
The first thing to get is the sensor name. This can be retreived using the
22-
get\_sensor\_list function. This function returns the full record which may
23+
`get_sensor_list` function. This function returns the full record which may
2324
be useful in some cases but primarily includes sensor names that include
24-
a plot id number. The utility function unique_sensor_names accpets the
25+
a plot id number. The utility function `unique_sensor_names` accpets the
2526
sensor list and provides a list of names suitable for use in the
26-
get_file_listing function.
27+
`get_file_listing` function.
2728

28-
```
29+
```{python}
2930
sensors = get_sensor_list(None, url, key)
3031
names = unique_sensor_names(sensors)
3132
```
@@ -36,16 +37,16 @@ geostreams API. The currently available sensors are:
3637
* IR Surface Temperature
3738
* Thermal IR GeoTIFFs Datasets
3839
* flirIrCamera Datasets
39-
* (EL) sensor\_weather\_station
40+
* (EL) sensor_weather_station
4041
* Irrigation Observations
4142
* Canopy Cover
4243
* Energy Farm Observations SE
43-
* (EL) sensor\_par
44+
* (EL) sensor_par
4445
* scanner3DTop Datasets
4546
* Weather Observations
4647
* Energy Farm Observations NE
4748
* RGB GeoTIFFs Datasets
48-
* (EL) sensor\_co2
49+
* (EL) sensor_co2
4950
* stereoTop Datasets
5051
* Energy Farm Observations CEN
5152

@@ -55,28 +56,30 @@ The geostreams API can be used to get a list of datasets that overlap a
5556
specific plot boundary and, optionally, limited by a time range. Iterating
5657
over the datasets allows the paths to all the files to be extracted.
5758

58-
```
59+
```{python}
5960
sensor = 'Thermal IR GeoTIFFs Datasets'
6061
sitename = 'MAC Field Scanner Season 1 Field Plot 101 W'
6162
datasets = get_file_listing(None, url, key, sensor, sitename)
6263
files = extract_file_paths(datasets)
6364
```
6465

6566
Datasets can be further filtered using the *since* and *until* parameters
66-
of get\_file\_listing with a date string.
67+
of `get_file_listing` with a date string.
6768

68-
```
69+
```{python}
6970
dataset = get_file_listing(None, url, key, sensor, sitename,
7071
since='2016-06-01', until='2016-06-10')
7172
```
7273

7374

7475
# Alternative method
76+
7577
The following method demonstrates the same approach using the Clowder API. This
7678
approach is useful for understanding the data layout and when the Python
7779
terrautils package is not available.
7880

7981
## Finding plot ID
82+
8083
```
8184
SENSOR_NAME = "MAC Field Scanner Season 1 Field Plot 101 W"
8285
GET https://terraref.ncsa.illinois.edu/clowder/api/geostreams/sensors?sensor_name={SENSOR_NAME}
@@ -85,7 +88,9 @@ GET https://terraref.ncsa.illinois.edu/clowder/api/geostreams/sensors?sensor_nam
8588
This returns a JSON object with an 'id' parameter. You can use this ID parameter to specify the right data stream.
8689

8790
## Finding stream ID within a plot
91+
8892
The names are formatted as "<Sensor Group> Datasets (<Sensor ID>)".
93+
8994
```
9095
SENSOR_ID = 3355
9196
STREAM_NAME = "Thermal IR GeoTIFFs Datasets ({SENSOR_ID})"
@@ -95,13 +100,15 @@ GET https://terraref.ncsa.illinois.edu/clowder/api/geostreams/streams?stream_nam
95100
This returns a JSON object with an 'id' parameter. You can use this ID parameter to get the right datapoints.
96101

97102
## Listing Clowder file IDs for that plot & sensor stream
103+
98104
```
99105
STREAM_ID = "11586"
100106
GET https://terraref.ncsa.illinois.edu/clowder/api/geostreams/datapoints?stream_id={STREAM_ID}
101107
```
102108

103109
This returns a list of datapoint JSON objects, each with a 'properties' parameter that looks like:
104-
```
110+
111+
```{python}
105112
properties: {
106113
dataset_name: "Thermal IR GeoTIFFs - 2016-05-09__12-07-57-990",
107114
source_dataset: "https://terraref.ncsa.illinois.edu/clowder/datasets/59fc9e7d4f0c3383c73d2905"
@@ -111,19 +118,23 @@ properties: {
111118
The source_dataset URL can be used to view the dataset in Clowder.
112119

113120
You can also filter the datapoints by date:
121+
114122
```
115123
GET https://terraref.ncsa.illinois.edu/clowder/api/geostreams/datapoints?stream_id={STREAM_ID}&since=2017-01-02&until=2017-06-10
116124
```
117125

118126
## Getting ROGER file path from dataset
127+
119128
Given a source dataset URL, we can call the API to get the files and their paths.
129+
120130
```
121131
SOURCE_DATASET = "https://terraref.ncsa.illinois.edu/clowder/datasets/59fc9e7d4f0c3383c73d2905"
122132
# Add /api after /clowder, and add /files at the end of the URL
123133
GET "https://terraref.ncsa.illinois.edu/clowder/api/datasets/59fc9e7d4f0c3383c73d2905/files"
124134
```
125135

126136
This returns a list of files in the dataset and their paths if available:
137+
127138
```
128139
[
129140
{

0 commit comments

Comments
 (0)