#### Degree-Day Calculation Methods

Every degree-days model is an approximate integral over time of some function of temperature. The function -- the "rate function" -- is an approximation to the rate at which development -- or some other biological process -- occurs happens as a function of temperature. In theory, if we had continuous temperature measurements, we would simply integrate the rate function of temperature over time.

However, for many weather stations, we only have daily maximum and minimum temperatures, so we must approximate. A number of different approximations, which we call "calculation methods," are in use. When a researcher develops a model, they specify the calculation method they used in developing it as well as the rate function. In general, a model is only valid with degree-days computed using that calculation method.

For most models, uspest.org uses the appropriate calculation method automatically, and users don't need to worry about it. But if you are developing a new model, or if you are curious, this page describes the calculation methods we use.

While the rate function and the calculation method are distinct concepts, modelers often present a single procedure or formula which combines them. The calculation methods listed below are in fact combinations of this sort, consisting of a rate function (usually with temperature threshold parameters) and a calculation method per se.

#### Typical Rate Functions

The rate functions in most of our models are piecewise linear functions described by these parameters:

Lower Threshold (Tlo or Tlow)
The temperature below which development does not occur.
Upper Threshold (Thi)
The temperature above which the development rate no longer increases with increasing temperature.
Cutoff Method
What the rate function does above the upper threshold. Common variants are:
Horizontal cutoff
Temperatures above Thi are treated as if the were equal to Thi. The development rate remains constant. The graph of the rate function is a horizontal line. Most of our models use horizontal cutoff.
Vertical cutoff
When the temperature is above Thi, development stops completely. The graph of the rate function drops vertically to zero and remains there.
Intermediate cutoff
When the temperature is above Thi, development proceeds, but slows gradually as temperature increases. The graph of the rate function reaches a peak at Thi and then decreases linearly.

That is, for most models the rate function is zero for temperatures less than Tlo, increases with slope 1 from Tlo to Thi, and then remains constant or drops depending on the cutoff method.

Note that this description does not apply all degree-day models. The rate function can have any form. Notable exceptions are Potato P-days and Heating Degree-days. P-days use a piecewise quadratic function. Heating Degree-days is a measure of cold, not heat. Its rate function is zero for temperatures above Tlo, and increases linearly as temperature decreases below that. (It does not use Thi.)

Notation: Tlo and Thi are the lower and upper threshold temperatures (parameters of the calculation method). Tmin and Tmax are the minimum and maximum temperatures that day (weather data from observations or forecasts). DDs is the number of degree-days for that day; it's calculated for each day and the results added together.

Simple Average / Growing Degree-days [A]

This calculation method is sometimes called Growing Degree-days. It is used for the growth of crops other than corn. It uses horizontal cutoff, except that if the whole day is above the upper threshold (Tmin > Thi) it uses vertical cutoff.

• If Tmax < Tlow, set DDs=0 and stop.
• If Tmin > Thi, set DDs=0 and stop.
• If Tmax > Thi, set Tmax = Thi.
• set DDs=(Tmax + Tmin) / 2 - Tlo.
• if DDs < 0, set DDs=0.
Corn Growing Degree-days [G]

This method is traditionally for corn; it is deprecated for other uses. Uses horizontal cutoff.

• If Tmin < Tlo, set Tmin=Tlo.
• If Tmax > Thi, set Tmax=Thi.
• set DDs=(Tmax + Tmin) / 2 - Tlo.
• if DDs < 0, set DDs=0.

#### General Mathematical Methods

These methods are derived by estimating the temperature throughout the day and then integrating the rate function of that estimated temperature. They differ in how they construct the estimated temperature, though they tend to produce very similar values. Another description of them is given at UC IPM's About Degree-Days page.

These four methods are used by most of our insect phenology models and nearly half of our crop development models. Almost all of those use Single Sine. All use horizontal cutoff.

