Nowosad / pollen

Tools for working with aerobiological data
https://nowosad.github.io/pollen/
Other
3 stars 2 forks source link

calculate base temp #11

Closed cperk closed 2 years ago

cperk commented 3 years ago

Hello!

I just discovered your gdd (growing degree days) vignette and wonder if you have plans to add the capability of determining tbase for species in which a base temperature is not yet established?

Some of the methods used to calculate tbase include (1) the least standard deviation in GDD (Magoon and Culpepper, 1932; Stier, 1939); (2) the least standard deviation in days (Arnold, 1959); (3) the coefficient of variation in days (Nuttonson, 1958); (4) the regression coefficient (Hoover, 1955):

https://www.sciencedirect.com/science/article/abs/pii/016819239402185M

It would be amazing if your package had these calculations built-in.

Thanks!

-Carrie

Nowosad commented 3 years ago

Hi @cperk !

Thanks for this message.

Yes - I could (and I already did) add this to the pollen package. There is a new function called base_temp(), which accepts three arguments:

You can install the development version from GitHub:

remotes::install_github("nowosad/pollen")

Now, could I ask you for two things: 1. could you prepare some simple example data that I could use in the example section? 2. could you try the code and let me know if it works as expected?

Thanks!

Best, Jakub

Nowosad commented 2 years ago

Hi @cperk -- have you got a chance to check the new code?

cperk commented 2 years ago

Hi Jakub,

That's great news! I'm happy to help, but first need some more clarification. Is tavg the mean temperature on each day of the season, or the overall mean for the entire season for that planting?

I also don't understand what d is; is it the total number of days in the growing season or the number of days until first flower?

My data is field data rather than experiment data; so for me I guess the ith planting would be the ith sampling site?

Thanks!

-Carrie

On Sun, Nov 7, 2021 at 11:17 AM Jakub Nowosad @.***> wrote:

Hi @cperk https://github.com/cperk -- have you got a chance to check the new code?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Nowosad/pollen/issues/11#issuecomment-962639388, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFCT4K27OCSH4CRYAV6MILDUK2RC7ANCNFSM5GSNJOKQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

Nowosad commented 2 years ago

Hi Carrie (@cperk),

cperk commented 2 years ago

Hi Jakub,

Here is an attempt at a toy example for your vignette, although it seems to need some tweaking (the code works for my real data but with the toy dataset I made I get some strange results from base_temp).

##toy example with pollen dataset
data("gdd_data", package = "pollen")
head(gdd_data)
str(gdd_data)

#add pretend flower counts for 4 sites to this dataset

gdd_data$flowering1 <- c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1:45, 44:0)
gdd_data$flowering2 <- c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0,0,0,0,1:40, 44:0)
gdd_data$flowering3 <- c(0, 0, 0, 0, 0, 1:50, 44:0)
gdd_data$flowering4 <- c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0,0,0,0,0,0,0,0,0,1:35, 44:0)

#convert from wide to long
require(reshape2)
gdd_datam <- melt(gdd_data, id=c("day", "tmax","tmin"))

#rename columns
colnames(gdd_datam)[colnames(gdd_datam) == 'variable'] <- 'site'
colnames(gdd_datam)[colnames(gdd_datam) == 'value'] <- 'n_flowers'

#mean of max daily temp
mean_of_max_toy <- gdd_datam %>%
  group_by(site) %>%
  summarise(mofmax = mean(tmax,na.rm = TRUE))

#only look at rows where there was at least 1 flower
gdd_data_firstflower_toy <- subset(gdd_datam,gdd_datam$n_flowers>0)

#find first day that each site had at least 1 flower (this is the phenological event, i.e. number of days until first flower)
first_flower_per_site_toy <- gdd_data_firstflower_toy %>%
  group_by(site) %>%
  summarise(mindate = min(day,na.rm = TRUE))

#merge average temp data with first flowering date data
head(first_flower_per_site_toy)
first_flower_plus_temp_toy <- merge(mean_of_max_toy,first_flower_per_site_toy, by=c("site"),all.y=TRUE)

#find base_temp for gdd
#"sd_gdd", "sd_day", "cv_day", or "y_i"
base_temp(tavg = first_flower_plus_temp_toy$mofmax, d=first_flower_plus_temp_toy$mindate, type = "sd_gdd")
base_temp(tavg = first_flower_plus_temp_toy$mofmax, d=first_flower_plus_temp_toy$mindate, type = "sd_day")
base_temp(tavg = first_flower_plus_temp_toy$mofmax, d=first_flower_plus_temp_toy$mindate, type = "cv_day")
base_temp(tavg = first_flower_plus_temp_toy$mofmax, d=first_flower_plus_temp_toy$mindate, type = "y_i")

I do have another question, and that is in the case of using days until first flower for the phenological event, what does tbase really represent? The minimum temperature needed for flowering, or the minimum temperature needed for the plant to grow vegetatively (which allows it to get big enough to produce a flower)?

