Skip to content

Commit 155095c

Browse files
authored
Merge pull request #9 from KWB-R/dev
First release
2 parents c8d2374 + e795796 commit 155095c

33 files changed

Lines changed: 677 additions & 642 deletions

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: kwb.rabimo
22
Title: R Implementation of Water Balance Model Abimo
3-
Version: 0.0.0.9000
3+
Version: 1.0.0
44
Authors@R: c(
55
person("Hauke", "Sonnenberg", , "hauke.sonnenberg@kompetenz-wasser.de", role = c("aut", "cre"),
66
comment = c(ORCID = "0000-0001-9134-2871")),

NAMESPACE

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@
33
export("%>%")
44
export(BERLIN_TYPES_TO_USAGE_YIELD_IRRIGATION)
55
export(abimo_config_to_config)
6-
export(actualEvaporationWaterbodyOrPervious)
6+
export(actual_evaporation_waterbody_or_pervious)
77
export(call_with_data)
8-
export(getPotentialEvaporation)
9-
export(getPrecipitation)
10-
export(getSoilProperties)
11-
export(getUsageTuple)
8+
export(get_potential_evaporation)
9+
export(get_precipitation)
10+
export(get_soil_properties)
11+
export(get_usage_tuple)
1212
export(index_string_to_integers)
1313
export(list_to_data_frame_with_keys)
14-
export(prepareInputData)
15-
export(realEvapoTranspiration)
14+
export(prepare_input_data)
15+
export(real_evapo_transpiration)
1616
export(run_rabimo)
17-
export(yearlyHeightToVolumeFlow)
17+
export(yearly_height_to_volume_flow)
1818
importFrom(dplyr,left_join)
1919
importFrom(kwb.utils,catAndRun)
2020
importFrom(kwb.utils,catIf)

NEWS.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
1+
# kwb.rabimo 1.0.0 (2023-11-09)
2+
3+
First release of kwb.rabimo. This version tries to simulate exactly what
4+
Abimo 3.3.0 (https://github.com/KWB-R/abimo/releases/tag/v3.3.0) does.
5+
When being applied to the Berlin data (kwb.abimo::abimo_input_2019) there
6+
are remaining maximum differences between intermediate variables calculated
7+
by Abimo and kwb.rabimo, respectively, between about -6% and + 2%. They are
8+
most probably the result of differences in the precision of fractional numbers
9+
and rounding behaviour in C++ and R, respectively.
10+
111
# kwb.rabimo 0.0.0.9000
212

313
* Added a `NEWS.md` file to track changes to the package.
4-
514
* see https://style.tidyverse.org/news.html for writing a good `NEWS.md`
6-
7-

R/abimo_config_to_config.R

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#' Convert Abimo Configuration to List
22
#'
33
#' @param abimo_config as returned by \code{kwb.abimo:::read_config}
4-
#' @return list with elements \code{"potentialEvaporation"},
5-
#' \code{"runoffFactors"}, \code{"bagrovValues"}, \code{"diverse"},
6-
#' \code{"resultDigits"}
4+
#' @return list with elements \code{"potential_evaporation"},
5+
#' \code{"runoff_factors"}, \code{"bagrov_values"}, \code{"diverse"},
6+
#' \code{"result_digits"}
77
#' @export
88
abimo_config_to_config <- function(abimo_config)
99
{
@@ -28,16 +28,16 @@ abimo_config_to_config <- function(abimo_config)
2828
expand_district_ranges() %>%
2929
all_columns_to_int() %>%
3030
rename_columns(list(eg = "etp")) %>%
31-
cbind(etps = -1L, isWaterbody = TRUE)
31+
cbind(etps = 0, is_waterbody = TRUE)
3232

3333
evap_else <- result %>%
3434
select_elements(element_else) %>%
3535
expand_district_ranges() %>%
3636
all_columns_to_int() %>%
37-
cbind(isWaterbody = FALSE)
37+
cbind(is_waterbody = FALSE)
3838

39-
result[["potentialEvaporation"]] <- rbind(evap_water, evap_else) %>%
40-
move_columns_to_front("isWaterbody")
39+
result[["potential_evaporation"]] <- rbind(evap_water, evap_else) %>%
40+
move_columns_to_front("is_waterbody")
4141

4242
convert_element <- function(config, from, to, convert = identity) {
4343
x <- select_elements(config, from)
@@ -48,19 +48,19 @@ abimo_config_to_config <- function(abimo_config)
4848
remove_elements(config, from)
4949
}
5050

51-
result %>%
51+
result <- result %>%
5252
remove_elements(c(
5353
element_water,
5454
element_else
5555
)) %>%
5656
convert_element(
5757
from = "Infiltrationsfaktoren",
58-
to = "runoffFactors",
58+
to = "runoff_factors",
5959
convert = function(x) 1 - as.numeric(x)
6060
) %>%
6161
convert_element(
6262
from = "Bagrovwerte",
63-
to = "bagrovValues",
63+
to = "bagrov_values",
6464
convert = as.numeric
6565
) %>%
6666
convert_element(
@@ -69,9 +69,15 @@ abimo_config_to_config <- function(abimo_config)
6969
) %>%
7070
convert_element(
7171
from = "ErgebnisNachkommaStellen",
72-
to = "resultDigits",
72+
to = "result_digits",
7373
convert = as.numeric
7474
)
75+
76+
result[["precipitation_correction_factor"]] <- as.numeric(
77+
select_elements(result, "diverse")[["NIEDKORRF"]]
78+
)
79+
80+
result
7581
}
7682

7783
# get_all_item_data ------------------------------------------------------------

0 commit comments

Comments
 (0)