Double Triangle [T2]
Assumes the temperature starts at yesterday's Tmax, decreases linearly over 12 hours to today's Tmin, and then increases linearly over 12 hours to today's Tmax.
• Perform the Single Triangle calculation with yesterday's Tmax and today's Tmin and call the result DD1.
• Perform the Single Triangle calculation with today's Tmax and today's Tmin, and call the result DD2.
• set DDs = (DD1 + DD2)/2.
Single Triangle [T1]
Like Double Triangle, except that it uses today's Tmax as a substitute for yesterday's Tmax. Can also be thought of as assuming the temperature starts at today's Tmin, and then increases linearly over 24 hours to today's Tmax.
• if Tmin > Thi, set DDs = (Thi - Tlo) and stop.
• if Tmax < Tlo, set DDs = 0 and stop.
• if Tmin ≥ Tlo and Tmax ≤ Thi, set DDs = (Tmax + Tmin)/2 - Tlo and stop.
• if Tmin < Tlo and Tmax < Thi, set DDs = (Tmax - Tlo)2/(2*(Tmax - Tmin)) and stop.
• if Tmin ≥ Tlo and Tmax ≥ Thi, set DDs = (Tmax + Tmin)/2 - Tlo - (Tmax - Thi)2/(2*(Tmax - Tmin)) and stop.
• if Tmin < Tlow and Tmax ≥ Thi set DDs = [(Tmax - Tlo)2 - (Tmax - Thi)2] / (2*(Tmax - Tmin)) and stop.
Double Sine [S2]
Like Double Triangle, assumes the temperature starts at yesterday's Tmax, decreases over 12 hours to today's Tmin, and then increases over 12 hours to today's Tmax. However, the increase and decrease are assumed to each follow a half-period of a sinusoid, rather than being linear. The sine methods come from Baskerville & Emin 1969.
• set DDs = docalcs_S(Yesterday's Tmax, today's Tmin) + docalcs_S(today's Tmax, today's Tmin) using the docalcs_S function below.
Single Sine [S1]
Like Double Sine, except that it uses today's Tmax in place of yesterday's Tmax. Can also be thought of as assuming that the temperature starts at today's Tmin and increases over 24 hours to today's Tmax. following a half-period of a sinusoid.
• set DDS = 2*docalcs_S(Tmax, Tmin) using the docalcs_S function below.

This is code in the Perl programming language. Thresholds \$thi and \$tlow are global variables.

```sub docalcs_S {
local(\$max, \$min) = @_;

if (\$min > \$thi) {
\$heat = \$thi - \$tlow;
}
else {
if (\$max <= \$tlow) {
\$heat = 0;
}
else {
\$fk1 = 2 * \$tlow;
\$diff = \$max - \$min;
\$sum = \$max + \$min;
if (\$min >= \$tlow) {
\$heat = (\$sum - \$fk1) / 2;
}
else {
\$heat = &sinec(\$sum, \$diff, \$fk1);
}
if (\$max > \$thi) {
\$fk1 = 2 * \$thi;
\$heat -= sinec(\$sum, \$diff, \$fk1);
}
}
}
\$ddtmp = \$heat / 2;
return \$ddtmp;
}

sub sinec {
local(\$sum, \$diff, \$fk1) = @_;

\$twopi = 6.28318530717959;
\$pihlf = 1.5707963267949;
\$d2 = \$fk1 - \$sum;
my \$d3 = \$diff * \$diff - \$d2 * \$d2;
# keep roundoff from causing errors like "Can't take sqrt of -1.20792e-13"
\$d3 = 0 if \$d3<0 and \$d3 > -1e-9;
\$theta = atan2(\$d2, sqrt(\$d3));
if ((\$d2 < 0) && (\$theta > 0)) {
\$theta = \$theta - 3.1416;
}
\$heat = (\$diff * cos(\$theta) - \$d2 * (\$pihlf - \$theta)) / \$twopi;
\$heat;
}
```

#### Intermediate Cutoff methods

These methods use the same temperature estimate as Double Sine and Single Sine, but use a rate function with intermediate cutoff. Our implementations use the same code as for the horizontal cutoff sine methods, but and then subtract off the difference.

Single Sine with Intermediate Cutoff [I1]
Used for the new Spotted Wing Drosophila model.
• Set DD1 = 2*docalcs_S(Tmax, Tmin) as for single sine
• Temporarily change Tlo and Thi to Thi and 2*Thi - Tlo, respectively.
• Set DD2 = 2*docalcs_S(Tmax, Tmin), repeating the calculation with the temporary thresholds.
• Restore the proper Tlo and Thi.
• Set DDs = DD1-DD2
Double Sine with Intermediate Cutoff [I2]
• Perform the Single Sine with Intermediate Cutoff calculation with yesterday's Tmax and today's Tmin and call the result DD1.
• Perform the Single Sine with Intermediate Cutoff calculation again with today's Tmax and today's Tmin, and call the result DD2.
• set DDs = (DD1 + DD2)/2.

#### For specific models

These calculation methods were developed for specific models, and are normally used only with those models.

