Estimate degree days from daily min and max temperature

dd_calc(
  daily_min,
  daily_max,
  nextday_min = daily_min,
  thresh_low = NULL,
  thresh_up = NULL,
  method = c("sng_tri", "dbl_tri", "sng_sine", "dbl_sine", "simp_avg")[0],
  cutoff = c("horizontal", "vertical", "intermediate")[1],
  digits = 2,
  cumulative = FALSE,
  no_neg = TRUE,
  simp_avg_zero_method = 1,
  interpolate_na = FALSE,
  quiet = FALSE,
  debug = FALSE
)

dd_simp_avg(
  daily_min,
  daily_max,
  thresh_low,
  thresh_up = NULL,
  simp_avg_zero_method = 1,
  digits = 2,
  cumulative = FALSE,
  quiet = FALSE
)

dd_sng_tri(
  daily_min,
  daily_max,
  thresh_low = NULL,
  thresh_up = NULL,
  cutoff = c("horizontal", "vertical", "intermediate")[1],
  digits = 2,
  cumulative = FALSE,
  quiet = FALSE
)

dd_sng_sine(
  daily_min,
  daily_max,
  thresh_low = NULL,
  thresh_up = NULL,
  cutoff = c("horizontal", "vertical", "intermediate")[1],
  digits = 2,
  cumulative = FALSE,
  quiet = FALSE
)

dd_dbl_tri(
  daily_min,
  daily_max,
  nextday_min = daily_min,
  thresh_low = NULL,
  thresh_up = NULL,
  cutoff = c("horizontal", "vertical", "intermediate")[1],
  digits = 2,
  cumulative = FALSE,
  quiet = FALSE
)

dd_dbl_sine(
  daily_min,
  daily_max,
  nextday_min = daily_min,
  thresh_low = NULL,
  thresh_up = NULL,
  cutoff = c("horizontal", "vertical", "intermediate")[1],
  digits = 2,
  cumulative = FALSE,
  quiet = FALSE
)

Arguments

daily_min

Daily minimum temperature

daily_max

Daily maximum temperature

nextday_min

Minimum temp the day after

thresh_low

Lower development threshold temperature

thresh_up

Upper development threshold temperature

method

Estimation method

cutoff

Estimation cutoff method

digits

Number of decimal places to round results to

cumulative

Return cumulative values

no_neg

Set negative values to zero

simp_avg_zero_method

How to handle temperatures in the simple average method that fall outside the upper and lower thresholds (see details)

interpolate_na

Interpolate missing values, logical

quiet

Suppress messages, logical

debug

Show additional messages

Value

A vector of estimated degree day values (either daily or cumulative, depending on the value of cumulative)

Details

Units for daily_min, daily_max, thresh_low, and thresh_up should all be the same (i.e., all Fahrenheit or all Celsius). The function does not check for unit consistency.

nextday_min is required for the double-triangle and the double-sine methods. These methods use the minimum temperature of the following day to model temperatures in the 2nd half of the day. If omitted or NA, the daily minimum temperature will be substituted.

no_neg = TRUE sets negative values to zero. This is generally preferred when using degree days to predict the timing of development milestones, if one assumes that growth can not go backwards.

The simple average method is taken from McMaster and Wilhelm (1997). This method requires passing a lower threshold (also called the base temp). There are two ways of handling temperatures that fall below the base temperature. Most studies and applications use the default method (simp_avg_zero_method = 1) which simply 'zeroes out' average daily temperatures that fall below the base temp. Some studies (notably corn) use method 2, which truncates the daily minimum and maximum temperature before computing the simple average. Method 2 also allows you to pass an upper threshold. For details, see McMaster and Wilhelm.

Missing values (NAs) in the temperatures will result in NA degree days. If interpolate_na = TRUE, missing degree days will be interpolated. NAs in the middle of the series will be linearly interpolated, and NAs at the ends will be filled with the adjacent values.

Functions

  • dd_simp_avg(): Estimate degree days using the simple avg method

  • dd_sng_tri(): Estimate degree days using the single-triangle method

  • dd_sng_sine(): Estimate degree days using the single-sine method

  • dd_dbl_tri(): Estimate degree days using the double-triangle method

  • dd_dbl_sine(): Estimate degree days using the double-sine method

Examples

daily_temps <- system.file("extdata/espartoa-weather-2020.csv", package = "degday") %>%
  read.csv() %>%
    dplyr::mutate(date = as.Date(date)) %>%
    dplyr::slice(1:10)
daily_temps
#>      station       date tmin tmax
#> 1  Esparto.A 2020-01-01   38   55
#> 2  Esparto.A 2020-01-02   36   67
#> 3  Esparto.A 2020-01-03   33   59
#> 4  Esparto.A 2020-01-04   37   59
#> 5  Esparto.A 2020-01-05   38   63
#> 6  Esparto.A 2020-01-06   36   58
#> 7  Esparto.A 2020-01-07   30   53
#> 8  Esparto.A 2020-01-08   41   50
#> 9  Esparto.A 2020-01-09   37   53
#> 10 Esparto.A 2020-01-10   32   55
## Simple average method
dd_simp_avg(daily_min = daily_temps$tmin,
            daily_max = daily_temps$tmax,
            thresh_low = 55)
#>  - using simple average method
#>  [1] 0 0 0 0 0 0 0 0 0 0
## Single sine method
dd_sng_sine(daily_min = daily_temps$tmin, daily_max = daily_temps$tmax,
            thresh_low = 55, thresh_up = 93.9)
#>  - using single sine method
#>  [1] 0.00 3.31 0.68 0.74 1.99 0.48 0.00 0.00 0.00 0.00
## Single triangle method
dd_sng_tri(daily_min = daily_temps$tmin, daily_max = daily_temps$tmax,
           thresh_low = 55, thresh_up = 93.9)
#>  - using single triangle method
#>  [1] 0.00 2.32 0.31 0.36 1.28 0.20 0.00 0.00 0.00 0.00
## Add next day min temp as an additional column
daily_temps_plus_tmin_next <- daily_temps %>% dplyr::mutate(tmin_next = dplyr::lead(tmin, n = 1))
daily_temps_plus_tmin_next
#>      station       date tmin tmax tmin_next
#> 1  Esparto.A 2020-01-01   38   55        36
#> 2  Esparto.A 2020-01-02   36   67        33
#> 3  Esparto.A 2020-01-03   33   59        37
#> 4  Esparto.A 2020-01-04   37   59        38
#> 5  Esparto.A 2020-01-05   38   63        36
#> 6  Esparto.A 2020-01-06   36   58        30
#> 7  Esparto.A 2020-01-07   30   53        41
#> 8  Esparto.A 2020-01-08   41   50        37
#> 9  Esparto.A 2020-01-09   37   53        32
#> 10 Esparto.A 2020-01-10   32   55        NA
## Double-triangle method
dd_dbl_tri(daily_min = daily_temps_plus_tmin_next$tmin,
           daily_max = daily_temps_plus_tmin_next$tmax,
           nextday_min = daily_temps_plus_tmin_next$tmin_next,
           thresh_low = 55, thresh_up = 93.9)
#>  - using double triangle method
#>  [1] 0.00 2.22 0.34 0.37 1.23 0.18 0.00 0.00 0.00 0.00