Nowosad commented 2 years ago

Hi Carrie, correct me if I am wrong, but your tiny example could not be the most suitable to test this idea, as it has always the same tavg (22.82) and varies only in d (from 6 to 21). Therefore, I created even smaller example:

library(pollen)
tavg = c(25, 20, 15, 10)
d = c(6, 11, 16, 21)
base_temp(tavg = tavg, d = d, type = "sd_gdd")
#> [1] 4
base_temp(tavg = tavg, d = d, type = "sd_day")
#> [1] 10.00926
base_temp(tavg = tavg, d = d, type = "cv_day")
#> [1] 2.211921
base_temp(tavg = tavg, d = d, type = "y_i")
#> [1] 4

I do have another question, and that is in the case of using days until first flower for the phenological event, what does tbase really represent? The minimum temperature needed for flowering, or the minimum temperature needed for the plant to grow vegetatively (which allows it to get big enough to produce a flower)?

I am not a biologist, but my understanding is that the second is true. tbase is often called a "minimum development threshold".

Finally, I also improved the documentation and added some tests to the code. Let me know if you are happy with it - if so, I will submit the new version to CRAN soon.

cperk commented 2 years ago

Thanks!

I'm getting slightly warmer temperatures for tbase than I would have expected, which is why I wanted to confirm that it is intended to be the minimum development threshold. Could that be because I don't have daily temperatures for the full year (I just have them for the growing season)? Is there anything you could add to the list of arguments to base_temp() that would help account for that?

On Sat, Nov 27, 2021 at 10:38 AM Jakub Nowosad @.***> wrote:

Hi Carrie, correct me if I am wrong, but your tiny example could not be the most suitable to test this idea, as it has always the same tavg (22.82) and varies only in d (from 6 to 21). Therefore, I created even smaller example:

library(pollen)tavg = c(25, 20, 15, 10)d = c(6, 11, 16, 21) base_temp(tavg = tavg, d = d, type = "sd_gdd")#> [1] 4 base_temp(tavg = tavg, d = d, type = "sd_day")#> [1] 10.00926 base_temp(tavg = tavg, d = d, type = "cv_day")#> [1] 2.211921 base_temp(tavg = tavg, d = d, type = "y_i")#> [1] 4

I do have another question, and that is in the case of using days until first flower for the phenological event, what does tbase really represent? The minimum temperature needed for flowering, or the minimum temperature needed for the plant to grow vegetatively (which allows it to get big enough to produce a flower)?

I am not a biologist, but my understanding is that the second is true. tbase is often called a "minimum development threshold".

Finally, I also improved the documentation and added some tests to the code. Let me know if you are happy with it - if so, I will submit the new version to CRAN soon.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Nowosad/pollen/issues/11#issuecomment-980644800, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFCT4K7N6MFIBVAOTIUWP33UOD3Q5ANCNFSM5GSNJOKQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

Nowosad commented 2 years ago

I cannot think of any good solutions that would work here. All these methods expect tavg and they do not have any "correction factor". One possible workaround for you would be to estimate true tavg for your location based on tavg of some local meteorological station...

cperk commented 2 years ago

Ok, but to confirm, tavg expects temperature data for the full year, including the winter?

On Sat, Nov 27, 2021 at 2:24 PM Jakub Nowosad @.***> wrote:

I cannot think of any good solutions that would work here. All these methods expect tavg and they do not have any "correction factor". One possible workaround for you would be to estimate true tavg for your location based on tavg of some local meteorological station...

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Nowosad/pollen/issues/11#issuecomment-980788712, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFCT4K62PIB676CAIDMLDYLUOEV6LANCNFSM5GSNJOKQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

cperk commented 2 years ago

or is tavg the average temperature starting from the time of planting, which would be equivalent to the start of the growing season for a given species? Somehow this is very confusing.

On Sat, Nov 27, 2021 at 2:30 PM Carrie Perkins @.***> wrote:

Ok, but to confirm, tavg expects temperature data for the full year, including the winter?

On Sat, Nov 27, 2021 at 2:24 PM Jakub Nowosad @.***> wrote:

I cannot think of any good solutions that would work here. All these methods expect tavg and they do not have any "correction factor". One possible workaround for you would be to estimate true tavg for your location based on tavg of some local meteorological station...

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Nowosad/pollen/issues/11#issuecomment-980788712, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFCT4K62PIB676CAIDMLDYLUOEV6LANCNFSM5GSNJOKQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

Nowosad commented 2 years ago

I am not an expert in plants development. However, based on what I read -- both can be true. For example, if you study perennial plants then you probably would use full-year data (or specify some relevant time range); however, when you create new plantings, then tavg should probably be measured starting of the time of planting.

Nowosad commented 2 years ago

(Sidenote: the new version is now on CRAN - https://cran.r-project.org/package=pollen)