Title: | R Implementation of Water Balance Model Abimo |
---|---|
Description: | The code in this package has been transferred from the C++ code of ABIMO 3.3: Water Balance Model for Urban Areas (https://github.com/KWB-R/abimo/). |
Authors: | Hauke Sonnenberg [aut, cre] , Francesco Del Punta [aut], Kompetenzzentrum Wasser Berlin gGmbH (KWB) [cph] |
Maintainer: | Hauke Sonnenberg <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.0.1 |
Built: | 2024-11-20 10:37:12 UTC |
Source: | https://github.com/KWB-R/kwb.rabimo |
Convert Abimo Configuration to List
abimo_config_to_config(abimo_config)
abimo_config_to_config(abimo_config)
abimo_config |
as returned by |
list with elements "potential_evaporation"
,
"runoff_factors"
, "bagrov_values"
, "diverse"
,
"result_digits"
Calculate Actual Evapotranspiration for Waterbodies or Pervious Areas
actual_evaporation_waterbody_or_pervious( usage_tuple, potential_evaporation, soil_properties, precipitation, dbg = TRUE, ..., digits = NULL )
actual_evaporation_waterbody_or_pervious( usage_tuple, potential_evaporation, soil_properties, precipitation, dbg = TRUE, ..., digits = NULL )
usage_tuple |
list as returned by |
potential_evaporation |
potential evaporation in mm |
soil_properties |
list as returned by |
precipitation |
precipitation in mm |
dbg |
logical indicating whether or not to show debug messages |
... |
further arguments passed to |
digits |
optional. If given, the BAGROV parameter values are rounded to this number of digits. This reduces the number of BAGROV curves that need to be calculated and thus improves the performance (by reducing the precision of the output) |
The following tables are read from csv files and then merged:
BERLIN_TYPES_TO_USAGE_YIELD_IRRIGATION
BERLIN_TYPES_TO_USAGE_YIELD_IRRIGATION
An object of class data.frame
with 180 rows and 5 columns.
berlin_tuples.csv table of different occurring (usage, yield, irrigation) tuples
berlin_type_tuple_groups.csv assignments between berlin_type (input column "TYP") and tuples
berlin_usage_to_type_tuple_groups.csv assignments between berlin_usage (input column "NUTZUNG") and assignments between berlin_type (input column "TYP") and tuple
Call a Function with Argument Combinations from a Data Frame
call_with_data( FUN, data, ..., threshold = 0.5, SIMPLIFY = TRUE, USE.NAMES = TRUE )
call_with_data( FUN, data, ..., threshold = 0.5, SIMPLIFY = TRUE, USE.NAMES = TRUE )
FUN |
function to be called |
data |
data frame with one column per argument of |
... |
further (constant) arguments to |
threshold |
if the ratio of unique value combinations in the relevant columns in data to all value combinations in these columns is below this threshold value then FUN will be called only with the unique value combinations. This should increase performance. |
SIMPLIFY |
passed to |
USE.NAMES |
passed to |
vector of length nrow(data)
with the result values returned by
FUN
combis <- expand.grid(x = 1:2, y = c(10, 20, 30)) combis call_with_data(`+`, combis)
combis <- expand.grid(x = 1:2, y = c(10, 20, 30)) combis call_with_data(`+`, combis)
Provide Data on Potential Evaporation
get_potential_evaporation(is_waterbody, district, lookup)
get_potential_evaporation(is_waterbody, district, lookup)
is_waterbody |
(vector of) logical indicating whether a block area is of type (from the type/yield/irrigation tuple) "waterbody" |
district |
(vector of) integer indicating the district number of the plot area (from the original input column "BEZIRK") |
lookup |
data frame with key columns |
## Not run: config <- abimo_config_to_config(kwb.abimo:::read_config()) get_potential_evaporation( is_waterbody = TRUE, district = 1, lookup = config$potential_evaporation ) ## End(Not run)
## Not run: config <- abimo_config_to_config(kwb.abimo:::read_config()) get_potential_evaporation( is_waterbody = TRUE, district = 1, lookup = config$potential_evaporation ) ## End(Not run)
Provide Information on Precipitation
get_precipitation(precipitation_year, precipitation_summer, correction_factor)
get_precipitation(precipitation_year, precipitation_summer, correction_factor)
precipitation_year |
precipitation per year in mm |
precipitation_summer |
precipitation within summer period in mm |
correction_factor |
correction factor |
list with elements per_year
, in_summer
get_precipitation(600, 300, 0.8)
get_precipitation(600, 300, 0.8)
Provide variables that are relevant to calculate the actual evaporation for unsealed areas
get_soil_properties( usage, yield, depth_to_water_table, field_capacity_30, field_capacity_150, default_for_waterbodies = NA, dbg = FALSE )
get_soil_properties( usage, yield, depth_to_water_table, field_capacity_30, field_capacity_150, default_for_waterbodies = NA, dbg = FALSE )
usage |
usage string, one of "vegetationless_D", "waterbody_G", "horticultural_K", "agricultural_L", "forested_W" |
yield |
yield class |
depth_to_water_table |
depth to water table |
field_capacity_30 |
field capacity in 30 cm depth |
field_capacity_150 |
field capacity in 150 cm depth |
default_for_waterbodies |
value to be used for waterbodies. Default: NA |
dbg |
logical indicating whether or not to show debug messages |
Get Usage Tuple (Usage, Yield, Irrigation) from NUTZUNG and TYP
get_usage_tuple(usage, type, include_inputs = FALSE)
get_usage_tuple(usage, type, include_inputs = FALSE)
usage |
value of column NUTZUNG in input data frame |
type |
value of column TYP in input data frame |
include_inputs |
logical indicating whether or not to include the input values in the output |
list with elements usage
, yield
, irrigation
get_usage_tuple(10, 10) get_usage_tuple(10, 1:3)
get_usage_tuple(10, 10) get_usage_tuple(10, 1:3)
Convert e.g. "1,4-6,10-11,20" to c(1L, 4L, 5L, 6L, 10L, 11L, 20L)
index_string_to_integers(x, splits = c(",", "-"))
index_string_to_integers(x, splits = c(",", "-"))
x |
vector of character of length one representing a string
of integer ranges, e.g. |
splits |
characters at which to 1. split |
vector of integer
index_string_to_integers("1,4-6,10-11,20")
index_string_to_integers("1,4-6,10-11,20")
Convert List of Similar Flat Sublists to a Data Frame
list_to_data_frame_with_keys(x, key_name, key_pattern, convert = identity)
list_to_data_frame_with_keys(x, key_name, key_pattern, convert = identity)
x |
list of similar flat lists, i.e. lists that have list elements with the same names and list elements that all have length one |
key_name |
name of column in the returned data frame that will contain
the integer values that are constructed from the element names in |
key_pattern |
regular expression matching all element names in |
convert |
function to be applied to the (character) key. Set e.g.
|
data frame with keys in a column named according to key_name
and value columns according to the list elements in the sublists of
x
list_to_data_frame_with_keys( x = list( element_1 = list(a = 100, b = 10), element_2 = list(a = 200, b = 20) ), key_name = "element", key_pattern = "element_([0-9]+)", convert = as.integer )
list_to_data_frame_with_keys( x = list( element_1 = list(a = 100, b = 10), element_2 = list(a = 200, b = 20) ), key_name = "element", key_pattern = "element_([0-9]+)", convert = as.integer )
Rename columns from ABIMO 3.2 original names to ABIMO 3.3 internal names
prepare_input_data(input_data)
prepare_input_data(input_data)
input_data |
data frame with columns REGENJA, REGENSO, NUTZUNG, TYP, BEZIRK, FLGES, STR_FLGES, PROBAU, PROVGU, VGSTRASSE, KAN_BEB, BELAG1, BELAG2, BELAG3, BELAG4, KAN_VGU, STR_BELAG1, STR_BELAG2, STR_BELAG3, STR_BELAG4, KAN_STR, FLUR, FELD_30, FELD_150 |
input_data
with columns renamed and additional columns
(e.g. ratios calculated from percentages, (main) usage, yield, irrigation)
Sequence of Values Between the Range of Values in a Given Vector
range_to_seq(x, by = 1)
range_to_seq(x, by = 1)
x |
vector of values from which to take the range |
by |
increment of seqence |
sequence of values between min(x)
and max(x)
with
increment by
Calculate Actual Evapotranspiration with Bagrov
real_evapo_transpiration( precipitation, potential_evaporation, bagrov_parameter, x_ratio = NULL, FUN_y_ratio = y_ratio_3, ... )
real_evapo_transpiration( precipitation, potential_evaporation, bagrov_parameter, x_ratio = NULL, FUN_y_ratio = y_ratio_3, ... )
precipitation |
precipitation in mm |
potential_evaporation |
potential evaporation in mm |
bagrov_parameter |
Bagrov parameter (n-value) |
x_ratio |
optional. Instead of |
FUN_y_ratio |
function to be called to calculate the y_ratio(s) from the
given x_ratio(s). Default: |
... |
further arguments passed to |
estimated actual evapotranspiration in mm
Run R-Abimo, the R-implementation of Water Balance Model Abimo
run_rabimo(input_data, config, simulate_abimo = TRUE)
run_rabimo(input_data, config, simulate_abimo = TRUE)
input_data |
data frame with columns as required by Abimo |
config |
configuration object (list) as returned by
|
simulate_abimo |
logical of length one indicating whether or not to
simulate exactly what Abimo does (including obvious errors!).
Default: |
data frame with columns as returned by Abimo
Lookup y_ratio for given x_ratio on a BAGROV curve
y_ratio_3( bagrov_parameter, x_ratio, min_size_for_parallel = 10L, use_abimo_algorithm = FALSE )
y_ratio_3( bagrov_parameter, x_ratio, min_size_for_parallel = 10L, use_abimo_algorithm = FALSE )
bagrov_parameter |
(vector of) BAGROV parameter(s) |
x_ratio |
(vector of) x-ratio(s) (between precipitation and potential evaporation) for which to look up the corresponding y-ratio(s) (between actual evaporation and potential evaporation) on the BAGROV curve(s) |
min_size_for_parallel |
minimum number of BAGROV curves to start parallel processing |
use_abimo_algorithm |
whether or not to use the original algorithm that
is implemented in the C++ code (converted to R:
|
Convert Yearly Height (mm) to Volume Flow (unit?)
yearly_height_to_volume_flow(height, area)
yearly_height_to_volume_flow(height, area)
height |
height in mm |
area |
area in square metres |