Package 'kwb.abimo'

Title: R Package with Functions for Working with Water Balance Model ABIMO
Description: R Package with functions for working with water balance bodel ABIMO https://www.stadtentwicklung.berlin.de/umwelt/umweltatlas/download/goedecke_et_al_abimo2019_doku.pdf).
Authors: Andreas Matzinger [aut, cre] (ORCID: <https://orcid.org/0000-0001-5483-4594>), Michael Rustler [ctb] (ORCID: <https://orcid.org/0000-0003-0647-7726>), Hauke Sonnenberg [ctb] (ORCID: <https://orcid.org/0000-0001-9134-2871>), KEYS [fnd], Kompetenzzentrum Wasser Berlin gGmbH (KWB) [cph]
Maintainer: Andreas Matzinger <[email protected]>
License: MIT + file LICENSE
Version: 0.4.0
Built: 2026-06-06 06:57:11 UTC
Source: https://github.com/KWB-R/kwb.abimo

Help Index


adapt ABIMO output dbf-file to Berlin shape file

Description

changes order in dbf-file to match geographical shape file of Berlin "Stadtstruktur"

Usage

ABIMO_adapt_map(ABIMO_out, file_georef, out_file)

Arguments

ABIMO_out

data.frame of ABIMO output file

file_georef

path of dbf file that matches existing shape (incl. path)

out_file

file path and file name for ordered ABIMO output file (to be linked to shape files)

Value

ordered dbf returned and written to out_file


calculate Berlin average of water balance terms

Description

multiplies each water balance component by area, sums them up and divides the sum by the total surface

Usage

abimo_Berlin_average(abimo_df)

Arguments

abimo_df

data.frame of ABIMO output file, merged with input file

Value

table with averages in mm of water balance components


join ABIMO in- and output files

Description

join ABIMO in- and output files

Usage

abimo_comb_in_out(file_ABIMO_out, file_ABIMO_in)

Arguments

file_ABIMO_out

path of ABIMO output file in dbf format (incl. path)

file_ABIMO_in

path of ABIMO input file in dbf format (incl. path)

Value

data.frame with matched ABIMO in- and output data


Compares ABIMO-output-file to reference (or other ABIMO output file)

Description

Compares two ABIMO-output-files by plotting parameters compared to 1:1 line into pdf-File and by doing a simple column statistics.

Usage

abimo_compare_output(x_reference, x_new)

Arguments

x_reference

reference data frame with ABIMO output (can be ABIMO output or downloaded from Berlin geoportal)

x_new

new ABIMO output to be compared to reference

Value

data.frame of column statistics; plots and evaluation open as pdf


calculate groundwater recharge and interflow

Description

uses correction factor to calculate groundwater recharge from infiltration RI. Difference is interflow. Requires a combined data.frame of ABIMO output and input, e.g. by using function abimo_comb_in_out

Usage

abimo_grwater_interflow(abimo_df)

Arguments

abimo_df

data.frame of ABIMO output file, merged with input file

Value

input data.frame with two new columns "RI_K" and "INTERF"


"Official" Abimo Input Data for Berlin, 2019, with streets

Description

The data was read from a file called "abimo_2019_mitstrassen.dbf" using read.dbf. For a description of the input data, see the URL below.

Usage

abimo_input_2019

Format

A data frame with 25352 observations of 34variables:

CODE

Variable 'CODE', see URL below

BEZIRK

Variable 'BEZIRK', see URL below

STAGEB

Variable 'STAGEB', see URL below

BLOCK

Variable 'BLOCK', see URL below

TEILBLOCK

Variable 'TEILBLOCK', see URL below

NUTZUNG

Variable 'NUTZUNG', see URL below

TYP

Variable 'TYP', see URL below

FLGES

Variable 'FLGES', see URL below

VG

Variable 'VG', see URL below

PROBAU

Variable 'PROBAU', see URL below

PROVGU

Variable 'PROVGU', see URL below

REGENJA

Variable 'REGENJA', see URL below

REGENSO

Variable 'REGENSO', see URL below

BELAG1

Variable 'BELAG1', see URL below

BELAG2

Variable 'BELAG2', see URL below

BELAG3

Variable 'BELAG3', see URL below

BELAG4

Variable 'BELAG4', see URL below

VGSTRASSE

Variable 'VGSTRASSE', see URL below

STR_BELAG1

Variable 'STR_BELAG1', see URL below

STR_BELAG2

Variable 'STR_BELAG2', see URL below

STR_BELAG3

Variable 'STR_BELAG3', see URL below

STR_BELAG4

Variable 'STR_BELAG4', see URL below

KANAL

Variable 'KANAL', see URL below

KANART

Variable 'KANART', see URL below

KAN_BEB

Variable 'KAN_BEB', see URL below

KAN_VGU

Variable 'KAN_VGU', see URL below

KAN_STR

Variable 'KAN_STR', see URL below

FELD_30

Variable 'FELD_30', see URL below

FELD_150

Variable 'FELD_150', see URL below

FLUR

Variable 'FLUR', see URL below

STR_FLGES

Variable 'STR_FLGES', see URL below

KOR_FL_N

Variable 'KOR_FL_N', see URL below

AGEB1_NR

Variable 'AGEB1_NR', see URL below

AGEB1

Variable 'AGEB1', see URL below

Source

https://www.berlin.de/umweltatlas/_assets/literatur/goedecke_et_al_abimo2019_doku.pdf


Reads two ABIMO output files

Description

Reads a new ABIMO output file in dbase format. In addition the original SENSTADTUM output file is read and made comparable. Alternatively two new ABIMO output files can be read. Output are two comparable (same dimensions and column names) data frames.

Usage

ABIMO_read_output(SENSTADTUM_dbf, new_dbf)

Arguments

SENSTADTUM_dbf

path of original SENSTADTUM-database

new_dbf

path of new output-database

Value

output are two comparable (same dimensions and column names) data frames.


change "BERtoZero"-settings in Abimo config.xml to true

Description

as default irrigation of pervious areas is assumed based on "Nutzung" and "Typ". This function turns of irrigation for all areas (BERtoZero = true)

Usage

abimo_xml_BER(file_in = default_config(), file_out, line_BER = 56)

Arguments

file_in

path and file name of abimo xml-input file, default is default_config

file_out

path and file name to write changed abimo xml-input file

line_BER

line number in xml-file, where BERtoZero is defined, default is 56

Value

abimo xml-input file with changed BERtoZero-setting


change potential evaporation in Abimo config.xml

Description

potential evaporation (annual and summer) is a boundary condition defined in config.xml. This function sets potential evaporation to a given value for all surfaces (except lakes and rivers)

Usage

abimo_xml_evap(file_in = default_config(), file_out, evap_annual, evap_summer)

Arguments

file_in

path and file name of abimo xml-input file, default is default_config

file_out

path and file name to write changed abimo xml-input file

evap_annual

annual potential evaporation

evap_summer

potential evaporation for summer months

Value

abimo xml-input file with changed potential evaporation


add ISU5 ID to dbf file from geoportal

Description

the ID is an unambiguous identifier for all blocks of the Berlin Geoportal but is usually hidden

Usage

add_ISU5_ID(
  x_no_ID,
  ID_dbf = "C:/Aendu_lokal/ABIMO_Paper/Daten/Karten/Basis_ISU5_Daten_2015/ISU5_ID.dbf"
)

Arguments

x_no_ID

data.frame created from dbf file, downloaded from Berlin geoportal

ID_dbf

path of dbf file including ids, default is set to local folder with ISU5-Ids

Value

data.frame of x_no_ID with a new column "ID"


Add "SUB" field to dbf-File

Description

Adds "SUB" field to the end of an existing file, as expected by some older applications (such as input-dbf-file for ABIMO) function by grandmaster HAUKESON

Usage

appendSubToFile(filename)

Arguments

filename

Path of file name of data.frame

Value

dbf file with sub field


Calculate the curve(s) of the Bagrov relation

Description

Calculate the curve(s) of the Bagrov relation

Usage

calculate_bagrov_curve(
  effectivity,
  P_over_Ep_max = 4,
  Ep = 650,
  delta_Ea = 0.1,
  dbg = FALSE
)

Arguments

effectivity

Bagrov effectivity value (= n-value)

P_over_Ep_max

maximum value of the ratio P/Ep with precipitation P and potential evaporation Ep.

Ep

potential evaporation in mm/a (default: 650)

delta_Ea

step of actual evaporation (default: 0.1)

dbg

logical indicating whether or not to show debug messages

Value

data frame with columns P_over_Ep (P/Ep), Ea_over_Ep (Ea/Ep), effectivity (n-value)

Examples

## Not run: 
bagrov_data <- calculate_bagrov_curve(1:2)
plot(bagrov_data$P_over_Ep, bagrov_data$Ea_over_Ep)

## End(Not run)

Create Configuration Object from Abimo Configuration File

Description

Create Configuration Object from Abimo Configuration File

Usage

create_configurator(xml_file = NULL)

Arguments

xml_file

path to "config.xml". By default a configuration file that is stored in this package (system.file("extdata/config.xml")) is used.

Value

object of class "abimo_config"


Default ABIMO config.xml path

Description

Default ABIMO config.xml path

Usage

default_config()

Examples

kwb.abimo::default_config()

Get Path to File in This Package

Description

Get Path to File in This Package

Usage

extdata_file(..., must_exist = TRUE, dbg = FALSE)

Arguments

...

parts of the file path to be passed to system.file

must_exist

if TRUE (the default) and the specified file does not exist, the program stops with an error message

dbg

if TRUE (the default is FALSE) debug messages are shown


Get Bagrov curves from Abimo software

Description

Call Abimo with the –write-bagrov-table argument being set and convert the console output to a data frame

Usage

get_bagrov_curves_from_abimo()

Value

data frame with columns P_over_Ep (P/Ep), Ea_over_Ep (Ea/Ep), effectivity (n-value)


Return List of XPath Expressions to Address Config Elements

Description

Return List of XPath Expressions to Address Config Elements

Usage

get_xpaths()

Value

List structure containing XPath expressions (see e.g. https://www.w3schools.com/xml/xpath_intro.asp)


Install ABIMO

Description

Install ABIMO

Usage

install_abimo(
  tag = latest_abimo_version(),
  arch = get_architecture_suffix(),
  ...
)

Arguments

tag

tag of ABIMO version to be installed, e.g. "v3.2.2"

arch

target system architecture, one of "windows", "linux", "macos"

...

further arguments passed to kwb.abimo:::download_assets


Read Abimo Configuration from XML File

Description

Read Abimo Configuration from XML File

Usage

read_config(file = default_config())

Arguments

file

path to XML file


Read Intermediate Results from Log File

Description

Read Intermediate Results from Log File

Usage

read_intermediate_results_from_log(
  file = file.path(tempdir(), "abimo_input_result.log"),
  pattern_remove = "Start|unknown|angenommen|nicht definiert|std::"
)

Arguments

file

path to log file

pattern_remove

regular expression matching lines to remove from the log file before looking for "variable=expression" assignments


Helper function: replace value

Description

searches string for parameter=<pattern_value> and replaces with parameter=<new_value> for all found entries

Usage

replace_value(
  string,
  new_value,
  parameter = "etp",
  pattern_value = "\"[0-9]+?\\.?[0-9]+?\""
)

Arguments

string

string with ABIMO config

new_value

new parameter value

parameter

parameter name to search for (default: "etp")

pattern_value

pattern of value field (default: '\"[0-9]+?\.?[0-9]+?\"')

Value

returns string with modified parameter = value

Examples

### Simple string
string <- '<item bezirke="15,16,18,19,20" etp="807" etps="600" />'
replace_value(string, new_value = 100, parameter = "etp")
replace_value(string, new_value = 100, parameter = "etps")
### Default ABIMO config
config <- readLines(kwb.abimo::default_config())
replace_value(config, new_value = 100, parameter = "etp")

Run Abimo with Input Data or Input File

Description

Run Abimo with Input Data or Input File

Usage

run_abimo(
  input_file = NULL,
  input_data = NULL,
  output_file = NULL,
  config_file = NULL,
  config = NULL,
  tag = latest_abimo_version(),
  read_intermediates = FALSE
)

Arguments

input_file

path to input dbf file

input_data

data frame from which a temporary input file is to be generated

output_file

path to output file. By default the output file has the same name as the input file with "_result" appended

config_file

optional. Path to config.xml file

config

optional. Configuration object of class "abimoConfig", as returned by create_configurator. If given, config_file is ignored.

tag

version tag of Abimo release to be used, see https://github.com/KWB-R/abimo/releases.

read_intermediates

if TRUE the values of intermediate variables are read from the log file (if applicable). The default is FALSE.

Value

data frame, read from dbf file that was created by Abimo.exe. If read_intermediates is TRUE, intermediate results are returned in the attribute "intermediates"


Run Abimo on the Command Line

Description

Run Abimo on the Command Line

Usage

run_abimo_command_line(args, tag = latest_abimo_version())

Arguments

args

vector of arguments to be passed to Abimo

tag

version tag of Abimo release to be used, see https://github.com/KWB-R/abimo/releases

Value

The function returns what Abimo.exe sent to the standard output (as a vector of character).


writes data.frame into ABIMO-dbf

Description

Saves an existing data.frame into dBase-format and adds "SUB" field to the end of the file as required by ABIMO

Usage

write.dbf.abimo(df_name, new_dbf)

Arguments

df_name

name of data.frame

new_dbf

path of new ABIMO-input file to be written (.dbf)

Value

dbf file that can be processed by ABIMO