You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -11,23 +11,23 @@ The TERRA Ref program uses the BETYdb database and web application software to s
11
11
12
12
### BETYdb: database software and web application
13
13
14
+
The TERRA REF trait database (terraref.ncsa.illinois.edu/bety) uses the BETYdb data schema (structure) and web application.
14
15
The BETYdb software is actively used and developed by the [TERRA Reference](terraref.org) program as well as by the [PEcAn project](pecanproject.org).
15
16
16
17
For more information about BETYdb, see the following:
17
18
18
19
* BETYdb documentation (available via the web application under 'Docs')
19
-
*_Data Access_
20
+
*_Data Access_: how to access data
20
21
*_Data Entry Workflow:_ how to add data to the database
21
22
*_BETYdb Technical Documentation_ is written for advanced users and website and database administrators who may also be interested in the [full database schema](betydb.org/schemas)
22
23
* BETYdb: A Yield, Trait and Ecosystem Service Database Applied to Second Generation Bioenergy Feedstocks. ([LeBauer et al, 2017](dx.doi.org/10.1111/gcbb.12420))
23
24
24
-
The TERRA REF trait database (terraref.ncsa.illinois.edu/bety) uses the BETYdb data schema (structure) and web application.
25
25
There are at least a half-dozen other databases using the BETYdb software that these exercises will work with, though the results will depend on the available data.
26
26
The first, betydb.org is described in LeBauer et al, 2017.
27
27
Others are listed in the 'distributed BETYdb' section of the technical documentation.
28
28
29
-
One database, terraref.ncsa.illinois.edu/terra-test, houses a simulated dataset that is used in [lesson 1: A simulated data set](../traits/01-simulated-sorghum.Rmd)and does not require an account to access the data.
30
-
BETYdb is only designed to keep the primary data private. Metadata such as field management and experimental design are available if the url is public.
29
+
When there is a public-facing website, BETYdb is only designed to keep its trait and yield data private.
30
+
Metadata such as field management and experimental design are available if the url is public.
31
31
32
32
## Getting an account for the TERRA trait database
33
33
@@ -40,22 +40,30 @@ TODO add signup info from handout
40
40
41
41
## First steps: download data from web interface
42
42
43
-
TODO add steps to download csv from the web interface
43
+
* Point your browser to terraref.ncsa.illinois.edu/bety
44
+
* login
45
+
* enter "NDVI" in the search box
46
+
* on the next page you will see the results of this search
47
+
* if you want all of the data, including data that has not gone through QA/QC, make sure to check the 'include unchecked records' option
48
+
* in the upper right, you will see a button that will allow you to download the search results as a CSV file. Click it. Open the file in a text editor or spreadsheet program and review its contents.
44
49
45
-
Note that the web interface only provides a core set of data. More complex queries, such as those in the [Agronomic metadata](../traits/04-agronomic-metadata.Rmd)
50
+
Note that the web interface only provides a core set of data and limited meta-data. To access all of the data within BETYdb, it is necessary to search and merge multiple tables. More complex queries, such as those in the [Agronomic metadata](../traits/04-agronomic-metadata.Rmd).
46
51
47
52
## Advanced: Using URLs to construct Queries
48
53
49
54
The first step toward reproducible pipelines is to automate the process of searching the database and returning results. This is one of the key roles of an Application programming interface, or 'API'. You can learn to use the API in less than 20 minutes, starting now.
50
55
51
56
### What is an API?
52
57
53
-
An API is ...
58
+
An API is an 'Application Programming Interface'. An API is a way that you and your software can connect to and access data.
59
+
60
+
All of our databases have web interfaces for humans to browse as well as APIs that are constructed as URLs.
61
+
54
62
55
63
### Using Your API key to Connect
56
64
57
65
An API key is like a password. It allows you to access data, and should be kept private.
58
-
Therefore, we are not going to put it in code that we share. The one exception is the key 9999999999999999999999999999999999999999 that will allow you to access metadata tables (all tables except _traits_ and _yields_).
66
+
Therefore, we are not going to put it in code that we share. The one exception is the key 9999999999999999999999999999999999999999 that will allow you to access metadata tables (all tables except _traits_ and _yields_). It will also allow you to access all of the simulated data in the terraref.ncsa.illinois.edu/bety-test database.
59
67
60
68
A common way of handling private API keys is to place it in a text file in your home directory.
61
69
Don't put it in a project directory where it might be inadvertently shared.
@@ -66,9 +74,17 @@ Here is how to find and save your API key:
66
74
* copy the api key that was sent when you registered into the file
67
75
* file --> save as '~/.betykey'
68
76
69
-
Equivalently in R `r writeLines('9999999999999999999999999999999999999999', con = '~/.betykey')` or at the command line `sh echo 9999999999999999999999999999999999999999 > ~/.betykey`
77
+
For the public key, you can call this file `~/.betykey_public`.
78
+
79
+
### Components of a URL query
80
+
81
+
82
+
* base url: `terraref.ncsa.illinois.edu/bety`
83
+
* path to the api: `/api/beta`
84
+
* api endpoint: `/search` or `traits` or `sites`. For BETYdb, these are the names of database tables.
85
+
* Query parameters: `genus=Sorghum`
86
+
* Authentication: `key=9999999999999999999999999999999999999999` is the public key for the TERRA REF traits database.
70
87
71
-
For the purposes of the tutorial, you can assign it to the `betykey` variable in the console window.
72
88
73
89
### Constructing a URL query
74
90
@@ -86,27 +102,68 @@ First, lets construct a query by putting together a URL.
86
102
*`name=~height` where the variable name contains 'height'
## Using the R traits package to query the database
97
153
98
154
The rOpenSci traits package makes it easier to query the TERRA REF trait database, or any database that uses BETYdb software.
99
155
100
-
First, make sure we have the latest version
156
+
First, make sure we have the latest version from the terraref fork of the repository on github. (you can install using the standard `install.packages('traits')` but I can't promise everything will work.
157
+
158
+
### Install the package
101
159
102
160
```{r install_traits, echo=FALSE}
103
-
if(packageVersion("traits") == '0.2.0'){
104
-
devtools::install_github('ropensci/traits')
105
-
}
161
+
devtools::install_github('terraref/traits')
106
162
```
107
163
164
+
Now, we can load the packages that we will need to get started.
0 commit comments