Skip to content

Commit de71a58

Browse files
committed
updated traits tutorials
1 parent 97358ec commit de71a58

4 files changed

Lines changed: 33 additions & 23 deletions

File tree

index.Rmd

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,8 @@ output:
99
bookdown::pdf_book: default
1010
---
1111

12-
# Preamble
12+
# Preamble
13+
14+
```{r}
15+
knitr::opts_chunk$set(echo = FALSE, cache = TRUE)
16+
```
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Command Line Hyperspectral Workflow
22

33
```{r}
4-
include_url("https://docs.google.com/document/d/1QWBUHsRql_c_q15WoFrUGRMGk0gZQ-y85y6tpd9pdNM/pub")
4+
knitr::include_url("https://docs.google.com/document/d/1QWBUHsRql_c_q15WoFrUGRMGk0gZQ-y85y6tpd9pdNM/pub")
55
```

traits/00-BETYdb-getting-started.Rmd

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -127,32 +127,42 @@ writeLines('9999999999999999999999999999999999999999',
127127
con = '~/.betykey_public')
128128
```
129129
```{r traits}
130-
terraref_test_url <- "https://terraref.ncsa.illinois.edu/bety-test/"
131-
132-
betykey <- readLines('~/.betykey_public', warn = FALSE)
130+
terraref_test_url <-
131+
public_betykey <-
133132
134133
```
135134

135+
### Our first Query
136+
136137
```{r simulated-LAI}
137138
sorghum_lai <- betydb_query(table = 'search',
138139
trait = "LAI",
139140
api_version = 'beta',
140141
limit = 5000,
141-
betyurl = terraref_test_url,
142-
key = betykey)
142+
betyurl = "https://terraref.ncsa.illinois.edu/bety-test/",
143+
key = readLines('~/.betykey_public', warn = FALSE))
143144
144-
#traits <- betydb_query(table = "traits",
145-
# api_version = 'beta',
146-
# limit = 5000,
147-
# betyurl = terraref_test_url,
148-
# key = betykey)
145+
```
149146

147+
Notice all of the arguments? We can change this by setting the default options
150148

151149

150+
```{r}
151+
options(betydb_key = readLines('~/.betykey_public', warn = FALSE),
152+
betydb_url = "https://terraref.ncsa.illinois.edu/bety-test/",
153+
betydb_api_version = 'beta')
152154
```
153155

154-
```{r}
156+
Now the same query can be reduced to:
155157

158+
```{r eval=FALSE}
159+
sorghum_lai <- betydb_query(table = 'search',
160+
trait = "LAI",
161+
limit = 5000)
162+
```
163+
164+
165+
```{r}
156166
ggplot(data = sorghum_lai) +
157167
geom_smooth(aes(x = lubridate::yday(lubridate::ymd_hms(raw_date)), y = mean, color = as.factor(lubridate::year(lubridate::ymd_hms(raw_date)))), span = 0.5) +
158168
# scale_x_datetime(date_breaks = '6 months', date_labels = "%b %Y") +

traits/01-simulated-sorghum.Rmd

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -140,17 +140,13 @@ The virtual crop is encoded as a set of associated species and prior estimates o
140140

141141

142142
```{r}
143-
terraref_test_url <- "https://terraref.ncsa.illinois.edu/bety-test/"
144-
## note that this key accesses public data. In part 2 you will use your own key to access the actual data
145143
146-
public_key <- "9999999999999999999999999999999999999999"
144+
options(betydb_key = readLines('~/.betykey_public', warn = FALSE),
145+
betydb_url = "https://terraref.ncsa.illinois.edu/bety-test/",
146+
betydb_api_version = 'beta')
147147
148-
149-
SLA <- (betydb_search(query = "SLA",
150-
betyurl = terraref_test_url,
151-
key = public_key,
152-
api_version = "beta")
153-
%>% filter(scientificname == 'Sorghum bicolor'))
148+
sorghum_lai <- betydb_query(trait = "LAI",
149+
api_version = 'beta')
154150
155151
```
156152

@@ -159,7 +155,7 @@ Now we have queried all of the Specific Leaf Area records, we can see that these
159155

160156

161157
```{r sla-fig, fig.height=2, fig.width=6}
162-
ggplot(SLA) +
158+
ggplot(sorghum_lai) +
163159
geom_histogram(aes(mean), binwidth = 1)
164160
```
165161

0 commit comments

Comments
 (0)