Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Wrap your model in an R package!

Wrap your model in an R package!

The groundwater drawdown model WTAQ-2, provided by the United States Geological Survey for free, has been "wrapped" into an R package, which contains functions for writing input files, executing the model engine and reading output files. By calling the functions from the R package a sensitivity analysis, calibration or validation requiring multiple model runs can be performed in an automated way. Automation by means of programming improves and simplifies the modelling process by ensuring that the WTAQ-2 wrapper generates consistent model input files, runs the model engine and reads the output files without requiring the user to cope with the technical details of the communication with the model engine. In addition the WTAQ-2 wrapper automatically adapts cross-dependent input parameters correctly in case one is changed by the user. This assures the formal correctness of the input file and minimises the effort for the user, who normally has to consider all cross-dependencies for each input file modification manually by consulting the model documentation. Consequently the focus can be shifted on retrieving and preparing the data needed by the model. Modelling is described in the form of version controlled R scripts so that its methodology becomes transparent and modifications (e.g. error fixing) trackable. The code can be run repeatedly and will always produce the same results given the same inputs. The implementation in the form of program code further yields the advantage of inherently documenting the methodology. This leads to reproducible results which should be the basis for smart decision making.

Michael Rustler

June 28, 2016
Tweet

Other Decks in Programming

Transcript

  1. 1 www.kompetenz-wasser.de kwb-r.github.io your in an Michael Rustler & Hauke

    Sonnenberg Kompetenzzentrum Wasser Berlin @MichaelRustler mrustl !
  2. 4 www.kompetenz-wasser.de kwb-r.github.io Generic Case-specific Sensitivity analysis Calibration Challenges (Usually)

    not implemented in Generic “If you’re going to do something three times or more, you should think about writing a small package”(Peng,2016)
  3. 8 www.kompetenz-wasser.de kwb-r.github.io functions: 1. Create model configuration (R list)

    2. Write input file (text file) 3. Run model engine (text file) 4. Read output file (R data.frame) Model engine (source / binary) +
  4. 10 www.kompetenz-wasser.de kwb-r.github.io https://github.com/KWB-R/kwb.wtaq Thanks to for sponsoring this work

    within the project Tutorial: https://kwb-r.github.io/kwb.wtaq EPANET (USEPA) VS2DI (USGS) Summary “Wrapped“ models: Method: Wrap your model! (Sonnenberg et al. 2014) http://doi.org/10.13140/RG.2.1.2140.3683 WTAQ-2 (USGS)