Skip to content

Commit 8e7e8f9

Browse files
committed
Pass "config" instead of "abimo_config"
and return a data frame if called with vetors instead of scalars
1 parent dff4608 commit 8e7e8f9

2 files changed

Lines changed: 17 additions & 14 deletions

File tree

R/getPotentialEvaporation2.R

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,20 @@
66
#' of type (from the type/yield/irrigation tuple) "waterbody"
77
#' @param district (vector of) integer indicating the district number of the
88
#' plot area (from the original input column "BEZIRK")
9-
#' @param abimo_config list structure as returned by
10-
#' \code{kwb.abimo:::read_config}
9+
#' @param config list structure as returned by
10+
#' \code{\link{abimo_config_to_config}}
1111
#' @export
1212
#' @examples
1313
#' \dontrun{
14-
#' abimo_config <- kwb.abimo:::read_config()
14+
#' config <- abimo_config_to_config(kwb.abimo:::read_config())
1515
#' getPotentialEvaporation(
1616
#' is_waterbody = TRUE,
1717
#' district = 1,
18-
#' abimo_config = abimo_config
18+
#' config = config
1919
#' )
2020
#' }
2121
#'
22-
getPotentialEvaporation2 <- function(isWaterbody, district, abimo_config)
22+
getPotentialEvaporation2 <- function(isWaterbody, district, config)
2323
{
2424
#`%>%` <- magrittr::`%>%`
2525
#kwb.utils::assignPackageObjects("kwb.rabimo")
@@ -35,9 +35,7 @@ getPotentialEvaporation2 <- function(isWaterbody, district, abimo_config)
3535
)
3636

3737
# Create lookup table from abimo configuration object
38-
lookup <- abimo_config %>%
39-
abimo_config_to_config() %>%
40-
select_elements("potentialEvaporation")
38+
lookup <- select_elements(config, "potentialEvaporation")
4139

4240
result <- c(perYearInteger = "etp", inSummerInteger = "etps") %>%
4341
lapply(function(column) {
@@ -46,5 +44,10 @@ getPotentialEvaporation2 <- function(isWaterbody, district, abimo_config)
4644

4745
result[["perYearFloat"]] <- as.double(result[["perYearInteger"]])
4846

49-
result
47+
48+
if (all(lengths(result) == 1L)) {
49+
return(result)
50+
}
51+
52+
as.data.frame(result)
5053
}

man/getPotentialEvaporation2.Rd

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)