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.
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.
library(frost)
temp <- 25
rh <- 54
calcDewPoint(rh,temp,mode="A")
#> [1] 14.99222
calcDewPoint(rh,temp,mode="B")
#> [1] 24.07111
calcDewPoint(rh,temp,mode="C")
#> [1] 15.04884
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).
library(frost)
library(frost)
convert.temperature(from="K", to="C",350)
#> [1] 76.85
cels <- convert.temperature(from="F",to="C",c(120,80,134,110))
k <- convert.temperature(from="C", to="K",cels)
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)
.
library(frost)
# 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)
#> An object of class "FAOFrostModel"
#> Slot "a":
#> [1] 0.02662973
#>
#> Slot "b":
#> [1] -0.1001134
#>
#> Slot "c":
#> [1] 0.2859272
#>
#> Slot "Tp":
#> [1] -0.19020938 -0.14916901 0.40757180 0.49071066 0.27914252
#> [6] 0.49604312 -0.08044573 0.16027672 0.27977885 0.71202871
#> [11] 0.46274747 0.22830342 -0.31457067 -0.27405902 0.66182603
#> [16] 0.38829750 0.55421424 0.02319859 -0.58294347 0.61148867
#> [21] -0.15921080 0.26063683 -0.11551826 -0.02925595 0.30068791
#> [26] 0.66188744 0.49282661 0.28798678 0.33120183 0.77613292
#> [31] 0.21397742 -0.10810433 -0.10330527 0.35999429 0.70819217
#> [36] 0.34716422 0.29387814 0.69278205 -0.22765775 0.22750648
#> [41] -0.19373204 0.68801896 0.07833059 1.21053735 -0.05629027
#> [46] 0.45526647 0.12058019 0.10723638 0.51976959 0.17416007
#> [51] -0.09771255 0.54861018 -0.09060920 -0.22776314 0.77931587
#> [56] 0.51523271 0.10917970 0.50614842 0.75902563 0.56077785
#> [61] -0.22504757 0.43196966 -0.39424423 -0.05942793 0.06556593
#> [66] 0.09596800 0.24211122 0.27628319 0.18245733 0.10389392
#> [71] -0.40264655 0.20780255 0.59231733 0.61928866 -0.36181498
#> [76] -0.19033505 0.45740967 0.02260116 -0.15806010 0.38656030
#> [81] 0.03804272 0.42260677 0.27938556 0.43916613 0.20939097
#> [86] -0.01263477 -0.02554684 0.09430429 0.55553881 0.06005227
#> [91] 0.29310002 0.97589069 0.06748657 -0.48822982 0.85074701
#> [96] 0.05467774 0.58944187 0.32047287 0.14556136 0.39005134
#>
#> Slot "Rp":
#> [1] -0.903629661 -2.684611105 0.877945626 -0.523096891 2.800146952
#> [6] -0.349022571 2.096034728 -1.435532404 3.267057410 2.547108856
#> [11] 3.343064038 -3.742740069 -0.465013273 0.851538623 3.499767638
#> [16] 0.630689893 0.024408654 1.783386286 0.955599116 0.203131131
#> [21] -3.523837513 -2.856204637 -0.496685427 -0.395867944 1.119485687
#> [26] -2.937709548 -1.886723577 -1.011796604 -3.123540814 -0.959546178
#> [31] 2.073713120 -0.961276626 -0.149590936 -0.268457190 1.236826376
#> [36] -0.292071665 0.350929133 -0.830983336 -1.796211027 -2.479159368
#> [41] -1.284897142 -3.054352969 2.710877769 1.443784182 -0.696571125
#> [46] -0.567003780 3.198489425 1.944494300 3.171406752 2.799183339
#> [51] 4.018584059 -1.733178644 -0.873186871 1.772653263 -1.647491448
#> [56] -0.254354311 0.494441817 1.758020531 1.546550314 -0.283121958
#> [61] -1.256204457 -0.496931036 0.367538218 -0.473028080 -0.335898689
#> [66] -0.013605756 -0.638983884 2.056330252 -1.454627908 -0.488639613
#> [71] 2.216713698 2.073038127 -1.563597230 -2.342994203 -1.475021591
#> [76] 0.402822671 2.651548432 -3.933956341 2.295901233 -1.615986190
#> [81] -0.381629764 1.690923784 -0.998466342 -1.206347266 1.276158526
#> [86] -0.891237424 2.733355064 1.100270368 -2.755826037 0.136822026
#> [91] 2.070907362 -2.366407455 0.435593114 -4.242948116 1.006711211
#> [96] -0.120444431 -2.970409779 0.710348111 0.006960943 0.739396046
#>
#> Slot "r2":
#> [1] 0.03217716
# 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")
#> The predicte minimum temperature is -0.7409219 °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
#> x y
#> 1 3 6.6034223
#> 2 4 5.1965137
#> 3 5 4.1169548
#> 4 6 3.2068445
#> 5 7 2.4050213
#> 6 8 1.6801177
#> 7 9 1.0135000
#> 8 10 0.3930274
#> 9 11 -0.1897332
#> 10 12 -0.7409219
We can plot an estimated temperature trend during a frost night, calculated using the FAO recomendation.
library(frost)
getTrend(Tmin = 22.2,t2 = 33.7,n = 15) # in °F degress
#> x y
#> 1 3 30.51047
#> 2 4 29.18933
#> 3 5 28.17558
#> 4 6 27.32095
#> 5 7 26.56800
#> 6 8 25.88729
#> 7 9 25.26131
#> 8 10 24.67866
#> 9 11 24.13142
#> 10 12 23.61383
#> 11 13 23.12154
#> 12 14 22.65116
#> 13 15 22.20000
getTrend(Tmin = -5.45,t2 = 0.95,n = 15, plot=TRUE) # in °C degress
#> x y
#> 1 3 -0.8250406
#> 2 4 -1.5602865
#> 3 5 -2.1244606
#> 4 6 -2.6000813
#> 5 7 -3.0191115
#> 6 8 -3.3979438
#> 7 9 -3.7463161
#> 8 10 -4.0705731
#> 9 11 -4.3751219
#> 10 12 -4.6631713
#> 11 13 -4.9371438
#> 12 14 -5.1989211
#> 13 15 -5.4500000
We can use the output of plotTrend
to plot using other libraries such as ggplot2.
library(frost)
var <- getTrend(Tmin = -5.45,t2 = 0.95,n = 15) # in °C degress
require(ggplot2)
#> Loading required package: ggplot2
# 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")
#> `geom_smooth()` using method = 'loess' and formula 'y ~ x'