|
1 | 1 | # Generating file lists by plot |
2 | 2 |
|
| 3 | +The terrautils python package has a new products module that aid in connecting |
| 4 | +plot boundaries stored within betydb with file-based data products available |
| 5 | +from the workbench or Globus. |
| 6 | + |
| 7 | +## Getting started |
| 8 | + |
| 9 | +After installing terrautils, you should be able to import the *product* module. |
| 10 | +``` |
| 11 | +from terrautils.products import get_sensor_list, unique_sensor_names |
| 12 | +from terrautils.products import get_file_listing, extract_file_paths |
| 13 | +``` |
| 14 | + |
| 15 | +The get\_sensor\_list and get\_file\_listing both require connection, url, |
| 16 | +and key parameters. *Connection* can be 'None', the *url* (called host in the |
| 17 | +code) should be something like https://terraref.ncsa.illinois.edu/clowder/. |
| 18 | +The *key* is a unique access key for the Clowder api. |
| 19 | + |
| 20 | +## Getting the sensor list |
| 21 | +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 | +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 | +sensor list and provides a list of names suitable for use in the |
| 26 | +get_file_listing function. |
| 27 | + |
| 28 | +``` |
| 29 | +sensors = get_sensor_list(None, url, key) |
| 30 | +names = unique_sensor_names(sensors) |
| 31 | +``` |
| 32 | + |
| 33 | +Names will now contain a list of sensor names available in the Clowder |
| 34 | +geostreams API. The currently available sensors are: |
| 35 | + |
| 36 | +* IR Surface Temperature |
| 37 | +* Thermal IR GeoTIFFs Datasets |
| 38 | +* flirIrCamera Datasets |
| 39 | +* (EL) sensor\_weather\_station |
| 40 | +* Irrigation Observations |
| 41 | +* Canopy Cover |
| 42 | +* Energy Farm Observations SE |
| 43 | +* (EL) sensor\_par |
| 44 | +* scanner3DTop Datasets |
| 45 | +* Weather Observations |
| 46 | +* Energy Farm Observations NE |
| 47 | +* RGB GeoTIFFs Datasets |
| 48 | +* (EL) sensor\_co2 |
| 49 | +* stereoTop Datasets |
| 50 | +* Energy Farm Observations CEN |
| 51 | + |
| 52 | +## Getting a list of files |
| 53 | + |
| 54 | +The geostreams API can be used to get a list of datasets that overlap a |
| 55 | +specific plot boundary and, optionally, limited by a time range. Iterating |
| 56 | +over the datasets allows the paths to all the files to be extracted. |
| 57 | + |
| 58 | +``` |
| 59 | +sensor = 'Thermal IR GeoTIFFs Datasets' |
| 60 | +sitename = 'MAC Field Scanner Season 1 Field Plot 101 W' |
| 61 | +datasets = get_file_listing(None, url, key, sensor, sitename) |
| 62 | +files = extract_file_paths(datasets) |
| 63 | +``` |
| 64 | + |
| 65 | +Datasets can be further filtered using the *since* and *until* parameters |
| 66 | +of get\_file\_listing with a date string. |
| 67 | + |
| 68 | +``` |
| 69 | +dataset = get_file_listing(None, url, key, sensor, sitename, |
| 70 | + since='2016-06-01', until='2016-06-10') |
| 71 | +``` |
| 72 | + |
| 73 | + |
| 74 | +# Alternative method |
| 75 | +The following method demonstrates the same approach using the Clowder API. This |
| 76 | +approach is useful for understanding the data layout and when the Python |
| 77 | +terrautils package is not available. |
| 78 | + |
3 | 79 | ## Finding plot ID |
4 | 80 | ``` |
5 | 81 | SENSOR_NAME = "MAC Field Scanner Season 1 Field Plot 101 W" |
|
0 commit comments