ReadInputs for Using Package Evapotranspiration

Hey,
i want to calculate the evapotranspiration with the the PenmanMonteith function in the package 'Evapotranspiration'.
i thought i understood what steps i have to do, but when i try to use the funktion ReadInputs there comes a error message i don't know how to rectify.

i hope someone can help me. here is my code:

data(constants)
library(readxl)
Data <- read_excel('C:\Users\smith\Desktop\datas.xlsx')

Year<-as.numeric(format(Data$date, "%Y"))
Month<-as.numeric(format(Data$date, "%m"))
Day<-as.numeric(format(Data$date, "%d"))

Temp<- Data$temperature
RH <- Data$humidity
uz <- Data$wind
Rs <- Data$globalradiation

inputData <- cbind(Year, Month, Day, Temp,RH, uz, Rs)

colnames(inputData) <- c("Year", "Month", "Day" , "Temp", "RH", "uz", "Rs")

varnames <- c("Year", "Month", "Day", "Temp", "RH", "uz", "Rs")

stopmissing <- cbind("10", "10", "2")

climatedata <- data.frame(Year, Month, Day, Temp,RH, uz, Rs)

Inputs <- ReadInputs(varnames,climatedata,constants, stopmissing, timestep = "subdaily", interp_missing_days = FALSE, interp_missing_entries = FALSE, interp_abnormal = FALSE, missing_method = NULL, abnormal_method = NULL, message = "yes")

ET.PenmanMonteith(Inputs, constants, solar="sunshine hours", wind="yes", crop = "short", message="yes", AdditionalStats="yes", save.csv="no")

