Department Urban Water Management


Sewage Pattern Generator (SPG)

SPG is an R-package that provides functions to:

  1. simulate flow and substance patterns at high temporal resolution (complex sewer networks including pump stations)
  2. evaluate and optimize sampling setups to facilitate the collection of representative composite samples


The main aim of SPG is to efficiently model realistic short-term variations of flows and substances in sewers and to evaluate the suitability of different sampling setups. In addition to complex sewer networks, the package is also particularly useful to optimize sampling at the effluent of individual premises (e.g. hospital, school, prison) where short-term variations are typically highest and challenge the reliable collection of representative average samples over a period of time. The focus is on down-the-drain chemicals, e.g. pharmaceuticals or illicit drugs that usually enter the sewer system through toilet flushes. Since toilet flushes are distinct pulses of short-duration, „short-term variations“ at a potential sampling location requires modeling pollutant fluxes dynamically with a temporal resolution of 1-2 minutes.

Different scenarios (e.g. distribution of substance across sub-catchments) and sampling setups can be evaluated at relatively low computational cost. The processes advection and dispersion are considered.

Download (v1.01):

The authors welcome any kind of feedback.


The R-package SPG was developed within the project SEWPROF - A new paradigm in drug use and human health risk assessment: Sewage profiling at the community level.



Sustainable Network Infrastructure Planning (SNIP)

SNIP is a python based software package with an ArcGIS interface to determine the optimal degree of centralisation for wastewater infrastructure systems. Based on GIS input data an optimal separate sewer system is designed based on different sewer design criteria.


SNIP is thoroughly explained in: Eggimann, S., Truffer, B., Maurer, M. (2015): To connect or not to connect? Modelling the optimal degree of centralisation for wastewater infrastructures. Water Research, 84, 218-231. Link.



Github (Python Source-Code & ArcToolbox)

Example Data (Small test dataset)

Installation Guide (Help on how to use SNIP)


Adaptive Monte Carlo Markov chain sampler (adaptMCMC)

 R package that provides an implementation of the generic adaptive Monte Carlo Markov chain (MCMC) sampler proposed by Vihola (2011). MCMC samplers are often used to perform Bayesian inference.


Vihola, M., 2011. Robust adaptive Metropolis algorithm with coerced acceptance rate. Statistics and Computing. doi:10.1007/s11222-011-9269-5.



Andreas Scheidegger Statistics, Data Science & Modeling Tel. +41 58 765 5053 Send Mail

Sewer deterioration model (SWIP-SDM)


Predictions of the structural condition of urban drainage networks enables us to estimate future investment costs under various rehabilitation strategies. This facilitates proactive, far-sighted sewer asset management, which, in turn, contributes to a better balance between expenses and system performance.

Many sewer deterioration models have been formulated to predict the physical aging of pipes in terms of discrete sewer condition states. However, in many cases there is not sufficient information available to calibrate them. A severe  issue is that historical asset data is not available. Specifically, the lack of the following information often hinders us to calibrate sewer deterioration models:

  • (i) Condition records of sewer pipes which have been replaced by new ones. The corresponding records are discarded from the database and replaced by the new information.
  • (ii) Condition ratings of renovated or repaired sewer pipes from the time before such action. The repaired or renovated pipes are reassessed. On the basis of this reassessment, the condition rating prior to repair or renovation is overwritten by a new (typically better) condition rating. Thus, such records should be excluded from the analysis. The condition of such pipes is the result of not only aging but also rehabilitation.

When a sewer deterioration model is calibrated without explicitley accounting for effect (i) and (ii) the predictions suffer a ‘survival selection bias’ (Scheidegger et al., 2011).

The SWIP-SDM represents a simple probabilistic sewer deterioration model and provides the possibility to infer the deterioration parameters from data lacking historical information as defined by case (i) and (ii). Details of the model are given in Egger et al. (2013).


The R code provided below allows for model calibration and forecasting of condition states of the network. Model calibration is done by Bayesian inference (Egger et al., 2013). The likelihood functions described in Egger et al. (2013) (Eq. 1 and 6) are extended so that also condition data from two subsequent inspections per pipe can be used for parameter inference.

Model files contains the required R code. Look at SDM_inference.R to do parameter inference and at SDM_forecast.R to predict future condition states for a given model parameters.

Example data

For demonstration additionally two datasets are provided. Both contain the condition ratings of a sewer network which underwent substantial rehabilitation in form of pipe replacements in the last 30 years. Each row of the datasets represents one pipe with one or two observed condition states. Dataset dataset_example_complete.RData contains the condition records of all pipes ever constructed, i.e. it includes also pipes that have been replaced in the past. The data set dataset_example_incomplete.RData is more realistic. It contains only those pipes that are still in service, i.e. the data set lacks historical data of pipes replaced in the past (according to case (i) defined above).

Matching parameters for a log-normal prior distribution are contained in prior_complete.RData and prior_incomplete.RData respectively.


The development of SWIP-SDM was part of the National Research Project 61 (NRP 61) funded by the Swiss National Science Foundation (SNF) (project number 406140_125901/1).


Egger, C., Scheidegger, A., Reichert, P. and Maurer, M. (2013) Sewer deterioration modeling with condition data lacking historical records. Water Research 47(17), 6762-6779.

Scheidegger, A., Hug, T., Rieckermann, J. and Maurer, M. (2011) Network condition simulator for benchmarking sewer deterioration models. Water Research 45(16), 4983-4994

Urban Water Infrastructure Model (UWIM)

The urban water infrastructure model (UWIM) is a conceptual model that describes the water infrastructure of a settlement quantitatively in terms of generic input parameters, such as size of catchment area, number of buildings.

For more information see the project description.

UWIM is licensed under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

Getting started

  1. Download and install R
  2. Download and unzip
  3. Change in "UWIM_main_s.r" the working directory at line 31
  4. Run "UWIM_main_s.r" in R


Publication related scripts

Maurer et al. (2012), "A compatibility-based procedure designed to generate potential sanitation-system alternatives"

R-script to calculates the number of possible sanitation systems
(SanSys) given a compatible matrix for the 'wet', 'urine', and 'feces'
streams as described in Maurer et al. (2012).

Maurer et al. (2012), "A compatibility-based procedure designed to generate potential sanitation-system alternatives",  Journal of Environmental Management.

Download script  (ZIP file)