Potato P-Days [PD]
Originally developed to model potato development (Sands ed al, 1979) and used here for the potato early blight model (Gent and Schwartz 2003). The rate function for this model is a piecewise quadratic function of temperature. The approximation method involves evaluating the rate function at the minimum temperature, the maximum temperature and two points in between and taking a weighted average. Note that for this model the choice of temperature scale matters. The code shown here converts from Fahrenheit (which our code uses internally) to Celsius (used by in the definition of the rate function).
```sub docalcs_PD
{    # P-DAYS used for potato growth and early blight treatment initiation
# this is the daily approx version of equation 2 by Sands
my ( \$max, \$min ) = @_;
my ( \$dp1, \$dp2, \$dp3, \$dp4 ) = 0;
my ( \$cmax, \$cmin );

\$cmax = ( \$max - 32 ) * 5 / 9;
\$cmin = ( \$min - 32 ) * 5 / 9;

\$dp1 = &dp(\$cmin);
\$dp2 = &dp( 0.66667 * \$cmin + 0.333333 * \$cmax );
\$dp3 = &dp( 0.66667 * \$cmax + 0.333333 * \$cmin );
\$dp4 = &dp(\$cmax);

\$ddtmp = 1 / 24 * ( 5 * \$dp1 + 8 * \$dp2 + 8 * \$dp3 + 3 * \$dp4 );
return \$ddtmp;
}

sub dp {    #estimate delta-p with \$t temperature
my (\$t) = @_;
my \$dp = 0;

if ( \$t < 7 || \$t > 30 ) { \$dp = 0.0 }
elsif ( ( \$t >= 7 ) && ( \$t < 21 ) ) {
\$dp = 10 * ( 1 - ( \$t - 21 )**2 / 196 );
}
elsif ( ( \$t >= 21 ) && ( \$t <= 30 ) ) {
\$dp = 10 * ( 1 - ( \$t - 21 )**2 / 81 );
}
if ( \$dp < 0 ) { \$dp = 0 }
return \$dp;
}
```
Max Temp only Heat Units [XD]
Used for pine shoot beetle. The "approximation method" simply uses the maximum temperature, and the rate function uses a horizontal cutoff.
• If Tmax > Thi, set Tmax = Thi.
• Set DDs = Tmax - Tlo.
• If DDs < 0, set DDs = 0.
Max Temp only w/intermed. cutoff [XI]
The "approximation method" simply uses the maximum temperature, but the rate function uses an intermediate cutoff. Used for some crop growth models (Perry & Wehner 1996).
• If Tmax < Tlo, set DDs = 0 and stop.
• If Tmax > Thi, set DDs = 2*Tthi - Tlo - Tmax, otherwise set DDs = Tmax - Tlo.
• If DDs < 0, set DDs = 0.
Wheat Growing Degree-days[WG]
Developed for the Bauer Wheat model (Bauer et al. 1984). This model changes its thresholds as development proceeds. It sets its Thi internally, depending on the previously accumulated heat units, \$ddcum in the code below. This implementation assumes temperatures are in Fahrenheit.
```sub docalcs_WG {    # WHEAT (Bauer model) GROWING DEGREE-DAYS
\$tlow =32
my ( \$max, \$min, \$dd_cum ) = @_;
my \$l_thi;
my \$ddtmp;

# FAHRENHEIT
if (\$dd_cum < 215) {
# use thi=70 if prior to 2nd Leaf Stage ( < 215 DD )
\$l_thi = 70;
}
elsif (\$dd_cum >= 215) {
# use thi=95 if not prior to 2nd Leaf Stage ( >= 215 DD )
\$l_thi = 95;
}

if ( ( \$max < \$tlow ) && ( \$min < \$tlow ) ) {
\$ddtmp = 0.0;
} else {
if ( \$min < \$tlow ) {
\$min = \$tlow;
}
if ( \$max > \$l_thi ) {
\$max = \$l_thi;
}
\$ddtmp = ( \$max + \$min ) / 2 - \$tlow;
if ( \$ddtmp < 0 ) {
\$ddtmp = 0.0;
}
}
return \$ddtmp;
}
```
Fire Blight Degree-Hours [FB or DH]
These are specific for the 2010EZ fireblight model (Smith 2010). Degree-day models of fireblight are inferior to hourly-driven fireblight models. Use those instead. This method has been removed from our software.

#### From Other Disciplines

These measures are used primarily for measuring the demand for building heating and cooling, e.g., by power utilities and HVAC companies. We have included them for convenience, but they are not normally used for pest management.

Heating Degree-days / Chilling units[HD]
This primarily a measure of the demand for heat in buildings. It can also be used for in agriculture as a measure of the effect of cold on organisms, such as insect chilling units. Note that this model works backwards in the sense that it returns larger numbers on cold days. Degree days are accumulated for temperatures below Tlo and not above it. (Thi is not used; there is no cutoff method.)
• set DDs = Tlo - (Tmax + Tmin) / 2.
• if DDs < 0, set DDs=0.
Cooling Degree-Days [CD]
This is primarily used a measure of the demand for air conditioning in buildings. It is like simple average degree-days, except with no upper threshold. (Thi is not used; there is no cutoff method.)
• set DDs = (Tmax + Tmin) / 2 - Tlo.
• if DDs < 0, set DDs=0.

#### Internal use

These are not actually degree-day methods, but appear in some places in our software for programming convenience. Everyone else can safely ignore them. They simply return the daily minimum temperatures or daily maximum temperatures. They are useful in programming, primarily to allow code developed for interpolating degree-days to be used for interpolating temperatures. They ignore both Tlo and Thi and have no cutoff method.

Minimum temperature [MN]
• Set DDs = Tmin.
Maximum temperature [MX]
• Set DDs = Tmax.