Skip to content

Commit c8d2374

Browse files
authored
Merge pull request #3 from KWB-R/dev
Dev
2 parents 6eba51a + 92c0d73 commit c8d2374

24 files changed

Lines changed: 1721 additions & 399 deletions

DESCRIPTION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Imports:
2424
kwb.utils,
2525
magrittr,
2626
methods,
27+
parallel,
2728
xml2
2829
Remotes:
2930
github::kwb-r/kwb.abimo,

NAMESPACE

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
export("%>%")
44
export(BERLIN_TYPES_TO_USAGE_YIELD_IRRIGATION)
55
export(abimo_config_to_config)
6-
export(actualEvaporation)
6+
export(actualEvaporationWaterbodyOrPervious)
77
export(call_with_data)
8-
export(getDefaultConfiguration)
98
export(getPotentialEvaporation)
109
export(getPrecipitation)
1110
export(getSoilProperties)
@@ -14,19 +13,32 @@ export(index_string_to_integers)
1413
export(list_to_data_frame_with_keys)
1514
export(prepareInputData)
1615
export(realEvapoTranspiration)
16+
export(run_rabimo)
1717
export(yearlyHeightToVolumeFlow)
1818
importFrom(dplyr,left_join)
19+
importFrom(kwb.utils,catAndRun)
1920
importFrom(kwb.utils,catIf)
21+
importFrom(kwb.utils,checkForMissingColumns)
22+
importFrom(kwb.utils,createAccessor)
23+
importFrom(kwb.utils,defaultIfNULL)
24+
importFrom(kwb.utils,getAttribute)
25+
importFrom(kwb.utils,inRange)
2026
importFrom(kwb.utils,moveColumnsToFront)
2127
importFrom(kwb.utils,multiColumnLookup)
2228
importFrom(kwb.utils,printIf)
2329
importFrom(kwb.utils,removeColumns)
2430
importFrom(kwb.utils,removeElements)
31+
importFrom(kwb.utils,renameAndSelect)
2532
importFrom(kwb.utils,renameColumns)
2633
importFrom(kwb.utils,resetRowNames)
2734
importFrom(kwb.utils,safeRowBindAll)
2835
importFrom(kwb.utils,selectColumns)
2936
importFrom(kwb.utils,selectElements)
3037
importFrom(kwb.utils,stopFormatted)
38+
importFrom(kwb.utils,stringList)
3139
importFrom(magrittr,"%>%")
3240
importFrom(methods,formalArgs)
41+
importFrom(parallel,detectCores)
42+
importFrom(parallel,makeCluster)
43+
importFrom(parallel,parLapply)
44+
importFrom(parallel,stopCluster)

R/abimo_config_to_config.R

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#' Convert Abimo Configuration to List
22
#'
33
#' @param abimo_config as returned by \code{kwb.abimo:::read_config}
4-
#' @return list of data frames
4+
#' @return list with elements \code{"potentialEvaporation"},
5+
#' \code{"runoffFactors"}, \code{"bagrovValues"}, \code{"diverse"},
6+
#' \code{"resultDigits"}
57
#' @export
68
abimo_config_to_config <- function(abimo_config)
79
{
@@ -37,7 +39,39 @@ abimo_config_to_config <- function(abimo_config)
3739
result[["potentialEvaporation"]] <- rbind(evap_water, evap_else) %>%
3840
move_columns_to_front("isWaterbody")
3941

40-
remove_elements(result, c(element_water, element_else))
42+
convert_element <- function(config, from, to, convert = identity) {
43+
x <- select_elements(config, from)
44+
config[[to]] <- stats::setNames(
45+
convert(select_columns(x, "value")),
46+
select_columns(x, "key")
47+
)
48+
remove_elements(config, from)
49+
}
50+
51+
result %>%
52+
remove_elements(c(
53+
element_water,
54+
element_else
55+
)) %>%
56+
convert_element(
57+
from = "Infiltrationsfaktoren",
58+
to = "runoffFactors",
59+
convert = function(x) 1 - as.numeric(x)
60+
) %>%
61+
convert_element(
62+
from = "Bagrovwerte",
63+
to = "bagrovValues",
64+
convert = as.numeric
65+
) %>%
66+
convert_element(
67+
from = "Diverse",
68+
to = "diverse"
69+
) %>%
70+
convert_element(
71+
from = "ErgebnisNachkommaStellen",
72+
to = "resultDigits",
73+
convert = as.numeric
74+
)
4175
}
4276

4377
# get_all_item_data ------------------------------------------------------------

0 commit comments

Comments
 (0)