frost package

  collapse = TRUE,
  comment = "#>"

Prediction of minimum temperature for frost forecasting in agriculture


This package contains a compilation of empirical methods used by farmers and agronomic engineers to predict the minimum temperature to detect a frost event.

These functions use variables such as environmental temperature, relative humidity, and dew point.


If you don't have package devtools installed, run the following commands.



To install the package from the GitHub repo, run


Load the library to start using the functions


Dew point estimation

Given that several methods used dew point as an input variable, this package provides methods to estimate the dew point (in Celsius degree) given ambient temperature and relative humidity.


temp <- 25
rh <- 54


Temperature conversions

Most of the predictive methods use temperature in degree Celsius, so maybe you want to convert your temperature values to this unit. You can use the method convert.temperature to achieve this, and convert from/to Kelvin (K), Fahrenheit (F) or Celcius (C).


convert.temperature(from="K", to="C",350)
cels <- convert.temperature(from="F",to="C",c(120,80,134,110))
k <- convert.temperature(from="C", to="K",cels)

Prediction of minimum temperature

FAO approach

The empirical formula for estimating the minimum temperature is $T_{min} = a * T + b * T_{dew} + c$. For calculating the coefficientes $a, b$ and $c$ we call buildFAO(dw,temp,tmin).

# We create random data
x1 <- rnorm(100,mean=2,sd=5)
x2 <- rnorm(100,mean=1,sd=3)
y <- rnorm(100,mean=0,sd=2)
buildFAO(dw = x2,temp=x1,tmin=y)
# data example taken from FAO Book
t0 <- c(3.2,0.8,0.2,2.6,4.4,5.2,2.7,1.2,4.5,5.6) # temperature 2 hours after sunset
td <- c(-4.2,-8.8,-6.5,-6.2,-6.1,2.6,-0.7,-1.7,-1.2,0.1) # dew point 2 hours after sunset
tn <- c(-3.1,-5,-6.3,-5.4,-4,-2.5,-4.8,-5,-4.4,-3.3)
out <- buildFAO(dw = td,temp=t0,tmin=tn)

# We use the results of the model to have the coefficients for the formula
current_temp <- 10
current_dw <- 2
ptmin <- predFAO(out,current_temp,current_dw)
cat("The predicte minimum temperature is ",ptmin," °C")

# We plot the temperature trend, we have 12 hours until sunrise
getTrend(Tmin = ptmin ,t2 = current_temp,n = 12,plot=TRUE) # in °C degress

We can plot an estimated temperature trend during a frost night, calculated using the FAO recomendation.


getTrend(Tmin = 22.2,t2 = 33.7,n = 15) # in °F degress
getTrend(Tmin = -5.45,t2 = 0.95,n = 15, plot=TRUE) # in °C degress

We can use the output of plotTrend to plot using other libraries such as ggplot2.

var <- getTrend(Tmin = -5.45,t2 = 0.95,n = 15) # in °C degress
# just plotting points
ggplot(var,aes(x=x,y=y)) + geom_point(color="blue")
# add trend line
ggplot(var,aes(x=x,y=y)) + geom_point() + geom_smooth(color="red")

Empirical formula used in Mendoza

The empirical formula for estimating the minimum temperature is $T_{min} = \frac{T_{max} + T_{dew}}{2} - K$. For calculating K, we call buildMdz function. Then for prediction we use predMdz.

# just an example
dw <- c(-2,-5,2,6,8)
tempMax <- c(10,20,30,25,29)
tmin <- c(-1,-2,3,5,10)
out <- buildMdz(dw,tempMax,tmin)
predMdz(dw = -3, tempMax = 15, out)

Try the frost package in your browser

Any scripts or data that you put into this service are public.

frost documentation built on May 2, 2019, 10:19 a.m.