the error message i get is:
error in seq.Date(as.Date(Date.daily[1]), as.Date(Date.daily[length(date.daily)]), 'to' must be of length 1.

Hi @tim1,
Can you post a sample of your data to help diagnose the problem?
Run this code and then copy-paste the console output into your reply (please don't send a screenshot as that's not much help):

head(Data, n=20)

here is a sample of my Data. I hope that's the way you wanted it. Thanks for trying to help me:

# A tibble: 20 × 8

...1 date wind wind_direct…¹ tempe…² humid…³ air_p…⁴ globa…⁵

1 1 2020-08-25 00:00:00 0.806 247.19124423… 16.2 71.8 994. 34.1

2 2 2020-08-26 00:00:00 1.44 186.26249999… 17.1 70.9 990. 141.

3 3 2020-08-27 00:00:00 3.62 236.73541666… 18.1 64.8 987. 60.5

4 4 2020-08-28 00:00:00 1.20 226.27152777… 17.5 68.4 994. 152.

5 5 2020-08-29 00:00:00 1.39 200.05833333… 17.2 73.5 982. 124.

6 6 2020-08-30 00:00:00 1.52 192.45902777… 16.0 73.3 984. 185.

7 7 2020-08-31 00:00:00 0.499 223.32916666… 16.9 74.8 988. 122.

8 8 2020-09-01 00:00:00 0.732 232.50486111… 15.5 81.7 996. 115.

9 9 2020-09-02 00:00:00 0.491 194.33472222… 12.5 88.5 997. 99.3

10 10 2020-09-03 00:00:00 0.560 206.89513888… 13.4 78.0 997. 202.

11 11 2020-09-04 00:00:00 1.35 200.17986111… 13.4 82.7 998. 91.5

12 12 2020-09-05 00:00:00 0.988 194.56805555… 18.6 87.4 999. 73.3

13 13 2020-09-06 00:00:00 0.844 263.71041666… 15.3 82.8 997. 79.2

14 14 2020-09-07 00:00:00 0.739 231.82708333… 13.2 76.1 998. 167.

15 15 2020-09-08 00:00:00 0.513 238.77430555… 13.9 77.4 1002. 177.

16 16 2020-09-09 00:00:00 0.836 258.13958333… 16.2 76.4 1004. 185.

17 17 2020-09-10 00:00:00 1.03 241.47708333… 18.2 79.7 1000. 117.

18 18 2020-09-11 00:00:00 0.735 246.15972222… 15.2 73.8 1000. 183.

19 19 2020-09-12 00:00:00 0.411 223.66527777… 13.2 75.8 997. 194.

20 20 2020-09-13 00:00:00 0.972 243.61458333… 15.8 75.3 998. 185.

# … with abbreviated variable names ¹​wind_direction, ²​temperature, ³​humidity,

# ⁴​air_pressure, ⁵​globalradiation

That's still pretty "messy" to work with. Try pasting the output from this:

dput(head(Data, n=20))

i think they still look pretty messy:

structure(list(...1 = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 
## 13, 14, 15, 16, 17, 18, 19, 20), date = structure(c(1598313600, 
## 1598400000, 1598486400, 1598572800, 1598659200, 1598745600, 1598832000, 
## 1598918400, 1599004800, 1599091200, 1599177600, 1599264000, 1599350400, 
## 1599436800, 1599523200, 1599609600, 1599696000, 1599782400, 1599868800, 
## 1599955200), tzone = "UTC", class = c("POSIXct", "POSIXt")), 
##     wind = c(0.805529953917051, 1.443125, 3.623125, 1.20180555555556, 
##     1.38513888888889, 1.521875, 0.499444444444444, 0.731736111111111, 
##     0.491458333333333, 0.560347222222222, 1.35298611111111, 0.988055555555556, 
##     0.844375, 0.738888888888889, 0.512569444444444, 0.835763888888889, 
##     1.02868055555556, 0.734583333333333, 0.410555555555556, 0.972361111111111
##     ), wind_direction = c("247.191244239631", "186.26249999999999", 
##     "236.73541666666699", "226.271527777778", "200.058333333333", 
##     "192.459027777778", "223.32916666666699", "232.50486111111101", 
##     "194.33472222222201", "206.89513888888899", "200.17986111111099", 
##     "194.56805555555599", "263.71041666666702", "231.82708333333301", 
##     "238.774305555556", "258.13958333333301", "241.47708333333301", 
##     "246.159722222222", "223.66527777777799", "243.614583333333"
##     ), temperature = c(16.1873271889401, 17.0677777777778, 18.1098611111111, 
##     17.5280555555556, 17.2168055555556, 15.9779861111111, 16.9484722222222, 
##     15.4502777777778, 12.4588194444444, 13.3585416666667, 13.4349305555556, 
##     18.6405555555556, 15.2664583333333, 13.2375, 13.9465277777778, 
##     16.2358333333333, 18.1772916666667, 15.2189583333333, 13.1726388888889, 
##     15.8014583333333), humidity = c(71.7688940092166, 70.9423611111111, 
##     64.7947222222222, 68.3627777777778, 73.4723611111111, 73.3069444444444, 
##     74.8195138888889, 81.7063888888889, 88.5197222222222, 78.0480555555555, 
##     82.7043055555555, 87.4257638888889, 82.7684027777778, 76.1327083333333, 
##     77.416875, 76.3794444444444, 79.7432638888889, 73.8436111111111, 
##     75.7621527777778, 75.3015277777778), air_pressure = c(993.736175115207, 
##     990.029513888889, 986.658472222222, 993.611041666667, 982.227152777778, 
##     983.600763888889, 987.835625, 995.736111111111, 997.071736111111, 
##     997.178263888889, 998.447430555556, 998.812291666667, 996.524513888889, 
##     998.36375, 1002.31729166667, 1003.82576388889, 1000.02180555556, 
##     1000.24784722222, 996.665555555556, 997.971597222222), globalradiation = c(34.11866359447, 
##     141.123680555556, 60.5072222222222, 151.976666666667, 124.071666666667, 
##     185.319375, 121.866527777778, 114.900416666667, 99.3236111111111, 
##     201.992916666667, 91.4524305555556, 73.3261805555556, 79.1616666666667, 
##     166.542013888889, 176.949722222222, 185.437708333333, 116.506527777778, 
##     182.823680555556, 193.956319444444, 184.710555555556)), row.names = c(NA, 
## -20L), class = c("tbl_df", "tbl", "data.frame"))

but maybe the output of the data frame 'climatedata' is more helpful. it's the same data, just the date is splitted into Year, Month and Day and the column heading is changed, so it can be used to calcurate the evapotranspiration.

##     Year Month Day         Temp       RH         uz                     Rs
## 1   2020     8  25  16.18732719 71.76889 0.80552995  34.118664
## 2   2020     8  26  17.06777778 70.94236 1.44312500 141.123681
## 3   2020     8  27  18.10986111 64.79472 3.62312500  60.507222
## 4   2020     8  28  17.52805556 68.36278 1.20180556 151.976667
## 5   2020     8  29  17.21680556 73.47236 1.38513889 124.071667
## 6   2020     8  30  15.97798611 73.30694 1.52187500 185.319375
## 7   2020     8  31  16.94847222 74.81951 0.49944444 121.866528
## 8   2020     9   1  15.45027778 81.70639 0.73173611 114.900417
## 9   2020     9   2  12.45881944 88.51972 0.49145833  99.323611
## 10  2020     9   3  13.35854167 78.04806 0.56034722 201.992917
## 11  2020     9   4  13.43493056 82.70431 1.35298611  91.452431
## 12  2020     9   5  18.64055556 87.42576 0.98805556  73.326181
## 13  2020     9   6  15.26645833 82.76840 0.84437500  79.161667
## 14  2020     9   7  13.23750000 76.13271 0.73888889 166.542014
## 15  2020     9   8  13.94652778 77.41688 0.51256944 176.949722
## 16  2020     9   9  16.23583333 76.37944 0.83576389 185.437708
## 17  2020     9  10  18.17729167 79.74326 1.02868056 116.506528
## 18  2020     9  11  15.21895833 73.84361 0.73458333 182.823681
## 19  2020     9  12  13.17263889 75.76215 0.41055556 193.956319
## 20  2020     9  13  15.80145833 75.30153 0.97236111 184.710556

Ok, finally got something to run. You need to check these outputs very carefully as I have generated some dummy data and constants that need to be replaced with real data.
You should read the help pages for these functions very closely to check they are doing what you expect.

library(Evapotranspiration)
#> Loading required package: zoo
#> 
#> Attaching package: 'zoo'
#> The following objects are masked from 'package:base':
#> 
#>     as.Date, as.Date.numeric

climatedata <- read.table(header=TRUE,text=c("
Year Month Day         Tmax    RHmax         uz         Rs
2020     8  25  16.18732719 71.76889 0.80552995  34.118664
2020     8  26  17.06777778 70.94236 1.44312500 141.123681
2020     8  27  18.10986111 64.79472 3.62312500  60.507222
2020     8  28  17.52805556 68.36278 1.20180556 151.976667
2020     8  29  17.21680556 73.47236 1.38513889 124.071667
2020     8  30  15.97798611 73.30694 1.52187500 185.319375
2020     8  31  16.94847222 74.81951 0.49944444 121.866528
2020     9   1  15.45027778 81.70639 0.73173611 114.900417
2020     9   2  12.45881944 88.51972 0.49145833  99.323611
2020     9   3  13.35854167 78.04806 0.56034722 201.992917
2020     9   4  13.43493056 82.70431 1.35298611  91.452431
2020     9   5  18.64055556 87.42576 0.98805556  73.326181
2020     9   6  15.26645833 82.76840 0.84437500  79.161667
2020     9   7  13.23750000 76.13271 0.73888889 166.542014
2020     9   8  13.94652778 77.41688 0.51256944 176.949722
2020     9   9  16.23583333 76.37944 0.83576389 185.437708
2020     9  10  18.17729167 79.74326 1.02868056 116.506528
2020     9  11  15.21895833 73.84361 0.73458333 182.823681
2020     9  12  13.17263889 75.76215 0.41055556 193.956319
2020     9  13  15.80145833 75.30153 0.97236111 184.710556"))

# climatedata
str(climatedata)
#> 'data.frame':    20 obs. of  7 variables:
#>  $ Year : int  2020 2020 2020 2020 2020 2020 2020 2020 2020 2020 ...
#>  $ Month: int  8 8 8 8 8 8 8 9 9 9 ...
#>  $ Day  : int  25 26 27 28 29 30 31 1 2 3 ...
#>  $ Tmax : num  16.2 17.1 18.1 17.5 17.2 ...
#>  $ RHmax: num  71.8 70.9 64.8 68.4 73.5 ...
#>  $ uz   : num  0.806 1.443 3.623 1.202 1.385 ...
#>  $ Rs   : num  34.1 141.1 60.5 152 124.1 ...

# When climate data is at the daily level then "Temp" cannot be used, only Tmax
# Ditto for RH - use RHmax
# If these values are not Tmax and RHmax (for each day) then subdaily (e.g. hourly)
# data will be required.

# Looks like the function needs Tmin and RHmin as well for daily timestep.
# For demo purposes just use simple constant values (this needs fixing with real data!)
climatedata$Tmin <- c(5)    # 5 degrees C
climatedata$RHmin <- c(40)  # 40%

# You did not give these constants. Chiew and McMahon (1991) for Adelaide, Australia.
constants <- list(a_0=11.9, b_0=-0.15, c_0=-0.25, d_0=-0.0107)

varnames <- c("Tmax", "Tmin", "RHmax", "RHmin", "uz", "Rs")
stopmissing <- cbind("10", "10", "2")

Inputs <- ReadInputs(varnames, 
                     climatedata, 
                     constants, 
                     stopmissing, 
                     timestep = "daily")
#> The maximum acceptable percentage of date indices is 10 %
#> The maximum acceptable percentage of missing data is 10 %
#> The maximum acceptable percentage of continuous missing data is 2 %

# Need more constants for the model.
# Using latitude of 35 oS (needs to be in radians).
# Using elevation=100m, height of wind-speed measuring device=2m

ETconstants <- list(Elev=100, lambda=2.45, lat_rad=35*(pi/180), Gsc=0.082, z=2,
                    sigma=4.903E-9, G=0)

ET.PenmanMonteith(Inputs, 
                  constants=ETconstants,, 
                  solar="data", 
                  wind="yes", 
                  crop="short", 
                  message="yes", 
                  AdditionalStats="yes",
                  save.csv="no")
#> Penman-Monteith FAO56 Reference Crop ET
#> Evaporative surface: FAO-56 hypothetical short grass, albedo = 0.23 ; surface resistance = 70 sm^-1; crop height = 0.12  m; roughness height = 0.02 m
#> Solar radiation data have been used directly for calculating evapotranspiration
#> Wind data have been used for calculating the reference crop evapotranspiration
#> Timestep: daily
#> Units: mm
#> Time duration: 2020-08-25 to 2020-09-13
#> 20 ET estimates obtained
#> Basic stats
#> Mean: 11.73
#> Max: 17.11
#> Min: 4.05
#> $ET.Daily
#> 2020-08-25 2020-08-26 2020-08-27 2020-08-28 2020-08-29 2020-08-30 2020-08-31 
#>   4.046696  12.639231   6.630803  13.665820  11.257145  15.442262  11.494886 
#> 2020-09-01 2020-09-02 2020-09-03 2020-09-04 2020-09-05 2020-09-06 2020-09-07 
#>  10.504468   8.926835  17.113794   7.929981   7.360152   7.349279  13.691894 
#> 2020-09-08 2020-09-09 2020-09-10 2020-09-11 2020-09-12 2020-09-13 
#>  14.889122  15.590613  10.467613  15.019628  15.761804  14.858265 
#> 
#> $ET.Monthly
#>  Aug 2020  Sep 2020 
#>  75.17684 159.46345 
#> 
#> $ET.Annual
#>     2020 
#> 234.6403 
#> 
#> $ET.MonthlyAve
#> [1] 10.73955 12.26642
#> 
#> $ET.AnnualAve
#> [1] 11.73201
#> 
#> $ET_formulation
#> [1] "Penman-Monteith FAO56"
#> 
#> $ET_type
#> [1] "Reference Crop ET"
#> 
#> $message1
#> [1] "Solar radiation data have been used directly for calculating evapotranspiration"
#> 
#> $message2
#> [1] "Wind data have been used for calculating the reference crop evapotranspiration"

Created on 2022-10-13 with reprex v2.0.2

Thank you very much for your help. It worked.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.