From bd2983a1198b299c11d5a942492109be18f65195 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Santiago=20Beguer=C3=ADa?= Date: Sun, 20 Nov 2022 11:18:45 +0100 Subject: [PATCH 01/14] Solving devtools::test() errors for hargreaves.R Adding new import in NAMESPACE. Small changes in message errors. --- NAMESPACE | 1 + R/hargreaves.R | 5 +++-- tests/testthat/test_hargreaves.R | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 7544995..cda1e9e 100755 --- a/NAMESPACE +++ b/NAMESPACE @@ -47,5 +47,6 @@ importFrom(stats,optim) importFrom(stats,start) importFrom(stats,ts) importFrom(zoo,as.yearmon) +importFrom(zoo,as.Date) importFrom(zoo,na.trim) importFrom(zoo,rollapply) diff --git a/R/hargreaves.R b/R/hargreaves.R index 75afaeb..ef64862 100755 --- a/R/hargreaves.R +++ b/R/hargreaves.R @@ -308,6 +308,7 @@ hargreaves <- function(Tmin, Tmax, Ra=NULL, lat=NULL, Pre=NULL, # 3D array input (gridded data) int_dims <- tmin_dims } else { + int_dims <- tmin_dims check$push('Input data can not have more than three dimensions.') } n_sites <- prod(int_dims[[2]], int_dims[[3]]) @@ -355,7 +356,7 @@ hargreaves <- function(Tmin, Tmax, Ra=NULL, lat=NULL, Pre=NULL, # Verify the length of each input variable input_len <- prod(int_dims) if (sum(lengths(Tmin))!=input_len || sum(lengths(Tmax))!=input_len) { - check$push('`Tmin` and `Tmax` should not have different lengths.') + check$push('`Tmin` and `Tmax` cannot have different lengths.') } if (using$Ra && sum(lengths(Ra))!=input_len) { check$push('`Ra` has incorrect length.') @@ -462,4 +463,4 @@ hargreaves <- function(Tmin, Tmax, Ra=NULL, lat=NULL, Pre=NULL, dimnames(ET0) <- names return(ET0) -} \ No newline at end of file +} diff --git a/tests/testthat/test_hargreaves.R b/tests/testthat/test_hargreaves.R index 8d7b077..f0d50d7 100755 --- a/tests/testthat/test_hargreaves.R +++ b/tests/testthat/test_hargreaves.R @@ -65,7 +65,7 @@ test_that('input more than three dimensions', { test_that('Tmin and Tmax different size', { expect_error(hargreaves(c(1,TMIN), TMAX, lat=37.6475), - '`Tmin` and `Tmax`cannot have different lengths.') + '`Tmin` and `Tmax` cannot have different lengths.') }) test_that('Ra incorrect size', { From 6876d2a0ca784f4a7cb302a026aa27dbaa791353 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Santiago=20Beguer=C3=ADa?= Date: Wed, 23 Nov 2022 11:17:24 +0100 Subject: [PATCH 02/14] roxigen2 warnings solving and penman tests Solving some issues with test_penman.R, and prevent warnings casted by roxigen2. --- DESCRIPTION | 2 +- NAMESPACE | 3 -- R/data.R | 37 --------------------- R/hargreaves.R | 6 ---- R/kern.R | 10 ------ R/kern.plot.R | 10 ------ R/parglo.maxlik.R | 14 -------- R/penman.R | 13 +++----- R/spei.R | 29 ++-------------- R/thornthwaite.R | 8 ----- man/Datasets.Rd | 6 ---- man/Drought-indices.Rd | 1 + tests/testthat/data/penman_out_tsun.rds | Bin 2369 -> 2368 bytes tests/testthat/data/penman_out_tsun_ts.rds | Bin 2472 -> 2368 bytes tests/testthat/test_penman.R | 10 +++--- 15 files changed, 14 insertions(+), 135 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 986e4e8..b98df4a 100755 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -16,4 +16,4 @@ URL: http://spei.csic.es LazyLoad: yes Encoding: UTF-8 Suggests: covr, testthat -RoxygenNote: 7.1.1 +RoxygenNote: 7.2.0 diff --git a/NAMESPACE b/NAMESPACE index cda1e9e..8344e7b 100755 --- a/NAMESPACE +++ b/NAMESPACE @@ -22,9 +22,7 @@ importFrom(graphics,par) importFrom(graphics,plot) importFrom(graphics,points) importFrom(graphics,polygon) -importFrom(lmom,cdfgam) importFrom(lmom,cdfglo) -importFrom(lmom,cdfpe3) importFrom(lmom,pelgam) importFrom(lmom,pelglo) importFrom(lmom,pelpe3) @@ -47,6 +45,5 @@ importFrom(stats,optim) importFrom(stats,start) importFrom(stats,ts) importFrom(zoo,as.yearmon) -importFrom(zoo,as.Date) importFrom(zoo,na.trim) importFrom(zoo,rollapply) diff --git a/R/data.R b/R/data.R index 9cc1eb4..77dc5af 100755 --- a/R/data.R +++ b/R/data.R @@ -1,12 +1,6 @@ #' @name Datasets -#' -#' #' @aliases balance cabinda cruts4 -#' -#' #' @title Data sets for illustrating the functions in the SPEI package. -#' -#' #' @description #' Data used in the examples of the SPEI package: #' \code{wichita} dataset: monthly climate in Wichita (Kansas, lat=37.6475, @@ -18,19 +12,11 @@ #' Allen et al. (1998); #' \code{cruts4}: 120 years of monthly climatic water balance (precipitation #' minus reference evapotranspiration) data at six grid points from CRU TS 4.05. -#' -#' -#' -#' #' @details See description. -#' -#' #' @usage #' data(wichita) #' data(balance) #' data(cabinda) -#' -#' #' @format #' \code{wichita} dataset: a data frame with: #' \describe{ @@ -44,13 +30,11 @@ #' \item{ACSH}{ monthly mean sun hours, in h.} #' \item{ACSH}{ monthly mean cloud cover, in \%.} #'} -#' #' \code{balance} dataset: a data frame with monthly climatic water balance #' (precipitation minus potential evapotranspiration) at Indore (India), #' Kimberley (South Africa), Albuquerque (US), Valencia (Spain), Wien (Austria), #' Abashiri (Japan), Tampa (US), Sao Paulo (Brasil), Lahore (India), Punta #' Arenas (Chile) and Helsinki (Finland), in mm. -#' #' \code{cabinda} dataset: a data frame with one year of monthly climatic data #' at Cabinda (Angola, -5.33S 12.11E 20 m), with: #' @@ -102,21 +86,13 @@ #' data(balance) #' summary(balance) #' -#' -#' "wichita" #' #' @title cabinda -#' -#' #' @rdname Datasets -#' -#' #' @description See wichita -#' -#' #' @details See wichita #' "cabinda" @@ -124,27 +100,14 @@ #' #' @title balance -#' -#' #' @rdname Datasets -#' -#' -#' @description See wichita -#' -#' #' @details See wichita #' "balance" #' #' @title cruts4 -#' -#' #' @rdname Datasets -#' -#' #' @description See wichita -#' -#' #' @details See wichita "cruts4" \ No newline at end of file diff --git a/R/hargreaves.R b/R/hargreaves.R index ef64862..d44c431 100755 --- a/R/hargreaves.R +++ b/R/hargreaves.R @@ -1,12 +1,6 @@ #' @name Potential-evapotranspiration -#' -#' #' @title Computation of potential and reference evapotranspiration. -#' -#' #' @aliases thornthwaite penman -#' -#' #' @usage #' thornthwaite(Tave, lat, na.rm = FALSE, verbose=TRUE) #' diff --git a/R/kern.R b/R/kern.R index e2ec2f7..d87af21 100755 --- a/R/kern.R +++ b/R/kern.R @@ -1,21 +1,11 @@ #' @name Kernel-functions -#' -#' #' @title Time kernel for computing the SPEI at different time scales. -#' -#' #' @aliases kern.plot -#' -#' #' @description Function \code{kern} is used internally by \code{\link{spei}} and #' \code{\link{spi}}for computing drought indices at different time scales. -#' -#' #' @param scale numeric, time scale or length of the kernel. #' @param type character, shape of the kernel function. #' @param shift numeric, shifting of the kernel peak. -#' -#' #' @details #' Drought indices, such as the SPEI or the SPI, are usually #' computed at different time scales to adapt to the different response diff --git a/R/kern.plot.R b/R/kern.plot.R index 9ae5e58..245fdbb 100755 --- a/R/kern.plot.R +++ b/R/kern.plot.R @@ -1,18 +1,8 @@ #' @title Plot the kern object -#' -#' #' @description See kern -#' -#' #' @details See kern -#' -#' #' @rdname Kernel-functions -#' -#' #' @importFrom graphics plot par -#' -#' #' @export #' kern.plot <- function(scale=12, shift=0) { diff --git a/R/parglo.maxlik.R b/R/parglo.maxlik.R index 2ba0752..5461cdd 100755 --- a/R/parglo.maxlik.R +++ b/R/parglo.maxlik.R @@ -1,45 +1,31 @@ #' @name Generalized-Logistic -#' -#' #' @title Generalized Logistic maximum likelihood function -#' -#' #' @description Maximum likelihood fitting function for #' generalized logistic distribution. -#' -#' #' @details This function is used internally by \code{spei} #' and \code{spi} and is supposed to never be needed by the #' regular user. Initial values for maximum likelihood estimation #' can be provided by \code{parglo}. -#' -#' #' @usage #' parglo.maxlik(x, ini) #' -#' #' @param x vector of quantiles for which to evaluate the PDF. #' @param ini a vector of initial values of the parameters to be fit. #' -#' #' @return a list of parameters of a generalized Logistic #' distribution function #' -#' #' @references #' S.M. Vicente-Serrano, S. Beguería, J.I. López-Moreno. 2010. #' A Multi-scalar drought index sensitive to global warming: #' The Standardized Precipitation Evapotranspiration Index – SPEI. #' \emph{Journal of Climate} \bold{23}: 1696, DOI: 10.1175/2009JCLI2909.1. #' -#' #' @author Santiago Beguería #' -#' #' @importFrom stats optim #' @importFrom lmomco are.parglo.valid #' -#' #' @export #' parglo.maxlik <- function(x,ini) { diff --git a/R/penman.R b/R/penman.R index 704214e..ff7b459 100755 --- a/R/penman.R +++ b/R/penman.R @@ -1,12 +1,6 @@ #' @title Computation of potential evapotranspiration. -#' -#' #' @description See hargreaves -#' -#' #' @details See hargreaves -#' -#' #' @return A time series with the values of monthly potential or reference #' evapotranspiration, in mm. #' If the input is a matrix or a multivariate time series each column will be @@ -157,6 +151,7 @@ penman <- function(Tmin, Tmax, U2=NULL, Ra=NULL, lat=NULL, Rs=NULL, # 3D array input (gridded data) int_dims <- tmin_dims } else { + int_dims <- tmin_dims check$push('Input data can not have more than 3 dimensions') } n_sites <- prod(int_dims[[2]], int_dims[[3]]) @@ -204,7 +199,7 @@ penman <- function(Tmin, Tmax, U2=NULL, Ra=NULL, lat=NULL, Rs=NULL, # Verify the length of each input variable input_len <- prod(int_dims) if (sum(lengths(Tmin))!=input_len || sum(lengths(Tmax))!=input_len) { - check$push('`Tmin` and `Tmax`cannot have different lengths.') + check$push('`Tmin` and `Tmax` cannot have different lengths.') } if (using$U2 && sum(lengths(U2))!=input_len) { check$push('`U2` has incorrect length.') @@ -230,7 +225,7 @@ penman <- function(Tmin, Tmax, U2=NULL, Ra=NULL, lat=NULL, Rs=NULL, if (using$Tdew && sum(lengths(Tdew))!=input_len) { check$push('`Tdew` has incorrect length.') } - if (using$RH && sum(lengths(RRHa))!=input_len) { + if (using$RH && sum(lengths(RH))!=input_len) { check$push('`RH` has incorrect length.') } if (using$P && sum(lengths(P))!=input_len) { @@ -509,4 +504,4 @@ penman <- function(Tmin, Tmax, U2=NULL, Ra=NULL, lat=NULL, Rs=NULL, dimnames(ET0) <- names return(ET0) -} \ No newline at end of file +} diff --git a/R/spei.R b/R/spei.R index 3f611e1..03e36c2 100644 --- a/R/spei.R +++ b/R/spei.R @@ -2,26 +2,18 @@ spei <- function(x, y,...) UseMethod('spei') #' @name Drought-indices -#' -#' @aliases spi -#' #' @title Calculation of the Standardized Precipitation-Evapotranspiration #' Index (SPEI) and the Standardized Precipitation Index (SPI). -#' -#' +#' @aliases spi #' @description #' Given a time series of the climatic water balance (precipitation minus #' potential evapotranspiration), gives a time series of the Standardized #' Precipitation-Evapotranspiration Index (SPEI). -#' -#' #' @usage #' spei(data, scale, kernel = list(type = 'rectangular', shift = 0), #' distribution = 'log-Logistic', fit = 'ub-pwm', na.rm = FALSE, #' ref.start=NULL, ref.end=NULL, keep.x=FALSE, params=NULL, #' verbose=TRUE, ...) -#' -#' #' #' @param data a vector, matrix or data frame with time ordered values #' of precipitation (for the SPI) or of the climatic balance @@ -290,8 +282,8 @@ spei <- function(x, y,...) UseMethod('spei') #' #' @importFrom zoo rollapply #' @importFrom TLMoments PWM -#' @importFrom lmomco are.lmom.valid are.parglo.valid cdfgam cdfpe3 pargam parglo parpe3 pwm.pp pwm2lmom -#' @importFrom lmom pelgam pelglo pelpe3 cdfglo cdfgam cdfpe3 +#' @importFrom lmomco are.lmom.valid are.parglo.valid cdfgam cdfpe3 cdfgam pargam parglo parpe3 pwm.pp pwm2lmom +#' @importFrom lmom pelgam pelglo pelpe3 cdfglo #' #' @export #' @@ -722,17 +714,9 @@ print.spei <- function (x, ...) { #' #' @title summary of spei/spi -#' -#' #' @description See print.spei -#' -#' #' @details See print.spei -#' -#' #' @rdname Generic-methods-for-spei-objects -#' -#' #' @export #' summary.spei <- function (object, ...) { @@ -752,17 +736,10 @@ summary.spei <- function (object, ...) { #' #' @title plot spei/spi -#' -#' #' @description See print.spei -#' -#' #' @details See print.spei -#' -#' #' @rdname Generic-methods-for-spei-objects #' -#' #' @import ggplot2 #' @importFrom zoo na.trim #' @importFrom reshape melt diff --git a/R/thornthwaite.R b/R/thornthwaite.R index d73ad3f..f78c99e 100755 --- a/R/thornthwaite.R +++ b/R/thornthwaite.R @@ -1,20 +1,12 @@ #' @title Computation of potential evapotranspiration. -#' -#' #' @description See hargreaves -#' -#' #' @details See hargreaves -#' -#' #' @return A time series with the values of monthly potential or reference evapotranspiration, in mm. #' If the input is a matrix or a multivariate time series each column will be treated as independent #' data (e.g., diferent observatories), and the output will be a multivariate time series. #' -#' #' @rdname Potential-evapotranspiration #' -#' #' @export #' thornthwaite <- function(Tave, lat, na.rm=FALSE, verbose=TRUE) { diff --git a/man/Datasets.Rd b/man/Datasets.Rd index dc66c1f..96407be 100644 --- a/man/Datasets.Rd +++ b/man/Datasets.Rd @@ -21,13 +21,11 @@ \item{ACSH}{ monthly mean sun hours, in h.} \item{ACSH}{ monthly mean cloud cover, in \%.} } - \code{balance} dataset: a data frame with monthly climatic water balance (precipitation minus potential evapotranspiration) at Indore (India), Kimberley (South Africa), Albuquerque (US), Valencia (Spain), Wien (Austria), Abashiri (Japan), Tampa (US), Sao Paulo (Brasil), Lahore (India), Punta Arenas (Chile) and Helsinki (Finland), in mm. - \code{cabinda} dataset: a data frame with one year of monthly climatic data at Cabinda (Angola, -5.33S 12.11E 20 m), with: @@ -88,8 +86,6 @@ minus reference evapotranspiration) data at six grid points from CRU TS 4.05. See wichita -See wichita - See wichita } \details{ @@ -108,8 +104,6 @@ summary(wichita) data(balance) summary(balance) - - } \references{ S.M. Vicente-Serrano, S. Beguería, J.I. López-Moreno. 2010. A Multi-scalar diff --git a/man/Drought-indices.Rd b/man/Drought-indices.Rd index b2860f6..b4d4233 100755 --- a/man/Drought-indices.Rd +++ b/man/Drought-indices.Rd @@ -23,6 +23,7 @@ spi( ref.end = NULL, x = FALSE, params = NULL, + verbose = TRUE, ... ) } diff --git a/tests/testthat/data/penman_out_tsun.rds b/tests/testthat/data/penman_out_tsun.rds index 3120793df3dc47c4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k5b<3m=!IfUG@0DX6G|dsOb{u8SmpPzfhCf9CCn_pK$CYEj|fZ0vT)EzSV$z{;qIbiSiGsiMoqYxCJDr@TM1a>}-E0lPHo_fkWE^8+|cBK~2A1#6t?Mz9z zaWF{PvU?WfD&XLJ`GUW3IDAijS+0moriQ_T(u9NPHgGBTj<-@vEqPs}J}!X~{?Aa}lKY+YfT43^=qWMh8r`gTeMo uX-pmh-DLFg#q29^>))nmznHTZPFf9-QIn&8_kZ`l#(x8Znv0_k3;+P2-;zTB diff --git a/tests/testthat/data/penman_out_tsun_ts.rds b/tests/testthat/data/penman_out_tsun_ts.rds index dae193be4e782658636a37ee72d8cc44372e2bf8..dca2830fa6c8aabbf04ec41a522d2e6c484e039f 100644 GIT binary patch literal 2368 zcmV-G3BUFqiwFP!000001MQaiI~0l<$49nO5?ON9u@ox1vP8>wnqllln6V7TtY(am zV=bb^a-`fA%2mff5mJ%lL<@x$RL35nk_tsR5go4k^Zf(P{o(%f`9ALt@AJOj=Xt-+ z>m@@V5X1=*V&VjG$wf(!^z^Vbuv`=?2?Vi(gERlBN$3Bce-A;rvt+nYV;JrR4GU}U zK7||axl?afAiSj=%$piA!8&O$8%Pd7kYU&;QAP%P$vZyZG8}^_=`){dLIS5ft+Z(! z;Ki*wbY3MIZuyzfKTBJJQZ-#Sd_xJu?F3dqRTymSlN&|Oy`VjKt#rF)1WcZUfWC7% zxQI+VTyPk?F1?+l8UzG?Os7A{_L=*@KSDsz6<#6QAv)26D@befzWwL3(0+G2?Cr z9Ni-iSH#tWPLpK`3Ri+fiDL!bb^&L?Xx;71ci^`z={WeI5W#89Q&E>*CB+RuBsu@26sVqh9~nLK1Shoqctt? zNT`)O-=hTAaUD_FuA6YVc7AHhC>; zn=?VbVY?oJ4HEIxE;VqvtQuS`9)j5)Cokd|gIQAWAjp9Z+Vq{rv%V=HCkzq&=lwx- z(Y=Xp8F0B0R2)}k1^2<6YNMPw_&ID657pHGn|73#qAG>Zve@O7%hIv8?5;NHS}{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xMBV01G{os;}H?2tz_-(0d_HVtDOi0J#(LJa^7nAugNT*+F1q<+JO_5mXRRk zE3KPWu7aEA@gt#@F$muKVRl>06VQd>Qc`!s2xm9;J+D~@HnCAP*gy;X^R{x6*>@oH z-oddio(5-tJTZG(3rtHF)j4iy@GCmNR=0f#(!q>h^xllay}B-Y-PBFEWu+%=yc7kh zCsF6}`+W$LeK%r4d=K{PkD~VFLEzV9rSDKJM1=YeU&* Date: Wed, 23 Nov 2022 11:32:47 +0100 Subject: [PATCH 03/14] zoo::as.Date.yearmon Using zoo::as.Date.yearmon() in hargreaves, penman and thornthwaite. --- NAMESPACE | 1 + R/SPEI-package.r | 2 +- R/hargreaves.R | 2 +- R/penman.R | 2 +- R/thornthwaite.R | 4 ++-- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 8344e7b..4c9865e 100755 --- a/NAMESPACE +++ b/NAMESPACE @@ -44,6 +44,7 @@ importFrom(stats,frequency) importFrom(stats,optim) importFrom(stats,start) importFrom(stats,ts) +importFrom(zoo,as.Date.yearmon) importFrom(zoo,as.yearmon) importFrom(zoo,na.trim) importFrom(zoo,rollapply) diff --git a/R/SPEI-package.r b/R/SPEI-package.r index ae7298a..23a7609 100755 --- a/R/SPEI-package.r +++ b/R/SPEI-package.r @@ -43,5 +43,5 @@ #' #' @importFrom checkmate makeAssertCollection #' @importFrom stats cycle end frequency start ts optim -#' @importFrom zoo as.yearmon rollapply +#' @importFrom zoo as.yearmon as.Date.yearmon rollapply NULL diff --git a/R/hargreaves.R b/R/hargreaves.R index d44c431..327c0f1 100755 --- a/R/hargreaves.R +++ b/R/hargreaves.R @@ -336,7 +336,7 @@ hargreaves <- function(Tmin, Tmax, Ra=NULL, lat=NULL, Pre=NULL, } ym <- as.yearmon(time(Tmin)) warn$push(paste0('Time series spanning ', ym[1], ' to ', ym[n_times], '.')) - date <- as.Date(ym) + date <- as.Date.yearmon(ym) mlen_array <- array(as.numeric(lubridate::days_in_month(date)), dim=int_dims) msum_array <- array(yday(date) + round((mlen_array/2) - 1), dim=int_dims) } else { diff --git a/R/penman.R b/R/penman.R index ff7b459..d2cb148 100755 --- a/R/penman.R +++ b/R/penman.R @@ -185,7 +185,7 @@ penman <- function(Tmin, Tmax, U2=NULL, Ra=NULL, lat=NULL, Rs=NULL, } ym <- as.yearmon(time(Tmin)) warn$push(paste0('Time series spanning ', ym[1], ' to ', ym[n_times], '.')) - date <- as.Date(ym) + date <- as.Date.yearmon(ym) mlen_array <- array(as.numeric(days_in_month(date)), dim=int_dims) msum_array <- array(yday(date) + round((mlen_array/2) - 1), dim=int_dims) } else { diff --git a/R/thornthwaite.R b/R/thornthwaite.R index f78c99e..43b4c09 100755 --- a/R/thornthwaite.R +++ b/R/thornthwaite.R @@ -6,7 +6,6 @@ #' data (e.g., diferent observatories), and the output will be a multivariate time series. #' #' @rdname Potential-evapotranspiration -#' #' @export #' thornthwaite <- function(Tave, lat, na.rm=FALSE, verbose=TRUE) { @@ -53,6 +52,7 @@ thornthwaite <- function(Tave, lat, na.rm=FALSE, verbose=TRUE) { # 3D array input (gridded data) int_dims <- tmin_dims } else { + int_dims <- tmin_dims check$push('Input data can not have more than 3 dimensions') } n_sites <- prod(int_dims[[2]], int_dims[[3]]) @@ -87,7 +87,7 @@ thornthwaite <- function(Tave, lat, na.rm=FALSE, verbose=TRUE) { } ym <- as.yearmon(time(Tave)) warn$push(paste0('Time series spanning ', ym[1], ' to ', ym[n_times], '.')) - date <- as.Date(ym) + date <- as.Date.yearmon(ym) mlen_array <- array(as.numeric(lubridate::days_in_month(date)), dim=int_dims) msum_array <- array(yday(date) + round((mlen_array/2) - 1), dim=int_dims) } else { From 61cd8bb291d92e1bbe31814ec362b1f4abb2837e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Santiago=20Beguer=C3=ADa?= Date: Wed, 23 Nov 2022 13:27:38 +0100 Subject: [PATCH 04/14] Tests Correcting tests. Adding tests for spi(). --- R/spei.R | 1 + R/spi.R | 3 + R/thornthwaite.R | 4 +- man/Drought-indices.Rd | 17 +- tests/testthat/data/penman_out_tsun_ts.rds | Bin 2368 -> 2429 bytes tests/testthat/data/spi_12_array.rds | Bin 0 -> 3075 bytes tests/testthat/data/spi_12_matrix.rds | Bin 0 -> 3093 bytes tests/testthat/data/spi_12_tsmatrix.rds | Bin 0 -> 3178 bytes tests/testthat/data/spi_12_tsvector.rds | Bin 0 -> 3010 bytes tests/testthat/data/spi_12_vector.rds | Bin 0 -> 2947 bytes tests/testthat/data/spi_1_array.rds | Bin 0 -> 3101 bytes tests/testthat/data/spi_1_matrix.rds | Bin 0 -> 3152 bytes tests/testthat/data/spi_1_tsmatrix.rds | Bin 0 -> 3204 bytes tests/testthat/data/spi_1_tsvector.rds | Bin 0 -> 3033 bytes tests/testthat/data/spi_1_vector.rds | Bin 0 -> 2968 bytes tests/testthat/data/spi_gamma.rds | Bin 0 -> 2968 bytes tests/testthat/data/spi_pe3.rds | Bin 0 -> 2965 bytes tests/testthat/data/spi_refend.rds | Bin 0 -> 2946 bytes tests/testthat/data/spi_refst.rds | Bin 0 -> 2946 bytes tests/testthat/data/spi_refst_refend.rds | Bin 0 -> 2948 bytes tests/testthat/test_spei.R | 36 ++-- tests/testthat/test_spi.R | 219 +++++++++++++++++++-- 22 files changed, 238 insertions(+), 42 deletions(-) create mode 100644 tests/testthat/data/spi_12_array.rds create mode 100644 tests/testthat/data/spi_12_matrix.rds create mode 100644 tests/testthat/data/spi_12_tsmatrix.rds create mode 100644 tests/testthat/data/spi_12_tsvector.rds create mode 100644 tests/testthat/data/spi_12_vector.rds create mode 100644 tests/testthat/data/spi_1_array.rds create mode 100644 tests/testthat/data/spi_1_matrix.rds create mode 100644 tests/testthat/data/spi_1_tsmatrix.rds create mode 100644 tests/testthat/data/spi_1_tsvector.rds create mode 100644 tests/testthat/data/spi_1_vector.rds create mode 100644 tests/testthat/data/spi_gamma.rds create mode 100644 tests/testthat/data/spi_pe3.rds create mode 100644 tests/testthat/data/spi_refend.rds create mode 100644 tests/testthat/data/spi_refst.rds create mode 100644 tests/testthat/data/spi_refst_refend.rds diff --git a/R/spei.R b/R/spei.R index 03e36c2..5e7c302 100644 --- a/R/spei.R +++ b/R/spei.R @@ -419,6 +419,7 @@ spei <- function(data, scale, kernel=list(type='rectangular', shift=0), # 3D array input (gridded data) int_dims <- data_dims } else { + int_dims <- data_dims check$push('Input data can not have more than three dimensions.') } n_sites <- prod(int_dims[[2]], int_dims[[3]]) diff --git a/R/spi.R b/R/spi.R index eaeaafd..6037e45 100755 --- a/R/spi.R +++ b/R/spi.R @@ -8,6 +8,9 @@ spi <- function(x, y,...) UseMethod('spi') spi <- function(data, scale, kernel=list(type='rectangular',shift=0), distribution='Gamma', fit='ub-pwm', na.rm=FALSE, ref.start=NULL, ref.end=NULL, x=FALSE, params=NULL, verbose=TRUE, ...){ + + # input checks + sol <- spei(data, scale, kernel, distribution, fit, na.rm, ref.start, ref.end, x, params, verbose) sol$call <- match.call(expand.dots=FALSE) diff --git a/R/thornthwaite.R b/R/thornthwaite.R index 43b4c09..5d17770 100755 --- a/R/thornthwaite.R +++ b/R/thornthwaite.R @@ -53,7 +53,7 @@ thornthwaite <- function(Tave, lat, na.rm=FALSE, verbose=TRUE) { int_dims <- tmin_dims } else { int_dims <- tmin_dims - check$push('Input data can not have more than 3 dimensions') + check$push('Input data can not have more than three dimensions') } n_sites <- prod(int_dims[[2]], int_dims[[3]]) n_times <- int_dims[[1]] @@ -93,7 +93,7 @@ thornthwaite <- function(Tave, lat, na.rm=FALSE, verbose=TRUE) { } else { mlen <- c(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31) msum <- cumsum(mlen) - mlen + 15 - cyc <- array(c(1:12), dim=int_dims)[,1,1] + cyc <- array(c(1:12), dim=int_dims[1]) mlen_array <- array(mlen, dim=int_dims) msum_array <- array(msum, dim=int_dims) warn$push('Assuming the data are monthly time series starting in January, all regular (non-leap) years.') diff --git a/man/Drought-indices.Rd b/man/Drought-indices.Rd index b4d4233..1106be1 100755 --- a/man/Drought-indices.Rd +++ b/man/Drought-indices.Rd @@ -7,10 +7,19 @@ \title{Calculation of the Standardized Precipitation-Evapotranspiration Index (SPEI) and the Standardized Precipitation Index (SPI).} \usage{ -spei(data, scale, kernel = list(type = 'rectangular', shift = 0), -distribution = 'log-Logistic', fit = 'ub-pwm', na.rm = FALSE, -ref.start=NULL, ref.end=NULL, keep.x=FALSE, params=NULL, -verbose=TRUE, ...) +spei( + data, + scale, + kernel = list(type = 'rectangular', shift = 0), + distribution = 'log-Logistic', + fit = 'ub-pwm', + na.rm = FALSE, + ref.start=NULL, + ref.end=NULL, + keep.x=FALSE, + params=NULL, + verbose=TRUE, + ...) spi( data, diff --git a/tests/testthat/data/penman_out_tsun_ts.rds b/tests/testthat/data/penman_out_tsun_ts.rds index dca2830fa6c8aabbf04ec41a522d2e6c484e039f..e94617183e74e47081091f66317fac15c4b5278a 100644 GIT binary patch literal 2429 zcmV-@34-iX=K10I{_=XC_xXH2 z=W{;id_L#vD@Py@BnXmX5(EjU1xb+d_HtNbz2Ge&5XAN-fBNbzD)>MD9)fgJe5hV~ z2%bHfl#LsLK;7N{@j$yC{M2}VX()Sv^~2iV6G+qGnJ&3b4|KrJtslzejLi@hReE7Y zuK}F9!@MgtBk*-44(rlagPQrkXxQ>1$dxkwvC7i0-9lg$R*7J5x~pW=`#pT_y->Yg zGXiFaB%fxp7+l1p>@VDpkaiQB3)%z-UmvQGdNYF1(XznXVl80FUFezFR}GpqyK{}6 z8Jxb0jjwwy1=6;46uGftP}PZ6WZh;s5nbddk_DjWOh2A2bVcynOR6>MF<=jDB#upA zKxo$U>_tuE2v;k2krwL)=P=)G{#HF$(j&qq`AE?EKPNlOR>4EwFe%4h19r`SL`CVY z1?kb|vl+MA;A~DL^$Bf2^HE^&izPGIq_yMZ%ds(JmyFhX0!+mc@uL3p@vN-C!S zJpD=ox22cB%3~!BtW8BgN?dr${vJ@D&QNT-wcxN^dqAbI2&8}?m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?sD8 zzaNaf$r;>i=c}|>`pf;m!T9gG#3(q}F{G_CHi0&&A1XUv4Cd0p z;8Z6maL(y38K2z(p|<+IM=Rza{2Es0EjtD70oMoQQ(oYf9g$Czw*W(u6X&n$3EJtn z@NrpJP_zeJ3o5GM9+msK>mmtM!imkFdHdmYYl)>=R5&;ryPb23Gr&EjAv%|{9>P;{ z8T5Dd*!%s=v5eLz1o^AVnz}fGosZ)RC0<~po-&Wi+6j+csm1e0i{MB2RM(mo09d1u&)=I=o|oAQ_D*fbof>(ckkKZJc+a_rByLO^pO zs^6YG1%HXp<9ftNus?nkwQuzXza}mDh+y{>12j$#w*=eN!5fhrloy my?inI3f%g)DcUXOtfN*#WYpy7-~HeHukqiBeMQ+13;+ONpO|$3 diff --git a/tests/testthat/data/spi_12_array.rds b/tests/testthat/data/spi_12_array.rds new file mode 100644 index 0000000000000000000000000000000000000000..e9d84c02d6dfd19d740a4dbf2a935a5d6d8661da GIT binary patch literal 3075 zcmb`(_dgVl!vJvE&K~9Lb@nF0b#iBBmC?z}NLGmJY|iLxoxLJ=Mr2$kq0Gw`A2XxK zNM)S8*YSP5p1$yEcm(m=0CUiPioZ5hjf zikJ1e+}>`6ZWA;?KKjKa13IbVaNg zxs5x1ThLGD?kNmrak*ml1M7d8Bu6JT#oQ;{8EJ@!lAg}%8Dz5!_)?(!N6Rz4*iUOI zTefo6+JU;CNh_?u_klpO3##mksVjfSg64>~ z#(G-X;>s$x=Xm)9Ob$hs0@m();$jmXi`z4X^;zB6e^}j+gby1KSabEB2pW>b1|L)~ zU$C~L7knjfp_nxt#UoivEHb? zZ9~j4OnPiTn_!<9M_fpw{@^J?po2x2>nH0(?yRm#dOpDhO+HBQxeU=^4{xgtTnBLB z-{0k3<^`-zGjJ3KLUu#RM*k~Q ztaNAO`ia2T>V9ZNr``is^%{wXBMwa3LIUqYrWI(mL{UXo_g!wxay%EkpGEacA&DmT zIp30<&9epBIqD)0IrM&Zf>K0{OkdTdXzCoRH-w`V5U1I`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l0w$b=1=qj)f%RclJfjwXe7G5=bae;nVPu(pDu@WtA^x!FH+u-$ z;F0lGU_4T4yc+B}L|rS&rK!Uw=Og$`G*J#kSugee9Y3|H0}ycwz=Sq_j^j;cP=wE^ zz?-N5J{HBiZuTu-YxPxzK$Mw}Is5ItfW?YI*;L3tW7ao+?>TfEM)IRQ==?~BJ<;&nygxr(n)RB*b-=6RZrsvGg2i*!kOu2uo0`b-7j1{DdPUeA$w=Z=Lc6NXo|_8 z2mK2s&0R)67>9mf#C2wz?HxZ0vznSAb}n>pDV@%*=_lO2LAxL?r=5`#s~mY9Q}XUk z_iPu3q3@B1^MO_oquloxzmo{7k|xUAo5MQz1VFZJs^?!0HE74@&OvK zkqgl+JR5@n~m8iC>k?MyQi#KHv$!x2vs0t*aS70O{(0=P!pOPP;9pq{_rH zd7xEQ5SJ%>_^hmjh-X2du=pcHVy>$GWF}8o#K;JgZ9xA?Zu1# zmt0+AP8g^&iL6*o22j_xPF6CcZS*>E>bm1hk}VEZPDCwCbW)T@SNsMjQBeF3N;Czc literal 0 HcmV?d00001 diff --git a/tests/testthat/data/spi_12_matrix.rds b/tests/testthat/data/spi_12_matrix.rds new file mode 100644 index 0000000000000000000000000000000000000000..7bab2d0a658cdd6937a0085217296e7903c12670 GIT binary patch literal 3093 zcmb`(`9Bkm!vJt?#1P4toVhZYBlnUkXKo=!Vp_}*a(^sgO0FWg$~h%+4#_=Nj)|e< zX0Fy8p2yCqZ;AJQ4Jyv-bQ@H9ic=YhDO2~d z@UmsgiaT1twSapvBdhFInB%9bo9(^#l6z1k`-U|(ehx>1J{7?04i zzzA!lO{>TUCu!3y;pr!|)c|*^SGB@)P6hhWzc6G~T|hO;Iia3dQo|&5I9fks6G8a1zBe{`%8L=zw5;95|&SXX8HGq5Sg&gg`j9B$z-I1!SJl1T16w^B> zgB-gkQQaYS&1~{I)m$COfZNrmuJdp%)FdiH@yy6ZpkSI&O}F0N(W5o!6NIr+A$~9l z09(E??quXAfcA~nBgAvl7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^dh=S=2GRD;zfs2%R68BaCKd?Nby}Ls&9!SSnA!c^$bD1 zBI!M~a^Y*qgsZ%T+mcqNp|P;X$=W=@s(k!f!*_;EDISwO!?EDUpyuzNt<82i5?YX7 z;K}?{4;$sUz?d!xP9fO?25qEUPd}KU<_KA12inT*c@Q|54T3x+~E~` z+?77J<;0h;MIc%>(o}b*Uajf}&pN1kD~`{##Aje4{y%rU)}3Xug?qBJ4+`>eQI7mG zJNES9A0p`?WR5%n1d|b@hRTz&3qnVC*3A-4^S53S6d?7z@B*nx$0zQE)JPH~vWW8Z z|0QQ<0}N(BQsCt^LqJmP?oQfiKp`Z1e1q&1zzfV#S?@G{o^8_Zs?e+`CS7$hD(vyE Ph^E1Mpq{3n#KiPJ6CN6) literal 0 HcmV?d00001 diff --git a/tests/testthat/data/spi_12_tsmatrix.rds b/tests/testthat/data/spi_12_tsmatrix.rds new file mode 100644 index 0000000000000000000000000000000000000000..5ff2b93cfe32fb8d700a76e4918b89d3a71a04a9 GIT binary patch literal 3178 zcmb`(_dgVl!vOHCl9_#Rw(O$g$|kZu<*ecqapH6`vNwsNY?*Oq&&oWy<8aA1WF;DB z&$zSao$-CWp1>e0#Bc4Y4AAoM8W zllv#ykG)eJtr1Ic`j{?bvE6O17U*Pa%OO+qXh4@B+C;w zaqJJ(8d*3Jm>2p{Et_nE*8Ol4QK>|@i~s3VAwAHY{IMTe6>=x_L5{51w7XS3|FIg~ zm6r{TD?~i|A#KN;cs!UHc?)0@VYj)DV}y@jwZ1qw@#UXbc`~*<(8JhnSY(9GK(>9h zvL>t5%W%2zhrpn3^FpmZKc`R#UdD3zkJbQzANcC-npS@u1~(o}^BvSrP@x75YqH_k zfC9^~ap8@Qp5d0OTRq;bp-r`Mu47@(2qUSjtgz)1cIi{sA`^t9?Y}e?NL<#9kNi3J zjw)C;j)X%QrXAR0n?$W*pi57=&lbSVIYevTex6aK<525dJnuf&5*6tVEA9@q5)-fE zXZ@XhI)%HE?z=HW2|S=D6PQ#iwb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x!4Lu>xu2&qANt|Nhw~O7kAc;oRo|0YTvlg*zvbe&y0FdSM}d9jT+Uut%>&AwO==| zJD5tPk2=`dJ~+`_KI`<%LuS^sw#}wWJ|$^qe;wE=H*brXrCmTIzSu1MTbidv46Jvq qGqXlnNS#~5me(np>ymZn-OxoOW`%R3a5n7h3Z1w%a#{J(rT+ntn{2ND literal 0 HcmV?d00001 diff --git a/tests/testthat/data/spi_12_tsvector.rds b/tests/testthat/data/spi_12_tsvector.rds new file mode 100644 index 0000000000000000000000000000000000000000..6b11879898eb91eeb99ff1f18943084d3cc45424 GIT binary patch literal 3010 zcmV;z3qAB7iwFP!000001Fe^NG}Vh1$A5<-qKK;qMO5TbQ5m|lkBDwuvx*cllm<6L zMP1w|8m@#)6(W^fp}Z)neH6(&9#b6WI5=jvKVI};@cQc&>h4NTst+2!wox}a^@5niwfbG zUPo`1^(kbv&J~t0jImAEeYYUb6}zi)mg=4@V#{Tka_^ZmtOtHx;6Zz=u6uHSqvHYm zQa1VWq`w;m*B+KXy*>##^R5i|QIE;HjjK<+j(GO2x+E%kAT=`jej6@GWk> zLu4O*yWO8#D=ddTLrebtd_5SaAYeGQim(rtEX4FRvG;|{YKclW9CSX!T~BF1u4|BqY0nDm5{k{0m^MMWWJw@HG69=< zUW-TjO5wO)UChYay*Q~Fk$i*S7bhHauic;7fJ3HU8kUXDNNaxHmQ*!{udi1f>C#Dt zmM6q+0S*FtHxeFEG+++|d!339g1X*M&rURdhMG-39j^A_0afJDveL!NP_U-rXt;9- zq*=y`b;|U>r^RDW_J6a2ilk_Dx0&@&95%AvXGc6R9IZmnN}Pk*&Jc|jITHw?{`R@w zdju;V1(y60HHlfQ>Hry25%_d;r2J{S1hfnNar!5@1z?M@Nn~{nbUP*F^RumhYgv(T zw{#P5p0ec1k{`hE&B|zlGCvr%9n^Rzas>vnd(Xv0+XE|-`Q%mBBVY>$o5m?x!|-GC z{X#B$FyNlt(jQ|BtvYSH)Z58WZANMHr#*$9qTuc9z2M(r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@gf+<+WiwHFJqeWQA^#8%~tXMIz%(m>HAl)_f#_+r^Q^!vUL~#3v`zY2uS`1YrhJvF zceJOr0(?6`5O4Ut=~G}prellhzi?&Dp<7Cw`U0-Suw|P3>&8B`T2sOFPQeJW{An*x zwMi6akHQH9MKrOpvfO}^#9H}8{iBQjT=YgA!afDL>4#o-)BsvRky`kwk)AmomrtQ; zXN$H7t^hzisHmTRhQZt=(8DY142&UE_;S)yb}684|Arx4=%b!Xs#N+(pI;JJ24%sA z!0{xMT3wX$4Hi$;zJn5vZqB&dRg0LJW?>g#}Cv1$v3qF!#kwM>73)=rowB$Af z*-cI7mKvM$QZXph%nj^;UVOON1Yb+#-!@xzDckZ4>QJ2QQcCweK?bqA!~NC*DQI+B zXL%FEfYn2-i`yM{laE!kh#f$Veu)QBpMMzkg>o_i}=$Tb*)n9ANa6) z1ka%g-QJgcJWx2YfW)Ik;^K2O)6ZH3=DtTGxhrffnuH9dLX3{^d)tPRW_?8p0o2Z> za<|CeA!w1F6J2|wj*pY@&Nx~{WedmGX5~BCSS5jWV9>10sXunDWbq#v*T(sTM5M6} z%-efg2Ja0L>Vkz7b41=`J}uRwWC*vrq^gza&~@1q*8w;n<-MX)zK3xU^GbTqAGrwb zM7yEmG3g@Hy`_NG7IKA7n-Fb%eb><14QsD)G7JR6V^W1Z5Et-Nowa%NdqN6=y#F~T ze3xC|a(3A7Bzp9pA*8d|z2!?>j+lkaw zjT^IZS{nA5^)vYpT*?yczSJRh&yYru=4WDM1eGOo!b@4?WiU-{{$N%O}Pa3mARswDb3>TyU UafI7#l^beWBN=K+F%pvh0yJ1X1ONa4 literal 0 HcmV?d00001 diff --git a/tests/testthat/data/spi_1_matrix.rds b/tests/testthat/data/spi_1_matrix.rds new file mode 100644 index 0000000000000000000000000000000000000000..b68981c80389a577291d8ea1af09feb123c3372f GIT binary patch literal 3152 zcmb`(`9Bkm!vJtpu4J;IIp)64%vt8B+#xh)j#926w}g>0(P$<_SmX$~uiTTH-ig=_fK!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uU=au~wy+vsf*R!E)jRy>EkzfhgF}hnV zt?5dfjjrO-^Uw+LT)A+IhNHNEOa5s~E|co=af&nFe@_nQ8ENKlmxuRf$PM6vf@i(2 zvK`vC%Gt8f6Cyo|1Ors-c8%aKL#(76s>=tb?FA$D^DT0(GWRt49t;APD}_vFLh83! zrn)R7Pzm!D95;h9hY@#|gGQ@O#w}katE;Sg*F3vs5>sn>${{?1r2f!Kzu7VV zNr2a7Wt~mJ4jI#Fk%9BjG4n;ShMeH7<>9luV4f#w*w{-8(kD5c&Pw;3HFc*(QSXHV z+IpQo?fRSLSiQt>+zQXt8|*M6yXl@=0j)S$$IZz5@+zPI^d*IQz%==$t$Z z(;@b+S$FrOY2NE0ocnMH0a)BIpM2oWpXhf(Il=t8n3J{^+jXhA-XjsmyfNfpW?eEPfM-k7L=@*6x=fMdXTgCv~Upp#oi&>{Qelyye=2+WB{CN`~C{P={`X8-7 VgDTocIdPyd9nhqJfl73A{{vckRN(*s literal 0 HcmV?d00001 diff --git a/tests/testthat/data/spi_1_tsmatrix.rds b/tests/testthat/data/spi_1_tsmatrix.rds new file mode 100644 index 0000000000000000000000000000000000000000..0499e2a4477bac5e2b99b00722d65b43327af6b7 GIT binary patch literal 3204 zcmb`(^*bC60|0P+`b_s}lc#f-9$tKXO>>&l-Obpk`XA-IO&s1u3z*xf=q1R8Ka%Fl`$(9+aYfpP+IAZ23Jq;C zSD)soSR=?O3qhY9!)UsuYq_aR0k9|zkuO8J0;!4oL<9^>l_ZCJG74j)) z@Eiri_y`(u(P)uYYw!>~X*tT`>I|CD>1SAW4qU!uz9?IwJQKHyHw)YJjW&y-PHLoU ztbfCZK3?AM;4&fa&7}^7R8CJcJam1N&4%#sMT`Z`#frR(q%U_b0&90VPE_O#u%7fN zi8PJ0aUS8e4{BEi@K*pZ9iuCEm#y!Po9Eg?Ply2nQR&Kz4IP`g!41P;8@JDYr}&=Z z>Md=0o#7X*)~*R3uSu!lo~4noD?_X%NlC_lKQ!9u_Nl%<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X^cKa-az){@V$K4G^X=olV0qUdcMv0Jz!+JUch*R_PqOjXOC+k^o;ca#as z(M^SKih92OP0l=If!Ygs^D3=#l(fFI+*wPOXt&W*u<%p7dC7RToSm(^HWYf4SWV;7 z_pKR?5>Gi7SDgzlLle2C84U=Qh&1!d2qR^<@$b>5M#_IT9pd|{!G?NNTO?W`$K5_! zhmEYoE^4a5{?vb_9wqx>s$Z}qwF-Ou;O;qD^TbvJYVAaZ-(O~N`^D}ZW9@PAw_1$B z(E7y242Ol@WPY!oc3G_N`hqZ}iA-XadOH=jhyQjgp7A(OBb(K~ROY5SGgY&t%&UrV z+`mQ1ral5sN0+YuGMUNk4^p6awy-JZ4N|C=Y{N=D7 zBl*_vruDiH0}D8tw7uZ8(i->-#*990@5#VJZ}rcGvQzQ;%%1QMY>zAQ*rvgou7OKT P_aiWhVbXVB0uS%Mwi8ab literal 0 HcmV?d00001 diff --git a/tests/testthat/data/spi_1_tsvector.rds b/tests/testthat/data/spi_1_tsvector.rds new file mode 100644 index 0000000000000000000000000000000000000000..31840d8f7a1c7b96cc8d7235d68ef1bff1d7b758 GIT binary patch literal 3033 zcmV;~3nug*iwFP!00000167xKI28K#$H%^eD1)f4trA^plv15hbaNGvq_kL~?ybv0N7S(-TQu2a%Z#xMW5&p!$hZ6Z{<_cid;U4^=lwjN&*yp0b3U*0 z`PhjP2n0R?KMx;)PvD0n2pqB5r)l`ZlOPay0$|2DOZ$<|2CRSNcJG_wYnYT@l>d`x zhNHfN-WyUya45}b;O=q>E}x25QbAfJkMM1aU8gL8;#uxbH{F6P-QMFFV~sc%u_~+A zs|9KQ;uK~!eE?>^XB#{H3o@SASdDv=aaPKK>)z>(<%->pgwy(6zcL6gKAdQ4 zcYX)H&8jOEKQoKd@@ht2U(~UYU)$;BBo|_-iE9=#Qh{~8vE5FrAiSARRA*6kQ7+MU6153%A#s_9?*W$L4b>L9;Mp`Rg8+gRL+Vj0A_9?znuM zYw@7T9~o0I#g|ejNNbHzNeDTBvo*R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N6yL23xm2JARVuI;l2|t{J@70Sa5;Hpz@~e; z&_4UV+$Tm8XbXG$59zi+t4DV4YNHJNysuNFD7ONJQ)t3-`69?DYOPf+)q|x5=b0m3 z#yFe4WIAW3^^^ZNTXy&Q>wEylyW%NJ#)j(9@wuLtK9dCal z7;*@wi}iU+xh+6lHPw-L#tK;X4rwlBEdJyJiBJ^YRr8xRjO~h$51RXq9rJlP50baz z7{xtQN2VUxO40>u_b&l+pw=YvY7&grMQUbGRg!om&)aO)PD1t(TDJ3VH9!s~Jif4~ zU&%LS_Vk-eDRw>ccQ9?{^4_6cCBNS%{3(7lA6$nN&x0tn&~LL0cfoI z#c@Ncu&Y&3zNT0jruJyOnLjX&%<$if>^7ABGrvZ?$p-4%5a_$*tWHfy0zK&R=FA}> z9GQN%jW1yo=AC@PH-kNN9)I^@=NB%N@V=E#e;Wv29w(~DhL`}Y+2f}9-mB0+)qnUo zHR$L5z^Ea2I#Tc8yndodoRApITqB(wS6;@Ug)szGm`+h$s#Io8PK zx@OwPk$4{pcD~YV0hU;^zp73-e7?;J&DtM~b@7UCFuv z#LO+GZ`8f6K+kqwYyLIv(4H^L6jUpNsbkW-MVi}Sq^|6wx|k$Voq9w|%fpcVQQ7Qd zj{ttU@iI3jwH>NgJNtQb)M96NY>-h(3XZXsooxc$V1i^gmL;tSAA@3tG~M>$nfgYt z^Z+jOvRwnjfB8{I-#9I8xg?xP*NNxoOGEXyJKc6FLO2)faIS6P0May#8?(nn;A0Nw zR&RtHawMKu5`Wy=o~u$*WaSW~6K%uflsWJuXhzH|b_kgwt(MDr+o0Nq7&EYbBaY~V z<+X$lV3j}j&GNUK1Oh+rk2c{U@DoJ-{up?9di+Qde@jx*e|m_N?Eas;iSYmNKT8Ch bFF1O7{t%M?W%7Fc?R@_?weF~+Z43Yao1*$h literal 0 HcmV?d00001 diff --git a/tests/testthat/data/spi_1_vector.rds b/tests/testthat/data/spi_1_vector.rds new file mode 100644 index 0000000000000000000000000000000000000000..07b8db9b09e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KJ~6PC}uyO(3n z^FS{XXFuf0oV^^sJLNwDC2*pl=&_gzCKCTiVrgfYU`z2R(r2O6UFG!m-LWd`+;6Z>UN>r z#d)J-^8^tI;9e)5om5-Kk%fGr3#Tezgd;?wCu>6gfahjvvK7`T=6hs2B@p=^33tEN zX#X=ymYT6VJ!_Jk>-$wZE<3VaHQAJOsLhi4j_B{G9}(9iY=lKlOr zkNyd|dWtE?&D2li7|BBI_q)B0>LNH7>U^$a;Q&%~%$jp2#o$vO=XQUTB66gj+Q|L< z+rDcuOp;m{(&QW>6xBHJG=wW*89#yyv38qf!);LOCl@!gej|?QM-;S04q;6o@9pyU OTmJ)umak(E3;+P+chryo literal 0 HcmV?d00001 diff --git a/tests/testthat/data/spi_gamma.rds b/tests/testthat/data/spi_gamma.rds new file mode 100644 index 0000000000000000000000000000000000000000..07b8db9b09eceee19b05e13007c1087aeace346d GIT binary patch literal 2968 zcmV;J3up8niwFP!0000013i{`G!%*#$H%^eC|lICRibB&QmQ+OUY;V7lom_WdlmI4 zA$yA`OHWbRGf9^05p^xe7EN~9GGi>mEM_t&^6UK0>D|A+f8Be|_niCrejUXL1cCrT zkWYXhAoNobgpSzn(=queqzDAQAmF;?=sniofQ^qm?|)Z$1Jg>2O8>}N;<*2??}l_S z9LaDUy0=`0%cl}m)sb4wCwj+v*C`tydshb1EVdxap#ON*L^BRYt;*^5X+!F7oZ{@3 zkH8r8?qFwrMfy{F+eu#%&dNCRyt=)xQl|!RN0S{K&+ou@ISu8K zXJ&CmNz>Hls}?p3>bbs}=0Q9qdCh`$IxV6YNN2{C zUQQz;wLMNfDeM5w)*0A7`Qr|D69nT!Gl(!^c-ZH&(=nKFPIBvET>t;MKgxE2FFE#nP{Qk{CosPRs>tdrY<6*qltM@!w+g8i+}Lt6X<&y z*ZM&<9j2>tJO@1LpjBepp{_m_S<5%~IK31FazzoXTCA1G=U`!Clkp5DUubJ;%J$*> z6zo6puQ+nWmPjxC;;RJ@&)S47Oe(3D3(Gbo)0U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~`FR1{q;EOYx) zM4C9#Y<=yw*gglg!|A=1NzGVlSD(=G&;cie78=5`?SK&wt+Lv71N^AnC{{eQh*^)- z-6VcD#QvsN$)DGxVkhNWL%y;**64-QG_K!@Grp$%+bPeHDkPC{;wV7(8H4kzg<>2H zG9;EKm*PPGr=jL(5`Ihb-%3|Z2TDk_GK(&a4fC=?&+`G7Q&$FUx^DoTvmYw`;&gzz zuy^o~K?k&7%I#lmnuTBXb&HkcSHWl+RdlXU4Cy89^=jpYu+-$nJ>p}Avzbd4bB?;d z_>Z#{_inr?1fah!W!jj%0h%*C%4u^9Ff|6aO}%{Bn_gbQ61Ky(OWBp@Bi8@dPdFnf zFCW~ffbl_Y$7Qks4AD;55~rL4tYd>|4^B75ro)Psp#QA#0mKd@`QAn#%7cAOx4h3m^VB3o6q zXzl(bU<}opM_)^U@rG!fTxKJ~6PC}uyO(3n z^FS{XXFuf0oV^^sJLNwDC2*pl=&_gzCKCTiVrgfYU`z2R(r2O6UFG!m-LWd`+;6Z>UN>r z#d)J-^8^tI;9e)5om5-Kk%fGr3#Tezgd;?wCu>6gfahjvvK7`T=6hs2B@p=^33tEN zX#X=ymYT6VJ!_Jk>-$wZE<3VaHQAJOsLhi4j_B{G9}(9iY=lKlOr zkNyd|dWtE?&D2li7|BBI_q)B0>LNH7>U^$a;Q&%~%$jp2#o$vO=XQUTB66gj+Q|L< z+rDcuOp;m{(&QW>6xBHJG=wW*89#yyv38qf!);LOCl@!gej|?QM-;S04q;6o@9pyU OTmJ)umak(E3;+P+chryo literal 0 HcmV?d00001 diff --git a/tests/testthat/data/spi_pe3.rds b/tests/testthat/data/spi_pe3.rds new file mode 100644 index 0000000000000000000000000000000000000000..fefd8c8e9620a0cf43b8040c07c2019bea27eac6 GIT binary patch literal 2965 zcmV;G3u^QqiwFP!0000013lJxG!*O?2k^1AkR?Ssg;Juo>?tl;lAz=XXxszwRIR+&`Z4JfH95Dor2|BnXmX z5(EjU-z`DPd7q7r@$W{CKoGkMf~?q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sQUC1eD+`~ zySL+^Lqu>f$)N+jp}BG^hfgs4_i5VxItv)~a*k8?e+lFdx|fbbcNm%^qH19#EGT7sR59ejl2mwSVllpUXX`_4atN^i261JvhARa$o?*;uc=)x_*!IZysLKN@~-q5IH>7+%DFP znu!-TA^Cepyg-vX!AUzd3h{HFu03^c s04=cGleN#|(Uk6^oE!ID(US1PoyNp5G`A93NVf9&FAv5swhs&d0AjkbA^-pY literal 0 HcmV?d00001 diff --git a/tests/testthat/data/spi_refst.rds b/tests/testthat/data/spi_refst.rds new file mode 100644 index 0000000000000000000000000000000000000000..afd53ae0ef0a30a18c660d5b0506fdb4cc26d7b8 GIT binary patch literal 2946 zcmV-|3w`t-iwFP!000001Fco*I}{2Zov~$2(V~UiLUI$=Qi%5_2`#cmQIyJ_3MEAm zTF7#RN)(||SB!Cyd8fApKQ;Hk;A#cAbzeTPn?{{AnB@H z!68?dFL~53>=P{gCQOUKQN35sQvJ2DbIp@p+q+8G;_JZ4-6x67s{O~*&+1{VGLIO2 zb1ag$4&wK7JkYKf5Z7($2~913ey58$LwQ)uYn=u|NaN3zu$IX{`ciRhagiDR{HU7Z zlKdXWIa;d>2RCGdfA@7;*M|M`{fBGalCV)=_+iZg5} zG+v#o|^q(_p)V3APE!ZK<$X#L_Gx|E)xIXxeAyV)wNN z2BPfsV&%*5m(F%30RfqI)Z|cH>5_rILST{-+z_?@S7AXn) zAonj1!+^sr{9>FGUFdgZT&JJmT31guQ zc`YLtzSmNI?ve{ki4&cNd<}rX6k1dF&vT$lBuF!qTwuWNQWQ_OJusW(LyP|N5{3e+ zZMN;SgU0HrQg7o=zx`yg!MQtIlIj+%-+McdeMTs_kKuM6wxz}&&0*E zyA~p33vn@$7GLNVhs)xd^;hd<$=q%t#%p;Wkog`LJl$(@kIdB(yNxzWClgIv&74|) z_kSI2{`GAtnXkIcHFW(ZGI#DpwT$*coL8khPz#C0aSY1!6Iz39p4E{fK4Cy}bm~4d zwF>RF7yH(JOM==0cIM>ivrsEq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cH6#5L-C$HgHjX~r5~ToU3EuxRVWg%9et>Y{yd=2dBg!dfGo zCe#T3@sBu;)$?x@mzBl7M>6});1V)zsgHV_qapK@US?j>TKwiEOO$-hfe%-%9n&1H zf|orfE;>tI0m{MHBGnOHpg%~n@0JXJA(gt+UCBJqabU#i2E`0&dk<>fpzQ zORms(BvD@AEeQq;f~PA^EkJJknlUi4#rWl2=(v!Fq%z6)t;BR_fy<9KovZ zg6>d~V9Br@&}BSIcC;!(X+h=j<;%d>lfhfk zY7YHUU%Yp_&q2$Nk#kb!zSz;!Wky#n#g_2ej}m{SVZUydENc%NnY*tm@|51kK2p}! zRFOwmr#%X7fYCx+3##2Xmm30&nhTW4m~>l zQ8FXV@WVL9-PXDi`R|?fWuF^)APM<8;)Zp98jEbYFH}LB-6-%k*N7x@YuXvSNfeej}Ijb0vrr8P%{e$d8da|!c@bx%S{zKP sosbpq*{HSU4KBK@QXG@Ykv&mVB`1C#Ig055!uE0h1;_qL0S^oS0PA46ivR!s literal 0 HcmV?d00001 diff --git a/tests/testthat/data/spi_refst_refend.rds b/tests/testthat/data/spi_refst_refend.rds new file mode 100644 index 0000000000000000000000000000000000000000..8818cd9494969da3bd3fcad72e0704d0af4632ab GIT binary patch literal 2948 zcmV-~3w!h*iwFP!000001Fco}KNODtzhp#1WE7PZDj6v$%IkQSriM}(X_!g8>rmNg z7;mGLkrAr5q*7K!<#m*ua^`Vz=j=P<+;KLazCV0Ff5GRc=kxLW^|{WA5eS5(1i>Xs z2}_0kP=b)f8B@*Of5<8VVTpgh)c-k zbJtWvNEwp}%7c@MHF7wm)L`~eJsmmn)_cdIEOB@)$9;UVW^O;1d# z77n_xtm4rUI}h@t@2W;&%ZS67eR(WQ*UmBI=ux3@pZ&aoN(z?M8h=SUE{GI;_iNlj z7x?&~vqKaDA+DsR;6r9HR88o(N5Aw1M%8hH-v$A|A|)wmzxRfLqiZKjPEJ6NW2myZ zZwWBp_3zH+gaG^6f#<2T0$?+}26eVi0h3vKGWH$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k(=ABaZ{6VaZhEZ`kMHE~C?ArPP5UYi`F|bMy{PR2 z6zKrxVx5B@FRg-;@n((rv?}$DFv^@ z$DwUj;Bv2bC{WLvy4r~zfTq`0Yhvc^LA&%~>TtLX^w+JVd?T-eah;#nI|9>T#PF>H zg+c-P(+tH8;lt3aBx>;2(m%iAvi@#x@&pX08p!t1@530Ke(aV(6O5@%SEc)Bz+mjL zJ;@Tjz)ajI{QTf`pawR~3=4F^uLk1q>Z4KkK_SiLgijxEmd~7_21mkhXdQ-q7KTyd z4iDk5HPG*FYI~{i9Sqz*!?nW0&>=myMUvA8l_~8vZ!Q`^oz3QsQ+LlpbKeP-bwxjb z-4cE??{x?CHl8EVWo|(GcjE2D@BnO3-)!G~goQtnrNe@QCb8?$oV#LsA$CVid>1v0 z#5SgN=lGM=5Kwe0h8{csIkCLcJhxjwD}61q&U+jfnZI-G5?Z0|&33=NQzU4A`8FbH z)1Us%9!O=G$qRs}wbceTDW8F<>un_6#6!dOF|tU}u?a9L_{ z)U!!MLVneRFqUVrwWu4sq)&DWp6cS~iGvup}>(f;>Jn}voZGSy%ua%?|paI@i0;X#Ejd5wqa8RH>b>ZJyMd39T|Em$c8V^&e=-g&_^fr ukK76zyRbkidh!+dLD3yf86G%A^Ib36(Tek~df`@&rTzm&x}0PW3;+N@n9 Date: Wed, 23 Nov 2022 13:34:37 +0100 Subject: [PATCH 05/14] Minor issues Adding imports from stats. Changing fr by frequency to avoid ambiguity. Adding , ... to plot.spei() to conform with the plot() method. --- R/SPEI-package.r | 1 + R/spei.R | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/R/SPEI-package.r b/R/SPEI-package.r index 23a7609..e0aab84 100755 --- a/R/SPEI-package.r +++ b/R/SPEI-package.r @@ -44,4 +44,5 @@ #' @importFrom checkmate makeAssertCollection #' @importFrom stats cycle end frequency start ts optim #' @importFrom zoo as.yearmon as.Date.yearmon rollapply +#' @importFrom stats aggregate is.ts pnorm qnorm sd time window NULL diff --git a/R/spei.R b/R/spei.R index 5e7c302..2ed826e 100644 --- a/R/spei.R +++ b/R/spei.R @@ -516,7 +516,7 @@ spei <- function(data, scale, kernel=list(type='rectangular', shift=0), # Convert to time series if (!is.ts(acu)) { - acu <- ts(acu, start=ts_start, fr=ts_freq) + acu <- ts(acu, start=ts_start, frequency=ts_freq) } # Trim data set to reference period for fitting (acu.ref) @@ -748,7 +748,7 @@ summary.spei <- function (object, ...) { #' #' @export #' -plot.spei <- function (x) { +plot.spei <- function (x, ...) { ### Argument check - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -812,7 +812,7 @@ plot.spei <- function (x) { # Convert to time series if (!is.ts(data)) { - data <- ts(data, start=ts_start, fr=ts_freq) + data <- ts(data, start=ts_start, frequency=ts_freq) } # Determine reference period From e6401ef299d502bb9bacdff24792c7b64cb08c63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Santiago=20Beguer=C3=ADa?= Date: Wed, 23 Nov 2022 16:51:24 +0100 Subject: [PATCH 06/14] Cleaning for R CMD CHECK Solving some issues here and there with CMD CHECK. --- .Rbuildignore | 2 + DESCRIPTION | 2 +- NAMESPACE | 7 +++ R/SPEI-package.r | 6 ++- R/data.R | 33 +++++--------- R/hargreaves.R | 10 ++--- R/spei.R | 57 ++++++++++++++++--------- R/spi.R | 4 +- R/thornthwaite.R | 2 +- man/Datasets.Rd | 30 +------------ man/Drought-indices.Rd | 42 ++++++++++++------ man/Generic-methods-for-spei-objects.Rd | 11 ++--- man/Potential-evapotranspiration.Rd | 10 ++--- 13 files changed, 110 insertions(+), 106 deletions(-) diff --git a/.Rbuildignore b/.Rbuildignore index 91114bf..fa76b93 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -1,2 +1,4 @@ ^.*\.Rproj$ ^\.Rproj\.user$ +^data-raw$ +^_config\.yml$ diff --git a/DESCRIPTION b/DESCRIPTION index b98df4a..72ab2f6 100755 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -13,7 +13,7 @@ Depends: R (>= 3.5.0) Imports: lmomco, lmom, TLMoments, reshape, ggplot2, checkmate, zoo, lubridate License: GPL-2 URL: http://spei.csic.es -LazyLoad: yes +LazyLoad: true Encoding: UTF-8 Suggests: covr, testthat RoxygenNote: 7.2.0 diff --git a/NAMESPACE b/NAMESPACE index 4c9865e..2c99f8a 100755 --- a/NAMESPACE +++ b/NAMESPACE @@ -38,12 +38,19 @@ importFrom(lmomco,pwm2lmom) importFrom(lubridate,days_in_month) importFrom(lubridate,yday) importFrom(reshape,melt) +importFrom(stats,aggregate) importFrom(stats,cycle) importFrom(stats,end) importFrom(stats,frequency) +importFrom(stats,is.ts) importFrom(stats,optim) +importFrom(stats,pnorm) +importFrom(stats,qnorm) +importFrom(stats,sd) importFrom(stats,start) +importFrom(stats,time) importFrom(stats,ts) +importFrom(stats,window) importFrom(zoo,as.Date.yearmon) importFrom(zoo,as.yearmon) importFrom(zoo,na.trim) diff --git a/R/SPEI-package.r b/R/SPEI-package.r index e0aab84..ac6aed7 100755 --- a/R/SPEI-package.r +++ b/R/SPEI-package.r @@ -43,6 +43,10 @@ #' #' @importFrom checkmate makeAssertCollection #' @importFrom stats cycle end frequency start ts optim -#' @importFrom zoo as.yearmon as.Date.yearmon rollapply +#' @importFrom zoo as.yearmon as.Date.yearmon rollapply na.trim #' @importFrom stats aggregate is.ts pnorm qnorm sd time window +#' @importFrom TLMoments PWM +#' @importFrom lmomco are.lmom.valid are.parglo.valid cdfgam cdfpe3 cdfgam pargam parglo parpe3 pwm.pp pwm2lmom +#' @importFrom lmom pelgam pelglo pelpe3 cdfglo + NULL diff --git a/R/data.R b/R/data.R index 77dc5af..c3089f3 100755 --- a/R/data.R +++ b/R/data.R @@ -1,6 +1,7 @@ #' @name Datasets -#' @aliases balance cabinda cruts4 +#' @aliases wichita balance cabinda cruts4 #' @title Data sets for illustrating the functions in the SPEI package. +#' @keywords datasets #' @description #' Data used in the examples of the SPEI package: #' \code{wichita} dataset: monthly climate in Wichita (Kansas, lat=37.6475, @@ -13,10 +14,6 @@ #' \code{cruts4}: 120 years of monthly climatic water balance (precipitation #' minus reference evapotranspiration) data at six grid points from CRU TS 4.05. #' @details See description. -#' @usage -#' data(wichita) -#' data(balance) -#' data(cabinda) #' @format #' \code{wichita} dataset: a data frame with: #' \describe{ @@ -85,29 +82,19 @@ #' summary(wichita) #' data(balance) #' summary(balance) +#' data(cruts4) +#' summary(cruts4) #' -"wichita" +NULL +#' @rdname wichita +"wichita" -#' -#' @title cabinda -#' @rdname Datasets -#' @description See wichita -#' @details See wichita -#' +#' @rdname cabinda "cabinda" - -#' -#' @title balance -#' @rdname Datasets -#' @details See wichita -#' +#' @rdname balance "balance" -#' -#' @title cruts4 -#' @rdname Datasets -#' @description See wichita -#' @details See wichita +#' @rdname cruts4 "cruts4" \ No newline at end of file diff --git a/R/hargreaves.R b/R/hargreaves.R index 327c0f1..c6f4a46 100755 --- a/R/hargreaves.R +++ b/R/hargreaves.R @@ -4,12 +4,12 @@ #' @usage #' thornthwaite(Tave, lat, na.rm = FALSE, verbose=TRUE) #' -#' hargreaves(Tmin, Tmax, Ra = NA, lat = NA, Pre = NA, na.rm = FALSE, verbose=TRUE) +#' hargreaves(Tmin, Tmax, Ra = NULL, lat = NULL, Pre = NULL, na.rm = FALSE, verbose=TRUE) #' -#' penman(Tmin, Tmax, U2, Ra = NA, lat = NA, Rs = NA, tsun = NA, -#' CC = NA, ed = NA, Tdew = NA, RH = NA, P = NA, P0 = NA, -#' z = NA, crop='short', na.rm = FALSE, method='ICID', -#' verbose=TRUE) +#' penman(Tmin, Tmax, U2, Ra = NULL, lat = NULL, Rs = NULL, tsun = NULL, +#' CC = NULL, ed = NULL, Tdew = NULL, RH = NULL, P = NULL, P0 = NULL, +#' CO2 = NULL, z = NULL, crop='short', na.rm = FALSE, method='ICID', +#' verbose=TRUE) #' #' #' @description diff --git a/R/spei.R b/R/spei.R index 2ed826e..f1627e2 100644 --- a/R/spei.R +++ b/R/spei.R @@ -1,20 +1,41 @@ spei <- function(x, y,...) UseMethod('spei') - #' @name Drought-indices #' @title Calculation of the Standardized Precipitation-Evapotranspiration #' Index (SPEI) and the Standardized Precipitation Index (SPI). -#' @aliases spi +#' @aliases spei, spi #' @description #' Given a time series of the climatic water balance (precipitation minus #' potential evapotranspiration), gives a time series of the Standardized #' Precipitation-Evapotranspiration Index (SPEI). -#' @usage -#' spei(data, scale, kernel = list(type = 'rectangular', shift = 0), -#' distribution = 'log-Logistic', fit = 'ub-pwm', na.rm = FALSE, -#' ref.start=NULL, ref.end=NULL, keep.x=FALSE, params=NULL, -#' verbose=TRUE, ...) -#' +#' @usage +#' spei( +#' data, +#' scale, +#' kernel = list(type = 'rectangular', shift = 0), +#' distribution = 'log-Logistic', +#' fit = 'ub-pwm', +#' na.rm = FALSE, +#' ref.start=NULL, +#' ref.end=NULL, +#' keep.x=FALSE, +#' params=NULL, +#' verbose=TRUE, +#' ...) +#' +#' spi( +#' data, +#' scale, +#' kernel = list(type = 'rectangular', shift = 0), +#' distribution = 'Gamma', +#' fit = 'ub-pwm', +#' na.rm = FALSE, +#' ref.start=NULL, +#' ref.end=NULL, +#' keep.x=FALSE, +#' params=NULL, +#' verbose=TRUE, +#' ...) #' @param data a vector, matrix or data frame with time ordered values #' of precipitation (for the SPI) or of the climatic balance #' precipitation minus potential evapotranspiration (for the SPEI). @@ -273,6 +294,7 @@ spei <- function(x, y,...) UseMethod('spei') #' # Modding the plot #' # Since plot.spei() returns a ggplot object, it is possible to add or tweak #' # parts of the plot. +#' require(ggplot2) #' plot(spei(wichita[,'BAL'], 12)) + #' ggtitle('SPEI1 at Wichita') + #' scale_fill_manual(values=c('blue','red')) + # classic SPEI look @@ -280,11 +302,6 @@ spei <- function(x, y,...) UseMethod('spei') #' theme_classic() + #' theme(legend.position='bottom') #' -#' @importFrom zoo rollapply -#' @importFrom TLMoments PWM -#' @importFrom lmomco are.lmom.valid are.parglo.valid cdfgam cdfpe3 cdfgam pargam parglo parpe3 pwm.pp pwm2lmom -#' @importFrom lmom pelgam pelglo pelpe3 cdfglo -#' #' @export #' spei <- function(data, scale, kernel=list(type='rectangular', shift=0), @@ -672,7 +689,7 @@ spei <- function(data, scale, kernel=list(type='rectangular', shift=0), #' #' @title Generic methods for \code{spei} objects. #' -#' @aliases print.spi plot.spei plot.spi summary.spei summary.spi +#' @aliases plot.spei summary.spei #' #' @description #' Generic methods for extracting information and plotting \code{spei} objects. @@ -680,11 +697,10 @@ spei <- function(data, scale, kernel=list(type='rectangular', shift=0), #' @usage #' \method{print}{spei}(x, ...) #' \method{summary}{spei}(object, ...) -#' \method{plot}{spei}(x, ttext, ...) +#' \method{plot}{spei}(x, ...) #' #' @param x an object of class \code{spei}. #' @param object an object of class \code{spei}. -#' @param ttext text to use as part of the plot title #' @param ... additional parameters, not used at present. #' #' @@ -705,7 +721,7 @@ spei <- function(data, scale, kernel=list(type='rectangular', shift=0), #' @author Santiago Beguería #' #' @examples -#' See examples of use in the help page of the \code{spei()} function. +#' # See examples of use in the help page of the spei() function. #' #' @export #' @@ -759,6 +775,9 @@ plot.spei <- function (x, ...) { ### Make the plot - - - - - - - - - - - - - - - - - - - - - - - - - - - + # A workaround to avoid R CMD check warning about no visible binding for global variables + #utils::globalVariables(na, value) + # Label if (grepl('spei', x$call[1])) { label <- 'SPEI (z-values)' @@ -861,7 +880,7 @@ plot.spei <- function (x, ...) { # kk$cat[w] <- '(-0.5,0]' # Plot it - g <- ggplot(kk, aes(time, value, fill=cat, color=cat)) + g <- ggplot(kk, aes_string('time', 'value', fill='cat', color='cat')) # reference period (if different than whole series) if (!is.null(x$ref.period)) { g <- g + @@ -877,7 +896,7 @@ plot.spei <- function (x, ...) { scale_color_manual(values=c('cyan3','tomato')) # new look # add NAs g <- g + - geom_point(aes(time, na), shape=21, fill='white', color='black') + geom_point(aes_string('time', 'na'), shape=21, fill='white', color='black') # add other parts and options g <- g + geom_hline(yintercept=0, color='grey') + diff --git a/R/spi.R b/R/spi.R index 6037e45..78e102b 100755 --- a/R/spi.R +++ b/R/spi.R @@ -7,12 +7,12 @@ spi <- function(x, y,...) UseMethod('spi') #' spi <- function(data, scale, kernel=list(type='rectangular',shift=0), distribution='Gamma', fit='ub-pwm', na.rm=FALSE, - ref.start=NULL, ref.end=NULL, x=FALSE, params=NULL, verbose=TRUE, ...){ + ref.start=NULL, ref.end=NULL, keep.x=FALSE, params=NULL, verbose=TRUE, ...){ # input checks sol <- spei(data, scale, kernel, distribution, fit, na.rm, - ref.start, ref.end, x, params, verbose) + ref.start, ref.end, keep.x, params, verbose) sol$call <- match.call(expand.dots=FALSE) return(sol) diff --git a/R/thornthwaite.R b/R/thornthwaite.R index 5d17770..73dd458 100755 --- a/R/thornthwaite.R +++ b/R/thornthwaite.R @@ -168,7 +168,7 @@ thornthwaite <- function(Tave, lat, na.rm=FALSE, verbose=TRUE) { if (out_type=='tsmatrix') { PET <- matrix(PET, nrow=n_times) PET <- ts(PET, frequency=ts_freq, start=ts_start) - colnames(PET) <- rep('PET_tho', ncol(ET0)) + colnames(PET) <- rep('PET_tho', ncol(PET)) } else if (out_type=='tsvector') { PET <- as.vector(PET) PET <- ts(PET, frequency=ts_freq, start=ts_start) diff --git a/man/Datasets.Rd b/man/Datasets.Rd index 96407be..47225fa 100644 --- a/man/Datasets.Rd +++ b/man/Datasets.Rd @@ -1,6 +1,5 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/data.R -\docType{data} \name{Datasets} \alias{Datasets} \alias{wichita} @@ -46,12 +45,6 @@ points from CRU TS 4.05 data set. The array has dimensions [time=1440, longitude=2, latitude=3], with time starting in January 1900. Longitudes are (0.25, 0.75), and latitudes (42.25, 42.75, 43.25), corresponding to the Central Pyrenees between Spain and France. - -An object of class \code{data.frame} with 12 rows and 8 columns. - -An object of class \code{data.frame} with 1296 rows and 11 columns. - -An object of class \code{array} of dimension 1440 x 2 x 3. } \source{ The \code{wichita} data were obtained from the Global Historical Climatology Network @@ -61,17 +54,6 @@ Data for the \code{balance} dataset were taken from Allen et al. (1998), page 69 The \code{cruts4} data were obtained from the CRU (Climatic Research Unit, University of East Anglia \url{https://crudata.uea.ac.uk/cru/data/hrg/cru_ts_4.05/}) TS V4.05 data set. } -\usage{ -data(wichita) -data(balance) -data(cabinda) - -cabinda - -balance - -cruts4 -} \description{ Data used in the examples of the SPEI package: \code{wichita} dataset: monthly climate in Wichita (Kansas, lat=37.6475, @@ -83,19 +65,9 @@ since January 1900; Allen et al. (1998); \code{cruts4}: 120 years of monthly climatic water balance (precipitation minus reference evapotranspiration) data at six grid points from CRU TS 4.05. - -See wichita - -See wichita } \details{ See description. - -See wichita - -See wichita - -See wichita } \examples{ data(wichita) @@ -103,6 +75,8 @@ names(wichita) summary(wichita) data(balance) summary(balance) +data(cruts4) +summary(cruts4) } \references{ diff --git a/man/Drought-indices.Rd b/man/Drought-indices.Rd index 1106be1..4b58e27 100755 --- a/man/Drought-indices.Rd +++ b/man/Drought-indices.Rd @@ -3,23 +3,38 @@ \name{Drought-indices} \alias{Drought-indices} \alias{spei} +\alias{spei,} \alias{spi} \title{Calculation of the Standardized Precipitation-Evapotranspiration Index (SPEI) and the Standardized Precipitation Index (SPI).} \usage{ spei( - data, - scale, - kernel = list(type = 'rectangular', shift = 0), - distribution = 'log-Logistic', - fit = 'ub-pwm', - na.rm = FALSE, - ref.start=NULL, - ref.end=NULL, - keep.x=FALSE, - params=NULL, - verbose=TRUE, - ...) + data, + scale, + kernel = list(type = 'rectangular', shift = 0), + distribution = 'log-Logistic', + fit = 'ub-pwm', + na.rm = FALSE, + ref.start=NULL, + ref.end=NULL, + keep.x=FALSE, + params=NULL, + verbose=TRUE, + ...) + +spi( + data, + scale, + kernel = list(type = 'rectangular', shift = 0), + distribution = 'Gamma', + fit = 'ub-pwm', + na.rm = FALSE, + ref.start=NULL, + ref.end=NULL, + keep.x=FALSE, + params=NULL, + verbose=TRUE, + ...) spi( data, @@ -30,7 +45,7 @@ spi( na.rm = FALSE, ref.start = NULL, ref.end = NULL, - x = FALSE, + keep.x = FALSE, params = NULL, verbose = TRUE, ... @@ -292,6 +307,7 @@ dim(spei_12$fitted) # Modding the plot # Since plot.spei() returns a ggplot object, it is possible to add or tweak # parts of the plot. +require(ggplot2) plot(spei(wichita[,'BAL'], 12)) + ggtitle('SPEI1 at Wichita') + scale_fill_manual(values=c('blue','red')) + # classic SPEI look diff --git a/man/Generic-methods-for-spei-objects.Rd b/man/Generic-methods-for-spei-objects.Rd index ceb1b33..e372d71 100755 --- a/man/Generic-methods-for-spei-objects.Rd +++ b/man/Generic-methods-for-spei-objects.Rd @@ -3,20 +3,17 @@ \name{Generic-methods-for-spei-objects} \alias{Generic-methods-for-spei-objects} \alias{print.spei} -\alias{print.spi} \alias{plot.spei} -\alias{plot.spi} \alias{summary.spei} -\alias{summary.spi} \title{Generic methods for \code{spei} objects.} \usage{ \method{print}{spei}(x, ...) \method{summary}{spei}(object, ...) -\method{plot}{spei}(x, ttext, ...) +\method{plot}{spei}(x, ...) \method{summary}{spei}(object, ...) -\method{plot}{spei}(x) +\method{plot}{spei}(x, ...) } \arguments{ \item{x}{an object of class \code{spei}.} @@ -24,8 +21,6 @@ \item{...}{additional parameters, not used at present.} \item{object}{an object of class \code{spei}.} - -\item{ttext}{text to use as part of the plot title} } \description{ Generic methods for extracting information and plotting \code{spei} objects. @@ -48,7 +43,7 @@ See print.spei See print.spei } \examples{ -See examples of use in the help page of the \code{spei()} function. +# See examples of use in the help page of the spei() function. } \references{ diff --git a/man/Potential-evapotranspiration.Rd b/man/Potential-evapotranspiration.Rd index bd95887..1b5125c 100755 --- a/man/Potential-evapotranspiration.Rd +++ b/man/Potential-evapotranspiration.Rd @@ -9,12 +9,12 @@ \usage{ thornthwaite(Tave, lat, na.rm = FALSE, verbose=TRUE) -hargreaves(Tmin, Tmax, Ra = NA, lat = NA, Pre = NA, na.rm = FALSE, verbose=TRUE) +hargreaves(Tmin, Tmax, Ra = NULL, lat = NULL, Pre = NULL, na.rm = FALSE, verbose=TRUE) -penman(Tmin, Tmax, U2, Ra = NA, lat = NA, Rs = NA, tsun = NA, - CC = NA, ed = NA, Tdew = NA, RH = NA, P = NA, P0 = NA, - z = NA, crop='short', na.rm = FALSE, method='ICID', - verbose=TRUE) +penman(Tmin, Tmax, U2, Ra = NULL, lat = NULL, Rs = NULL, tsun = NULL, + CC = NULL, ed = NULL, Tdew = NULL, RH = NULL, P = NULL, P0 = NULL, + CO2 = NULL, z = NULL, crop='short', na.rm = FALSE, method='ICID', + verbose=TRUE) penman( Tmin, From 4aaf61a9cb8bd17a7ee00e224833d6ee93f2a8a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Santiago=20Beguer=C3=ADa?= Date: Wed, 23 Nov 2022 17:15:01 +0100 Subject: [PATCH 07/14] Assignment R style Replacing '=' by '<-' in a few lines to conform with normal R style. Also, adding cran-comments.md. --- .Rbuildignore | 1 + R/kern.R | 2 +- R/spei.R | 18 +++++++++--------- cran-comments.md | 5 +++++ tests/testthat/test_hargreaves.R | 4 ++-- tests/testthat/test_kern.R | 4 ++-- tests/testthat/test_thornthwaite.R | 4 ++-- 7 files changed, 22 insertions(+), 16 deletions(-) create mode 100644 cran-comments.md diff --git a/.Rbuildignore b/.Rbuildignore index fa76b93..dc93b90 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -2,3 +2,4 @@ ^\.Rproj\.user$ ^data-raw$ ^_config\.yml$ +^cran-comments\.md$ diff --git a/R/kern.R b/R/kern.R index d87af21..1037671 100755 --- a/R/kern.R +++ b/R/kern.R @@ -86,7 +86,7 @@ kern <- function(scale, type='rectangular', shift=0) { if(s == 1) type == "rectangular" - k = switch(type, + k <- switch(type, rectangular = rep(1,s), triangular = s:1, circular = (s^2+(1-(1:s)^2)), diff --git a/R/spei.R b/R/spei.R index f1627e2..4bc56f3 100644 --- a/R/spei.R +++ b/R/spei.R @@ -502,7 +502,7 @@ spei <- function(data, scale, kernel=list(type='rectangular', shift=0), # Instantiate an object to store the distribution coefficients # ADD PZE TO GAMMA AND PEARSONIII - coef = switch(distribution, + coef <- switch(distribution, "Gamma" = array(NA, c(2, n_sites, ts_freq), list(par=c('alpha','beta'), colnames(data), NULL)), "PearsonIII" = coef <- array(NA, c(3, n_sites, ts_freq), @@ -571,7 +571,7 @@ spei <- function(data, scale, kernel=list(type='rectangular', shift=0), # Probability of zero (pze) if(distribution != 'log-Logistic'){ pze <- sum(x.mon==0) / length(x.mon) - x.mon = x.mon[x.mon > 0] + x.mon <- x.mon[x.mon > 0] } ## Compute coefficients - - - - - - - - - - - - - - @@ -579,7 +579,7 @@ spei <- function(data, scale, kernel=list(type='rectangular', shift=0), # Distribution parameters (f_params) if (!using$params) { # Fit distribution parameters - x.mon_sd = sd(x.mon, na.rm=TRUE) + x.mon_sd <- sd(x.mon, na.rm=TRUE) # Early stopping if (is.na(x.mon_sd) || (x.mon_sd == 0)) { @@ -587,13 +587,13 @@ spei <- function(data, scale, kernel=list(type='rectangular', shift=0), next() } if(length(x.mon) < 4){ - spei[ff,s] = NA + spei[ff,s] <- NA coef[,s,c] <- NA next() } # Calculate probability weighted moments based on `lmomco` or `TLMoments` - pwm = switch(fit, + pwm <- switch(fit, 'pp-pwm' = pwm.pp(x.mon, -0.35, 0, nmom=3, sort=TRUE), 'ub-pwm' = PWM(x.mon, order=0:2) ) @@ -607,10 +607,10 @@ spei <- function(data, scale, kernel=list(type='rectangular', shift=0), # `lmom` fortran functions need specific inputs L1, L2, T3 # This is handled internally by `lmomco` with `lmorph` - fortran_vec = c(lmom$lambdas[1:2], lmom$ratios[3]) + fortran_vec <- c(lmom$lambdas[1:2], lmom$ratios[3]) # Calculate parameters based on distribution with `lmom`, then `lmomco` - f_params = switch(distribution, + f_params <- switch(distribution, 'log-Logistic' = tryCatch(pelglo(fortran_vec), error = function(e){ parglo(lmom)$para }), 'Gamma' = tryCatch(pelgam(fortran_vec), @@ -621,12 +621,12 @@ spei <- function(data, scale, kernel=list(type='rectangular', shift=0), # Adjust if user chose `log-Logistic` and `max-lik` if(distribution == 'log-Logistic' && fit=='max-lik'){ - f_params = parglo.maxlik(x.mon, f_params)$para + f_params <- parglo.maxlik(x.mon, f_params)$para } } else { # User-provided distribution parameters - f_params = as.vector(params[,s,c]) + f_params <- as.vector(params[,s,c]) } diff --git a/cran-comments.md b/cran-comments.md new file mode 100644 index 0000000..858617d --- /dev/null +++ b/cran-comments.md @@ -0,0 +1,5 @@ +## R CMD check results + +0 errors | 0 warnings | 1 note + +* This is a new release. diff --git a/tests/testthat/test_hargreaves.R b/tests/testthat/test_hargreaves.R index f0d50d7..ff3a25e 100755 --- a/tests/testthat/test_hargreaves.R +++ b/tests/testthat/test_hargreaves.R @@ -107,7 +107,7 @@ test_that('example with lat', { #out <- hargreaves(TMIN, TMAX, Ra=TMAX) #saveRDS(out, file='./tests/testthat/data/hargreaves_out_ra.rds') test_that('example with Ra', { - harModOut = readRDS('data/hargreaves_out_ra.rds') + harModOut <- readRDS('data/hargreaves_out_ra.rds') expect_equal(harModOut, hargreaves(TMIN, TMAX, Ra=TMAX) ) }) @@ -115,7 +115,7 @@ test_that('example with Ra', { #out <- hargreaves(TMIN, TMAX, lat=37.6475, Pre=TMAX) #saveRDS(out, file='./tests/testthat/data/hargreaves_out_pre.rds') test_that('example with Pre', { - harModOut = readRDS('data/hargreaves_out_pre.rds') + harModOut <- readRDS('data/hargreaves_out_pre.rds') expect_equal(harModOut, hargreaves(TMIN, TMAX, lat=37.6475, Pre=TMAX) ) }) diff --git a/tests/testthat/test_kern.R b/tests/testthat/test_kern.R index c57d0e9..e7a23b0 100755 --- a/tests/testthat/test_kern.R +++ b/tests/testthat/test_kern.R @@ -2,13 +2,13 @@ context("kern") test_that("example w/ defaults", { - k12Out = readRDS("data/k12_Out.rds") + k12Out <- readRDS("data/k12_Out.rds") expect_equal(k12Out, kern(12)) }) test_that("example w/ defaults", { - k12GaussOut = readRDS("data/k12_gauss_Out.rds") + k12GaussOut <- readRDS("data/k12_gauss_Out.rds") expect_equal(k12GaussOut, kern(12, 'gaussian')) }) diff --git a/tests/testthat/test_thornthwaite.R b/tests/testthat/test_thornthwaite.R index a8cfd4c..1523479 100755 --- a/tests/testthat/test_thornthwaite.R +++ b/tests/testthat/test_thornthwaite.R @@ -37,13 +37,13 @@ test_that('lat has incorrect length', { #out <- thornthwaite(TMED, 37.6475) #saveRDS(out, file='./tests/testthat/data/thornthwaite_out.rds') test_that('example', { - thoOut = readRDS('data/thornthwaite_out.rds') #./tests/testthat/ + thoOut <- readRDS('data/thornthwaite_out.rds') #./tests/testthat/ expect_equal(thoOut, thornthwaite(TMED, 37.6475)) }) #out <- thornthwaite(ts(TMED, c(1980,1), fr=12), 37.6475) #saveRDS(out, file='./tests/testthat/data/thornthwaite_out_ts.rds') test_that('example', { - thoOut = readRDS('data/thornthwaite_out_ts.rds') #./tests/testthat/ + thoOut <- readRDS('data/thornthwaite_out_ts.rds') #./tests/testthat/ expect_equal(thoOut, thornthwaite(ts(TMED, c(1980,1), fr=12), 37.6475)) }) From 59b34c9ee8a58d8da754db2c2b1601a4ee60696d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Santiago=20Beguer=C3=ADa?= Date: Wed, 23 Nov 2022 17:18:47 +0100 Subject: [PATCH 08/14] Removing Date Omiting Date in DESCRIPTION as it not required and a date is automatically added when R CMD build is performed. --- DESCRIPTION | 1 - 1 file changed, 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 72ab2f6..d150b94 100755 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,6 @@ Package: SPEI Type: Package Version: 1.8 -Date: 2022-05-05 Title: Calculation of the Standardised Precipitation-Evapotranspiration Index Authors@R: c( person('Santiago', 'Beguería', role=c('aut','cre'), From 327cdc462422354875bba23b0c8e07391d343a66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Santiago=20Beguer=C3=ADa?= Date: Wed, 23 Nov 2022 17:22:11 +0100 Subject: [PATCH 09/14] Update DESCRIPTION Adding URL and BugReporst, pointing to the GitHub SPEI page. --- DESCRIPTION | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index d150b94..6417e8c 100755 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -11,7 +11,8 @@ Description: A set of functions for computing potential evapotranspiration and s Depends: R (>= 3.5.0) Imports: lmomco, lmom, TLMoments, reshape, ggplot2, checkmate, zoo, lubridate License: GPL-2 -URL: http://spei.csic.es +URL: http://spei.csic.es, https://github.com/sbegueria/SPEI +BugReports: https://github.com/sbegueria/SPEI/issues LazyLoad: true Encoding: UTF-8 Suggests: covr, testthat From add122389dfe9d296efc3b5a802641b97b706bdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Santiago=20Beguer=C3=ADa?= Date: Wed, 23 Nov 2022 17:36:16 +0100 Subject: [PATCH 10/14] Avoid use of aes_string(), and remove global imports. Avoid use of aes_string() in ggplot2 to define aesthetics programatically (this is a requirement to pass R CMD test), and use non-standard evaluation now available in ggplot2 v. 3. Also, avoid importing import packages as a whole as we now import specific functions. --- DESCRIPTION | 1 - R/spei.R | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 6417e8c..9dd5683 100755 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -9,7 +9,6 @@ Authors@R: c( email='svicen@ipe.csic.es')) Description: A set of functions for computing potential evapotranspiration and several widely used drought indices including the Standardized Precipitation-Evapotranspiration Index (SPEI). Depends: R (>= 3.5.0) -Imports: lmomco, lmom, TLMoments, reshape, ggplot2, checkmate, zoo, lubridate License: GPL-2 URL: http://spei.csic.es, https://github.com/sbegueria/SPEI BugReports: https://github.com/sbegueria/SPEI/issues diff --git a/R/spei.R b/R/spei.R index 4bc56f3..02f6b9b 100644 --- a/R/spei.R +++ b/R/spei.R @@ -880,7 +880,7 @@ plot.spei <- function (x, ...) { # kk$cat[w] <- '(-0.5,0]' # Plot it - g <- ggplot(kk, aes_string('time', 'value', fill='cat', color='cat')) + g <- ggplot(kk, aes(.data[['time']], .data[['value']], fill='cat', color='cat')) # reference period (if different than whole series) if (!is.null(x$ref.period)) { g <- g + @@ -896,7 +896,7 @@ plot.spei <- function (x, ...) { scale_color_manual(values=c('cyan3','tomato')) # new look # add NAs g <- g + - geom_point(aes_string('time', 'na'), shape=21, fill='white', color='black') + geom_point(aes(.data[['time']], .data[['na']]), shape=21, fill='white', color='black') # add other parts and options g <- g + geom_hline(yintercept=0, color='grey') + From d3161038b9a5cefffd8401633fccb3356b59a251 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Santiago=20Beguer=C3=ADa?= Date: Wed, 23 Nov 2022 17:38:00 +0100 Subject: [PATCH 11/14] Add imports back Add back Imports, as removing it was a mistake. --- DESCRIPTION | 1 + 1 file changed, 1 insertion(+) diff --git a/DESCRIPTION b/DESCRIPTION index 9dd5683..6417e8c 100755 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -9,6 +9,7 @@ Authors@R: c( email='svicen@ipe.csic.es')) Description: A set of functions for computing potential evapotranspiration and several widely used drought indices including the Standardized Precipitation-Evapotranspiration Index (SPEI). Depends: R (>= 3.5.0) +Imports: lmomco, lmom, TLMoments, reshape, ggplot2, checkmate, zoo, lubridate License: GPL-2 URL: http://spei.csic.es, https://github.com/sbegueria/SPEI BugReports: https://github.com/sbegueria/SPEI/issues From 23c256e4497370f30f7b71628323dacc970796e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Santiago=20Beguer=C3=ADa?= Date: Wed, 23 Nov 2022 18:04:08 +0100 Subject: [PATCH 12/14] Spell check Correcting typos after devtools::spell_check(). --- NEWS.md | 16 ++++++++-------- R/data.R | 4 ++-- R/hargreaves.R | 8 ++++---- R/kern.R | 4 ++-- R/spei.R | 4 ++-- README.md | 12 ++++++------ man/Datasets.Rd | 4 ++-- man/Drought-indices.Rd | 4 ++-- man/Kernel-functions.Rd | 4 ++-- man/Potential-evapotranspiration.Rd | 8 ++++---- 10 files changed, 34 insertions(+), 34 deletions(-) diff --git a/NEWS.md b/NEWS.md index 9066e98..5a5699a 100644 --- a/NEWS.md +++ b/NEWS.md @@ -6,7 +6,7 @@ __Version history: -_Version 1.8, May 2022 (current development version on github). +_Version 1.8, May 2022 (current development version on GitHub). 1. Solving several minor bugs in ``, ``, and `` functions (output difference less than 0.1%). 2. Solving a bug in `` that resulted in bad cumulative data when using a non-rectangular kernel, resulting in incorrect SPEI values. @@ -16,16 +16,16 @@ _Version 1.8, May 2022 (current development version on github). 6. Implementation of different versions of the Penman-Monteith ETo calculation in function ``. 7. Implementation of an option to include CO2 concentration data in function ``. 8. Implementation of a new option for when no wind data are available in function ``. -9. Funtion `` completely rewritten based on `ggplot2`, solving some bugs and enabling more flexibility. +9. Function `` completely rewritten based on `ggplot2`, solving some bugs and enabling more flexibility. -_Version 1.7.2, June 2019 (current stable version on github). +_Version 1.7.2, June 2019 (current stable version on GitHub). 1. Allowing for data with frequency other than 12 in `` function. _Version 1.7.1, June 2017. -1. Corrected an error in `` function, which was not working when distribution was Gamma or PeasonIII and using user provided parameters. (Fixed by Emanuele Cordano, emanuele.cordano@gmail.com -- ecor) -2. Added probability of monthly precipitation = 0 (pze) when using user provided parameters. (Fixed by Emanuele Cordano, emanuele.cordano@gmail.com -- ecor) +1. Corrected an error in `` function, which was not working when distribution was Gamma or PeasonIII and using user provided parameters. (Fixed by Emanuele Cordano, emanuele.cordano@gmail.com -- 'ecor') +2. Added probability of monthly precipitation = 0 (pze) when using user provided parameters. (Fixed by Emanuele Cordano, emanuele.cordano@gmail.com -- 'ecor') _Version 1.7, June 2017 (current on CRAN). @@ -45,7 +45,7 @@ _Version 1.5, May 2013. _Version 1.4, May 2013. 1. Minor fixes to functions \code{\link{penman}} and \code{\link{pwm}}. -2. Documentation of the penman function defined by mistake ed as the saturation vapour pressure, while it should read 'actual vapour pressure'. +2. Documentation of the penman function defined by mistake ed as the saturation vapor pressure, while it should read 'actual vapor pressure'. 3. Function zzz.R added to display basic information about the SPEI package at startup. 4. Function \code{\link{SPEINews}} added to display the NEWS file. @@ -56,7 +56,7 @@ _Version 1.3, March 2013. _Version 1.2, October 2012. 1. Fixed a bug causing several functions to fail when a time series not belonging to matrix class was provided. -2. Function \code{\link{plot.spei}} now distinguises between calls to spei and spi and labels the axis accordingly. +2. Function \code{\link{plot.spei}} now distinguishes between calls to \code{\link{spei}} and \code{\link{spi}} and labels the axis accordingly. _Version 1.1, March 2012. 1. Functions \code{\link{spei}} and \code{\link{spi}} now yield an object of class "spei". @@ -69,6 +69,6 @@ First release of the SPEI package. __To do (work in progress): 1. Complete documentation for pwmLC.Rd. -2. Review method plot.spei() that produces wrong results in some cases. +2. Review method \code{\link{plot.speispei}} that produces wrong results in some cases. 3. Implement parallel processing. 4. Analysis functions. diff --git a/R/data.R b/R/data.R index c3089f3..e4fc1aa 100755 --- a/R/data.R +++ b/R/data.R @@ -30,7 +30,7 @@ #' \code{balance} dataset: a data frame with monthly climatic water balance #' (precipitation minus potential evapotranspiration) at Indore (India), #' Kimberley (South Africa), Albuquerque (US), Valencia (Spain), Wien (Austria), -#' Abashiri (Japan), Tampa (US), Sao Paulo (Brasil), Lahore (India), Punta +#' Abashiri (Japan), Tampa (US), Sao Paulo (Brazil), Lahore (India), Punta #' Arenas (Chile) and Helsinki (Finland), in mm. #' \code{cabinda} dataset: a data frame with one year of monthly climatic data #' at Cabinda (Angola, -5.33S 12.11E 20 m), with: @@ -42,7 +42,7 @@ #' \item{RH}{ monthly mean relative humidity, in \%.} #' \item{U2}{ monthly mean wind speed, in km h-1} #' \item{tsun}{ monthly mean sunshine hours, in h.} -#' \item{Rs}{ monthly mean dialy incoming solar radiation, MJ m-2 d-1.} +#' \item{Rs}{ monthly mean diaily incoming solar radiation, MJ m-2 d-1.} #' \item{ET0}{ monthly ET0 from the original publication, in mm.} #'} #' diff --git a/R/hargreaves.R b/R/hargreaves.R index c6f4a46..044a78a 100755 --- a/R/hargreaves.R +++ b/R/hargreaves.R @@ -29,10 +29,10 @@ #' @param Ra optional, a numeric vector, tsvector, matrix, tsmatrix, or 3-d array of monthly mean daily external radiation, MJ m-2 d-1. #' @param Pre optional, a numeric vector, tsvector, matrix, tsmatrix, or 3-d array of monthly total precipitation, mm. #' @param U2 a numeric vector, tsvector, matrix, tsmatrix, or 3-d array of monthly mean daily wind speeds at 2 m height, m s-1. -#' @param Rs optional, a numeric vector, tsvector, matrix, tsmatrix, or 3-d array of monthly mean dialy incoming solar radiation, MJ m-2 d-1. +#' @param Rs optional, a numeric vector, tsvector, matrix, tsmatrix, or 3-d array of monthly mean daily incoming solar radiation, MJ m-2 d-1. #' @param tsun optional, a numeric vector, tsvector, matrix, tsmatrix, or 3-d array of monthly mean daily bright sunshine hours, h. #' @param CC optional, numeric a vector, matrix or time series of monthly mean cloud cover, \%. -#' @param ed optional, numeric a vector, matrix or time series of monthly mean actual vapour pressure at 2 m height, kPa. +#' @param ed optional, numeric a vector, matrix or time series of monthly mean actual vapor pressure at 2 m height, kPa. #' @param Tdew optional, a numeric vector, tsvector, matrix, tsmatrix, or 3-d array of monthly mean daily dewpoint temperature (used for estimating ed), ºC. #' @param RH optional, a numeric vector, tsvector, matrix, tsmatrix, or 3-d array of monthly mean relative humidity (used for estimating ed), \%. #' @param P optional, a numeric vector, tsvector, matrix, tsmatrix, or 3-d array of monthly mean atmospheric pressure at surface, kPa. @@ -103,7 +103,7 @@ #' #' @references #' Thornthwaite, C. W., 1948. An approach toward a rational classification of climate. -#' \emph{Geographical Review} \bold{38}: 55–94. doi:10.2307/2107309. +#' \emph{Geographical Review} \bold{38}: 55–94. DOI:10.2307/2107309. #' #' Hargreaves G.H., 1994. Defining and using reference evapotranspiration. #' \emph{Journal of Irrigation and Drainage Engineering} \bold{120}: 1132–1139. @@ -125,7 +125,7 @@ #' Reston, VA, 57 pp. #' #' Yang, Y., Roderick, M.L., Zhang, S. McVicar, T., Donohue, R.J., 2019. Hydrologic implications of vegetation -#' response to elevated CO2 in climate projections. \emph{Nature Clim Change} \bold{9}: 44–48. +#' response to elevated CO2 in climate projections. \emph{Nature Climate Change} \bold{9}: 44–48. #' #' #' @author Santiago Beguería diff --git a/R/kern.R b/R/kern.R index 1037671..d83856b 100755 --- a/R/kern.R +++ b/R/kern.R @@ -9,7 +9,7 @@ #' @details #' Drought indices, such as the SPEI or the SPI, are usually #' computed at different time scales to adapt to the different response -#' times of systems affected by drought. This is acomplished by applying +#' times of systems affected by drought. This is accomplished by applying #' a kernel function to the data prior to computation of the SPEI. #' Application of a kernel has the effect of smoothing the temporal #' variability of the resulting SPEI, allowing for the major patterns @@ -40,7 +40,7 @@ #' time lag for the four different kernel shapes so they can be compared. #' #' -#' @return A vector of lenght equal to \code{scale} with weights used for computing the drought index. +#' @return A vector of length equal to \code{scale} with weights used for computing the drought index. #' #' #' @references diff --git a/R/spei.R b/R/spei.R index 02f6b9b..d89e567 100644 --- a/R/spei.R +++ b/R/spei.R @@ -113,7 +113,7 @@ spei <- function(x, y,...) UseMethod('spei') #' #' @section Probability distributions: #' Following the original definitions \code{spei} uses a log-Logistic distribution -#' by default, and \code{spi} uses a Gamma distribution. This behaviour can be modified, +#' by default, and \code{spi} uses a Gamma distribution. This behavior can be modified, #' however, through parameter \code{distribution}. #' #' @@ -138,7 +138,7 @@ spei <- function(x, y,...) UseMethod('spei') #' #' #' @section Reference period: -#' The default behaviour of the functions is using all the values provided in \code{data} +#' The default behavior of the functions is using all the values provided in \code{data} #' for parameter fitting. However, this can be modified with help of parameters \code{ref.start} #' and \code{ref.end}. These parameters allow defining a subset of values that will be used #' for parameter fitting, i.e. a reference period. The functions, however, will compute the diff --git a/README.md b/README.md index cffa523..453b3ea 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # SPEI -An R package incorporating a set of functions for computing potential or reference evapotranspiration and several widely used drought indices, currently including the **Standardized Precipitation-Evapotranspiration Index (SPEI)** and the **Standardized Precipitation Index (SPE)**. +An R package incorporating a set of functions for computing potential or reference evapotranspiration and several widely used drought indices, currently including the **Standardized Precipitation-Evapotranspiration Index (SPEI)** and the **Standardized Precipitation Index (SPI)**. The package is centered on the SPEI. For more information on this drought index, please visit [spei.csic.es](http://spei.csic.es/). @@ -46,17 +46,17 @@ You can cite this references if you use the SPEI library on your work: Other (possibly useful) references: -* Vicente-Serrano, S.M., Beguería, S., López-Moreno, J.I., Angulo, M., El Kenawy, A. 2010. A new global 0.5° gridded dataset (1901-2006) of a multiscalar drought index: comparison with current drought index datasets based on the Palmer Drought Severity Index. *Journal of Hydrometeorology* **11**: 1033--1043. +* Vicente-Serrano, S.M., Beguería, S., López-Moreno, J.I., Angulo, M., El Kenawy, A. 2010. A new global 0.5° gridded dataset (1901-2006) of a multi-scalar drought index: comparison with current drought index datasets based on the Palmer Drought Severity Index. *Journal of Hydrometeorology* **11**: 1033--1043. * Beguería, S., Vicente-Serrano, S.M. y Angulo, M. 2010. A multi-scalar global drought data set: the SPEIbase: A new gridded product for the analysis of drought variability and impacts. *Bulletin of the American Meteorological Society* **91**: 1351--1354. * Vicente-Serrano, S.M., Beguería, S. and Juan I. López-Moreno. 2011. Comment on “Characteristics and trends in various forms of the Palmer Drought Severity Index (PDSI) during 1900-2008” by A. Dai. *Journal of Geophysical Research-Atmosphere* **116**: D19112, doi:10.1029/2011JD016410. -* Vicente-Serrano, S.M., Santiago Beguería, Jorge Lorenzo-Lacruz, Jesús Julio Camarero, Juan I. López-Moreno, Cesar Azorin-Molina, Jesús Revuelto, Enrique Morán-Tejeda and Arturo Sánchez-Lorenzo. 2012. Performance of drought indices for ecological, agricultural and hydrological applications. *Earth Interactions* **16**: 1--27. +* Vicente-Serrano, S.M., Santiago Beguería, Jorge Lorenzo-Lacruz, Jesús Julio Camarero, Juan I. López-Moreno, Cesar Azorín-Molina, Jesús Revuelto, Enrique Morán-Tejeda and Arturo Sánchez-Lorenzo. 2012. Performance of drought indices for ecological, agricultural and hydrological applications. *Earth Interactions* **16**: 1--27. * Vicente-Serrano, S.M., Célia Gouveia, Jesús Julio Camarero, Santiago Beguería, Ricardo Trigo, Juan I. López-Moreno, César Azorín-Molina, Edmond Pasho, Jorge Lorenzo-Lacruz, Jesús Revuelto, Enrique Morán-Tejeda and Arturo Sanchez-Lorenzo. 2012. The response of vegetation to drought time-scales across global land biomes. *Proceedings of the National Academy of Sciences of the United States of America*, doi: 10.1073/pnas.1207068110. -* Vicente-Serrano, S.M., Gerard Van der Schrier, Santiago Beguería, Cesar Azorin-Molina, Juan-I. Lopez-Moreno. 2015. Contribution of precipitation and reference evapotranspiration to drought indices under different climates. Journal of Hydrology 426: 42--54. +* Vicente-Serrano, S.M., Gerard Van der Schrier, Santiago Beguería, Cesar Azorín-Molina, Juan-I. Lopez-Moreno. 2015. Contribution of precipitation and reference evapotranspiration to drought indices under different climates. Journal of Hydrology 426: 42--54. * Vicente-Serrano, S.M., Beguería, S. 2016. Comment on "Candidate Distributions for Climatological Drought Indices (SPI and SPEI)" by James H. Stagge et al. *International Journal of Climatology* **36**: 2120--213. @@ -75,7 +75,7 @@ Other (possibly useful) references: 7. Implementation of an option to include CO2 concentration data in function ``. 8. Implementation of a new option for when no wind data are available in function ``. 9. Functions `` and `` now admit time series of any frequency, and not only monthly (frequency 12) data. -10. Fucntion `` completely rewritten based on `ggplot2`, solving some bugs and enabling more flexibility. +10. Function `` completely rewritten based on `ggplot2`, solving some bugs and enabling more flexibility. ### Version 1.7.2, January 2018 (latest stable version on github). @@ -110,7 +110,7 @@ Other (possibly useful) references: ### Version 1.4, May 2013. 1. Minor fixes to functions `` and ``. -2. Documentation of the penman function defined by mistake ed as the saturation vapour pressure, while it should read 'actual vapour pressure'. +2. Documentation of the penman function defined by mistake ed as the saturation vapor pressure, while it should read 'actual vapor pressure'. 3. Function zzz.R added to display basic information about the SPEI package at startup. 4. Function `` added to display the NEWS file. diff --git a/man/Datasets.Rd b/man/Datasets.Rd index 47225fa..6fe5eda 100644 --- a/man/Datasets.Rd +++ b/man/Datasets.Rd @@ -23,7 +23,7 @@ \code{balance} dataset: a data frame with monthly climatic water balance (precipitation minus potential evapotranspiration) at Indore (India), Kimberley (South Africa), Albuquerque (US), Valencia (Spain), Wien (Austria), - Abashiri (Japan), Tampa (US), Sao Paulo (Brasil), Lahore (India), Punta + Abashiri (Japan), Tampa (US), Sao Paulo (Brazil), Lahore (India), Punta Arenas (Chile) and Helsinki (Finland), in mm. \code{cabinda} dataset: a data frame with one year of monthly climatic data at Cabinda (Angola, -5.33S 12.11E 20 m), with: @@ -35,7 +35,7 @@ at Cabinda (Angola, -5.33S 12.11E 20 m), with: \item{RH}{ monthly mean relative humidity, in \%.} \item{U2}{ monthly mean wind speed, in km h-1} \item{tsun}{ monthly mean sunshine hours, in h.} - \item{Rs}{ monthly mean dialy incoming solar radiation, MJ m-2 d-1.} + \item{Rs}{ monthly mean diaily incoming solar radiation, MJ m-2 d-1.} \item{ET0}{ monthly ET0 from the original publication, in mm.} } diff --git a/man/Drought-indices.Rd b/man/Drought-indices.Rd index 4b58e27..85a5a88 100755 --- a/man/Drought-indices.Rd +++ b/man/Drought-indices.Rd @@ -175,7 +175,7 @@ These parameters are then passed to the function \code{\link{kern}}. \section{Probability distributions}{ Following the original definitions \code{spei} uses a log-Logistic distribution -by default, and \code{spi} uses a Gamma distribution. This behaviour can be modified, +by default, and \code{spi} uses a Gamma distribution. This behavior can be modified, however, through parameter \code{distribution}. } @@ -203,7 +203,7 @@ this option in order to know what distribution function should be used. \section{Reference period}{ -The default behaviour of the functions is using all the values provided in \code{data} +The default behavior of the functions is using all the values provided in \code{data} for parameter fitting. However, this can be modified with help of parameters \code{ref.start} and \code{ref.end}. These parameters allow defining a subset of values that will be used for parameter fitting, i.e. a reference period. The functions, however, will compute the diff --git a/man/Kernel-functions.Rd b/man/Kernel-functions.Rd index 37eba4a..de76b0d 100755 --- a/man/Kernel-functions.Rd +++ b/man/Kernel-functions.Rd @@ -18,7 +18,7 @@ kern.plot(scale = 12, shift = 0) \item{shift}{numeric, shifting of the kernel peak.} } \value{ -A vector of lenght equal to \code{scale} with weights used for computing the drought index. +A vector of length equal to \code{scale} with weights used for computing the drought index. } \description{ Function \code{kern} is used internally by \code{\link{spei}} and @@ -29,7 +29,7 @@ See kern \details{ Drought indices, such as the SPEI or the SPI, are usually computed at different time scales to adapt to the different response -times of systems affected by drought. This is acomplished by applying +times of systems affected by drought. This is accomplished by applying a kernel function to the data prior to computation of the SPEI. Application of a kernel has the effect of smoothing the temporal variability of the resulting SPEI, allowing for the major patterns diff --git a/man/Potential-evapotranspiration.Rd b/man/Potential-evapotranspiration.Rd index 1b5125c..f0be80a 100755 --- a/man/Potential-evapotranspiration.Rd +++ b/man/Potential-evapotranspiration.Rd @@ -57,13 +57,13 @@ thornthwaite(Tave, lat, na.rm = FALSE, verbose = TRUE) \item{U2}{a numeric vector, tsvector, matrix, tsmatrix, or 3-d array of monthly mean daily wind speeds at 2 m height, m s-1.} -\item{Rs}{optional, a numeric vector, tsvector, matrix, tsmatrix, or 3-d array of monthly mean dialy incoming solar radiation, MJ m-2 d-1.} +\item{Rs}{optional, a numeric vector, tsvector, matrix, tsmatrix, or 3-d array of monthly mean daily incoming solar radiation, MJ m-2 d-1.} \item{tsun}{optional, a numeric vector, tsvector, matrix, tsmatrix, or 3-d array of monthly mean daily bright sunshine hours, h.} \item{CC}{optional, numeric a vector, matrix or time series of monthly mean cloud cover, \%.} -\item{ed}{optional, numeric a vector, matrix or time series of monthly mean actual vapour pressure at 2 m height, kPa.} +\item{ed}{optional, numeric a vector, matrix or time series of monthly mean actual vapor pressure at 2 m height, kPa.} \item{Tdew}{optional, a numeric vector, tsvector, matrix, tsmatrix, or 3-d array of monthly mean daily dewpoint temperature (used for estimating ed), ºC.} @@ -263,7 +263,7 @@ plot(ts(cbind(pen_300, pen_co2), fr=12)) } \references{ Thornthwaite, C. W., 1948. An approach toward a rational classification of climate. -\emph{Geographical Review} \bold{38}: 55–94. doi:10.2307/2107309. +\emph{Geographical Review} \bold{38}: 55–94. DOI:10.2307/2107309. Hargreaves G.H., 1994. Defining and using reference evapotranspiration. \emph{Journal of Irrigation and Drainage Engineering} \bold{120}: 1132–1139. @@ -285,7 +285,7 @@ Rep. Task Com. on Standardized Reference Evapotranspiration July 9, 2002, EWRI Reston, VA, 57 pp. Yang, Y., Roderick, M.L., Zhang, S. McVicar, T., Donohue, R.J., 2019. Hydrologic implications of vegetation -response to elevated CO2 in climate projections. \emph{Nature Clim Change} \bold{9}: 44–48. +response to elevated CO2 in climate projections. \emph{Nature Climate Change} \bold{9}: 44–48. } \author{ Santiago Beguería From af1699d0891b97a28bcb180f6a285eade5cbd052 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Santiago=20Beguer=C3=ADa?= Date: Wed, 23 Nov 2022 18:21:33 +0100 Subject: [PATCH 13/14] Three-digits version number Adding three-digits version number as required by CRAN. --- DESCRIPTION | 2 +- NEWS.md | 4 ++-- README.md | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 6417e8c..3ea18ac 100755 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: SPEI Type: Package -Version: 1.8 +Version: 1.8.0 Title: Calculation of the Standardised Precipitation-Evapotranspiration Index Authors@R: c( person('Santiago', 'Beguería', role=c('aut','cre'), diff --git a/NEWS.md b/NEWS.md index 5a5699a..ac176e5 100644 --- a/NEWS.md +++ b/NEWS.md @@ -6,7 +6,7 @@ __Version history: -_Version 1.8, May 2022 (current development version on GitHub). +_### _Version 1.8.0, November 2022 (current version on GitHub, submitted to CRAN). 1. Solving several minor bugs in ``, ``, and `` functions (output difference less than 0.1%). 2. Solving a bug in `` that resulted in bad cumulative data when using a non-rectangular kernel, resulting in incorrect SPEI values. @@ -18,7 +18,7 @@ _Version 1.8, May 2022 (current development version on GitHub). 8. Implementation of a new option for when no wind data are available in function ``. 9. Function `` completely rewritten based on `ggplot2`, solving some bugs and enabling more flexibility. -_Version 1.7.2, June 2019 (current stable version on GitHub). +_Version 1.7.2, June 2019 (only on GitHub). 1. Allowing for data with frequency other than 12 in `` function. diff --git a/README.md b/README.md index 453b3ea..6883c70 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,7 @@ Other (possibly useful) references: ## Version history -### Version 1.8, May 2022 (current version on github). +### Version 1.8.0, November 2022 (current version on GitHub, submitted to CRAN). 1. Solving several minor bugs in ``, ``, and `` functions (output difference is lower than 0.1% with respect to version 1.7). 2. Solving a bug in `` that resulted in bad cumulative data when using a non-rectangular kernel, resulting in incorrect SPEI values. @@ -77,7 +77,7 @@ Other (possibly useful) references: 9. Functions `` and `` now admit time series of any frequency, and not only monthly (frequency 12) data. 10. Function `` completely rewritten based on `ggplot2`, solving some bugs and enabling more flexibility. -### Version 1.7.2, January 2018 (latest stable version on github). +### Version 1.7.2, January 2018 (only on GitHub). 1. Several code optimizations and improvements (by github user @doug-friedman). 2. Added formal unit testing with `testthat` (@doug-friedman). From 397afba40f784eca3afb47bc7286558f4870642f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Santiago=20Beguer=C3=ADa?= Date: Wed, 23 Nov 2022 18:27:46 +0100 Subject: [PATCH 14/14] Tall crop Changing 'long' to 'tall' in penman(), as long was a typo. --- R/penman.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/penman.R b/R/penman.R index d2cb148..553029f 100755 --- a/R/penman.R +++ b/R/penman.R @@ -465,7 +465,7 @@ penman <- function(Tmin, Tmax, U2=NULL, Ra=NULL, lat=NULL, Rs=NULL, # Daily ET0 (eq. 2.18) if (crop=='short') { c1 <- 900; c2 <- 0.34 # short reference crop (e.g. clipped grass, 0.12 m) - } else if (crop=='long') { + } else if (crop=='tall') { c1 <- 1600; c2 <- 0.38 # tall reference crop (e.g. alfalfa, 0.5 m) } else { stop(paste('An error occurred while estimating the daily ET0',