Skip to content

Commit 95b42c9

Browse files
authored
begin updating synthesis vignette
starting to resolve #121
1 parent c7a4f0e commit 95b42c9

1 file changed

Lines changed: 29 additions & 11 deletions

File tree

vignettes/04-synthesis-data.Rmd

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ The second analysis compares greenness from image data with canopy cover.
99
## Get and join data
1010

1111
Here we combine two dataframes.
12-
The first contains all the canopy height values for 2017, which was created in the traits vignette.
13-
The second is the cumulative growing degree days for all of 2017, which were calculated from the daily minimum and maximum temperatures in the weather vignette.
12+
The first contains all the canopy cover values for 2018, which was created in the traits vignette.
13+
The second is the cumulative growing degree days for all of 2018, which were calculated from the daily minimum and maximum temperatures in the weather vignette.
1414
They are combined by their common column, the date.
1515

1616
```{r synth_setup}
@@ -19,24 +19,23 @@ library(ggplot2)
1919
library(jsonlite)
2020
library(lubridate)
2121
library(traits)
22-
library(inflection)
2322
library(sf)
2423
library(stringr)
2524
options(betydb_url = "https://terraref.ncsa.illinois.edu/bety/",
2625
betydb_api_version = 'v1')
2726
```
2827

2928
```{r get_trait_data, message = FALSE}
30-
trait_canopy_height <- betydb_query(table = "search",
31-
trait = "canopy_height",
32-
date = "~2017",
29+
trait_canopy_cover <- betydb_query(table = "search",
30+
trait = "canopy_cover",
31+
date = "~2018",
3332
limit = "none")
34-
trait_canopy_height_day = trait_canopy_height %>%
33+
trait_canopy_cover_day = trait_canopy_cover %>%
3534
mutate(day = as.Date(raw_date))
3635
```
3736

3837
```{r get_weather_data}
39-
weather <- fromJSON('https://terraref.ncsa.illinois.edu/clowder/api/geostreams/datapoints?stream_id=46431&since=2017-01-01&until=2017-12-31', flatten = FALSE)
38+
weather <- fromJSON('https://terraref.ncsa.illinois.edu/clowder/api/geostreams/datapoints?stream_id=46431&since=2018-01-01&until=2018-12-31', flatten = FALSE)
4039
weather <- weather$properties %>%
4140
mutate(time = ymd_hms(weather$end_time))
4241
daily_values = weather %>%
@@ -52,7 +51,7 @@ daily_values <- daily_values %>%
5251
```
5352

5453
```{r combine_trait_weather}
55-
trait_weather_df <- full_join(trait_canopy_height_day, daily_values, by = "day") %>%
54+
trait_weather_df <- full_join(trait_canopy_cover_day, daily_values, by = "day") %>%
5655
select(day, cultivar, mean, gdd_cum) %>%
5756
na.omit()
5857
```
@@ -62,8 +61,27 @@ trait_weather_df <- full_join(trait_canopy_height_day, daily_values, by = "day")
6261
We are interested in how growing degree days affects canopy cover.
6362
To investigate this, we are going to model and plot their relationship.
6463
We want to know the relationship for each cultivar, so we'll start of by determining the parameters of the model for one of the cultivars in our dataset.
65-
We are using a logistic growth model here because it is appropriate for the shape of the GDD-cover relationship.
64+
We are using a logistic growth model here because it is appropriate for the shape of the GDD-cover relationship. (From Bolker? ... need to cite)
65+
66+
This needs to be flushed out ... and the variable names should be consistent b/w equations and code
67+
68+
The logistic growth model is specified as
69+
70+
$Y=\frac{z}{1+e^{-k(t-t_0)}}$
71+
72+
$Y = \frac{c}{1+e^{a + b * \textrm{gdd}}}$
73+
74+
Where $Y$ is canopy cover, $c$ is the maximum canopy cover, $a$ is ... $b$ is ...
75+
76+
From this we can find the asymptote and maximum growth rate. The maximum growth rate is the change in canopy cover per day at the rate of maximum growth. The growing degree day at which maximum growth is obtained is called the _inflection point_ $\textrm{gdd}_i=\frac{\log{a}}{b}$.
77+
<!--
78+
or maybe start from the bolker form of the model (I added )
79+
if $Y=\frac{e^{a+b(t-t_0)}}{1+e^{a+b(t-t_0)}}$
80+
81+
then $t-t_0$ is the number of days after planting.
6682
83+
then the inflection point is at $x=\frac{-a}{b}$ and the maximum rate of growth, $\max{\frac{dY}{dt}}=\frac{b}{4}$
84+
-->
6785
```{r model_get_parameters}
6886
single_cultivar <- trait_weather_df %>%
6987
filter(cultivar == "PI656026")
@@ -129,7 +147,7 @@ ggplot(data.frame(inf_points = unique(all_cultivars$inf_point))) +
129147

130148
In this examnple we will extract our plot data from a series of images taken in May of Season 6, measure its "greeness" annd plot that against the plant heights from above in this vignette.
131149

132-
The chosen statistic here is the normalised green-red difference index, NGRDI=(R-G)/(R+G) (Rasmussen et al., 2016), which uses the red and green bands from the image raster.
150+
The chosen statistic here is the normalised green-red difference index, $\textrm{NGRDI}=\frac{R-G}/{R+G}$ (Rasmussen et al., 2016), which uses the red and green bands from the image raster.
133151

134152
Below we retrieve all the available plots for a particular date, then find and convert the plot boundary JSON into tuples.
135153
We will use these tuples to extract the data for our plot.

0 commit comments

Comments
 (0)