Skip to content

Commit c0b8f82

Browse files
Merge pull request #87 from terraref/image_tutorial2
minor updates to image tutorial
2 parents 8f1c01a + 608155c commit c0b8f82

1 file changed

Lines changed: 25 additions & 5 deletions

File tree

sensors/06-list-datasets-by-plot.Rmd

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,21 @@ The terrautils python package has a new `products` module that aids in connectin
1010
plot boundaries stored within betydb with the file-based data products available
1111
from the workbench or Globus.
1212

13+
* if are using Rstudio and want to run the Python code chunks, the R package "reticulate" is required
14+
* use `pip3 install terrautils` to install the terrautils Python library
15+
1316
## Getting started
1417

1518
After installing terrautils, you should be able to import the `products` module.
16-
```{python eval=FALSE}
19+
```{python}
1720
from terrautils.products import get_sensor_list, unique_sensor_names
1821
from terrautils.products import get_file_listing, extract_file_paths
1922
```
2023

2124
The `get_sensor_list` and `get_file_listing` functions both require the *connection*,
2225
*url*, and *key* parameters. The *connection* can be 'None'. The *url* (called host in the
2326
code) should be something like `https://terraref.ncsa.illinois.edu/clowder/`.
24-
The *key* is a unique access key for the Clowder api.
27+
The *key* is a unique access key for the Clowder API.
2528

2629
## Getting the sensor list
2730

@@ -32,11 +35,21 @@ a plot id number. The utility function `unique_sensor_names` accpets the
3235
sensor list and provides a list of names suitable for use in the
3336
`get_file_listing` function.
3437

35-
```{python eval=FALSE}
38+
To use this tutorial you will need to sign up for Clowder, have your
39+
account approved, and then get an API key from the [Clowder web interface](https://terraref.ncsa.illinois.edu/clowder).
40+
41+
```{python}
42+
url = 'https://terraref.ncsa.illinois.edu/clowder/'
43+
key = 'ENTER YOUR KEY HERE'
44+
```
45+
46+
```{python}
3647
sensors = get_sensor_list(None, url, key)
3748
names = unique_sensor_names(sensors)
49+
print(names)
3850
```
3951

52+
4053
Names will now contain a list of sensor names available in the Clowder
4154
geostreams API. The list of returned sensor names could be something like the
4255
following:
@@ -55,9 +68,10 @@ The geostreams API can be used to get a list of datasets that overlap a
5568
specific plot boundary and, optionally, limited by a time range. Iterating
5669
over the datasets allows the paths to all the files to be extracted.
5770

58-
```{python eval=FALSE}
71+
```{python eval = FALSE}
5972
sensor = 'Thermal IR GeoTIFFs Datasets'
6073
sitename = 'MAC Field Scanner Season 1 Field Plot 101 W'
74+
key = 'INSERT YOUR KEY HERE'
6175
datasets = get_file_listing(None, url, key, sensor, sitename)
6276
files = extract_file_paths(datasets)
6377
```
@@ -73,6 +87,10 @@ dataset = get_file_listing(None, url, key, sensor, sitename,
7387

7488
# Querying the API
7589

90+
<!--
91+
TODO: move this to a separate tutorial page focused on using curl
92+
-->
93+
7694
The source files behind the data are available for downloading through the API. By executing a series
7795
of requests against the API it's possible to determine the files of interest and then download them.
7896

@@ -82,7 +100,7 @@ to see how then end of the URL changes depending upon the reuqest.
82100

83101
Below is what the API looks like as a URL. Try pasting it into your browser.
84102

85-
https://terraref.ncsa.illinois.edu/clowder/api/geostreams/sensors?sensor_name=MAC Field Scanner Season 1 Field Plot 101 W
103+
[https://terraref.ncsa.illinois.edu/clowder/api/geostreams/sensors?sensor_name=MAC Field Scanner Season 1 Field Plot 101 W](https://terraref.ncsa.illinois.edu/clowder/api/geostreams/sensors?sensor_name=MAC Field Scanner Season 1 Field Plot 101 W)
86104

87105
This will return data for the requested plot including its id. This id (or identifier) can then be used for
88106
additional queries against the API.
@@ -93,6 +111,8 @@ to retrieve its data.
93111

94112
## A Word of Caution
95113

114+
We are no longer using the python terrautils package, which is a python library that provides helper functions that simplify interactions with the Clowder API. One of the ways it makes the interface easier is by using function names that make sense in the scope of the project. The API and the Clowder database have different names and _this is confusing_ since the same names are used for different parts of the database.
115+
96116
The names and meanings of variables in this section don't necessarily match the ones in the section
97117
above and it may be easy to get them confused. The API queries the database directly and thereby reflects
98118
the database structure. This is the main reason for the naming differences between the API and the terraref

0 commit comments

Comments
 (0)