# agri.growing-degree-days
Growing degree days (GDD, heat units, thermal time) from daily minimum and
maximum temperatures: how much warmth above a base temperature a crop, pest or
pasture has had. `growingDegreeDays([{min: 10, max: 20}], 10, null, "average")`
is 5.
## The two methods
McMaster and Wilhelm (1997) showed that "the" GDD equation is read two ways,
and that the difference matters most on cool days, so the method is an
argument rather than a hidden choice:
- **average** (their method 1): the day is (max + min) / 2 - base, and a
negative day counts as 0. With an upper cap, max and min above the cap are
first lowered to it.
- **clamped** (their method 2, and the US "86/50" maize method): max and min
are each held within base..upper first, then averaged and the base
subtracted. A day that is 5 °C at dawn and 35 °C in the afternoon counts
10 GDD at base 10, cap 30, where averaging gives 7.5.
The upper cap is optional (null for none). Neither method models the hours
above the cap (no triangle or sine methods).
## Exactness
Temperatures and the base are taken to 0.1 °C (half away from zero,
`math.round-float`), so each day is an exact multiple of 0.05 and is returned
as it is. The total adds the exact daily values and rounds once, half up, to
0.1. Rounding each day first would make three days of 0.05 into 0.3; this
gives 0.2 (0.15 rounded).
## Limits
Temperatures, base and cap are -100 to 100 °C; the cap must be above the base;
a day's min must not be above its max. An empty list is 0. The function does
not know crop bases: 10 °C for maize, 0 °C for wheat thermal time and grass
T-sum, 5 or 6 °C for many temperate crops are the caller's choice.
## Source
G. S. McMaster and W. W. Wilhelm, "Growing degree-days: one equation, two
interpretations", Agricultural and Forest Meteorology 87 (1997) 291-300,
https://doi.org/10.1016/S0168-1923(97)00027-0.