RMWSPy (v 1.1): A Python code for spatial simulation and inversion for environmental applications
Introduction
The simulation of conditional spatial random fields is a common task in earth and environmental sciences. There is a variety of established methods to perform such simulations, for example Turning band simulation, Kriging simulation or sequential Gaussian simulation (Journel, 1974; Isaaks, 1990; Wackernagel, 1998). However, the simulation problem becomes much more challenging if more complex types of conditioning constraints such as non-linear constraints are involved. Non-linear constraints can, for example, arise when measurements of a secondary variable (which is related to the primary variable of interest via complex mathematical functions such as partial differential equations) are used to condition the simulation of the primary variable. Some examples of these include using hydraulic pressure head observations to condition the simulation of hydraulic conductivity (Evensen, 2003; Hendricks-Franssen et al., 2009; Li et al., 2015), using groundwater chemistry observations such as tracer or contaminant concentrations to condition the simulation of hydraulic conductivity (Hendricks-Franssen et al., 2003; Hassan et al., 2009), or using electrical resistivity tomography data to condition the simulation of electrical conductivity (Loke and Barker, 1996; Codd and Gross, 2018; Hörning et al., 2020). In general, most geophysical measurements record information on a secondary variable rather than the actual primary variable of interest.
In this paper, a generalized approach based on Random Mixing (RM) for simulating conditional spatial random fields and inverse modelling is presented. RM is a geostatistical simulation approach that was first introduced by Bárdossy and Hörning (2016b) and Bárdossy and Hörning (2016a) where the authors applied it to inverse groundwater flow and transport problems. A detailed description of the RM theory can be found in Hörning (2016), an application to inverse hydrological modelling is presented in Grundmann et al. (2019) and its extension via Whittaker-Shannon interpolation (Random Mixing Whittaker-Shannon, hence RMWS) is presented in Hörning et al. (2019).
RMWS is model-independent and allows flexible integration and combination of different conditioning constraints including non-linear constraints. The approach is developed as a set of Python scripts. Python is an interpreted, high-level, object-oriented programming language that is widely used in the scientific community (Pérez et al., 2011). It has a more powerful syntax and a more complete set of data structures compared to low-level languages such as C or FORTRAN. Python runs on virtually every operating system that is available. Besides the Python core language there is a variety of Python packages for almost any type of scientific analysis. For example, NumPy is for working with arrays (Oliphant, 2015), SciPy offers a wide range of optimization and statistics routines (Jones et al., 2001; Virtanen et al., 2020) and Matplotlib provides high-quality graphics routines (Hunter, 2007). Python and most of its packages are open-source software.
The generalized implementation of the Random Mixing Whittaker-Shannon algorithm presented in this paper is an open-source Python package (RMWSPy) for simulating conditional spatial random fields and inverse modelling. The idea is to provide a flexible conditional simulation and inversion environment that is applicable to a wide range of environmental modelling problems. As such, RMWSPy exhibits similarities to the MAD# inverse modelling framework (Osorio-Murillo et al., 2015), however, the RMWSPy concept is that the user writes Python scripts that define the problem (domain, constraints, specific objective function etc.), creates a link to the RMWS simulation algorithm and performs the desired pre- and post-processing. While writing scripts seems less user-friendly than using a GUI for example, it has advantages in terms of flexibility. RMWSPy has been developed such that it can easily be coupled with a wide range of numerical models such as MODFLOW (Harbaugh, 2005; Harbaugh et al., 2017) or HydroGeoSphere (Therrien and Sudicky, 1996). Users can also develop their own (forward) model that can be incorporated into Python or connected to the RMWSPy scripts. Further, RMWSPy enables straight forward parallelization for example via multi-threading or MPI.
The paper is divided into four sections. After the introduction, the theory of Random Mixing is briefly introduced in Section 2. The example application which is also included in the GitHub repository is presented in Section 3. It introduces the synthetic data set and describes the application of RMWSPy to that specific example such that the reader can follow and repeat the individual steps of the algorithm. The results of the example application are discussed and the paper ends with conclusions in Section 4.
Section snippets
Theory
In the following, only a brief description of the theory of RMWS is presented. The interested reader is referred to Hörning et al. (2019) where the Random Mixing Whittaker-Shannon algorithm is described comprehensively.
In general, the goal of RMWS is to find a field with such that this field honors the observed spatial dependence structure, the observed marginal distribution as well as potential linear and non-linear observations. Linear (or direct) observations are values of the
A RMWSPy example
The use of RMWSPy requires a basic understanding of the Python programming language, as well as of object-oriented code design. Its very basic use case as a conditional spatial random field simulation tool is presented as a Jupyter Notebook which can be found in the GitHub repository.
The example application presented in this paper is a complex synthetic inversion case based on Haese et al. (2017). It demonstrates how to handle a combination of linear and non-linear constraints and it has been
Conclusions
The use of RMWSPy offers a very general framework for conditional spatial simulation and inversion for environmental modelling problems. It can be used as an independent, standalone Python package or in conjunction with other programming languages and numerical (forward) models. Using a high-level programming language such as Python allows complicated tasks to be achieved within a few lines of code, which is also straightforward to read. The scripting approach rather than using a GUI offers a
Code and data availability
All code developments presented here are open-source tools released under the GNU General Public License v3.0. Source code version 1.1 used in this paper is archived online at https://github.com/SebastianHoerning/RMWSPy.
Declaration of competing interest
The authors declare that they have no known competing financial interests or personal relationships that could have appeared to influence the work reported in this paper.
Acknowledgements
The research for this paper was partly supported by the German Research Foundation (Deutsche Forschungsgemeinschaft, FOR2131 - Data Assimilation for Improved Characterization of Fluxes across Compartmental Interfaces, Projektnummer: 652387, KU ) and partly by the Energi Simulation Program. The authors would also like to thank The University of Queensland Centre for Natural Gas and its industry members (APLNG, Arrow Energy and Santos) for providing research funding. The authors gratefully
References (39)
- et al.
Using Markov chain Monte Carlo to quantify parameter uncertainty and its effect on predictions of a groundwater flow model
Environ. Model. Software
(2009) - et al.
A comparison of seven methods for the inverse modelling of groundwater flow. Application to the characterisation of well catchments
Adv. Water Resour.
(2009) - et al.
Geostatistical electrical resistivity tomography using random mixing
J. Appl. Geophys.
(2020) - et al.
Computational efficient inverse groundwater modeling using random mixing and whittaker–shannon interpolation
Adv. Water Resour.
(2019) - et al.
A local–global pattern matching method for subsurface stochastic inverse modeling
Environ. Model. Software
(2015) - et al.
Software framework for inverse modeling and uncertainty characterization
Environ. Model. Software
(2015) - et al.
Three-dimensional analysis of variably saturated flow and solute transport in discretely-fractured porous media
J. Contam. Hydrol.
(1996) - et al.
Operational convective-scale numerical weather prediction with the cosmo model: description and sensitivities
Mon. Weather Rev.
(2011) - et al.
Gaussian and non-Gaussian inverse modeling of groundwater flow using copulas and random mixing
Water Resour. Res.
(2016) - et al.
Random mixing: an approach to inverse modeling for groundwater flow and transport problems
Transport Porous Media
(2016)
Electrical resistivity tomography using a finite element based bfgs algorithm with algebraic multigrid preconditioning
Geophys. J. Int.
Bresenham's algorithm
The ensemble kalman filter: theoretical formulation and practical implementation
Ocean Dynam.
Stochastic reconstruction of spatio-temporal rainfall patterns by inverse hydrologic modelling
Hydrol. Earth Syst. Sci.
Stochastic reconstruction and interpolation of precipitation fields using combined information of commercial microwave links and rain gauges
Water Resour. Res.
Modflow-2005, the u.S. Geological Survey Modular Ground-Water Model – the Ground-Water Flow Process: U.S. Geological Survey Techniques and Methods 6-a16
Modflow-2005 Version 1.12.00, the u.S. Geological Survey Modular Groundwater Model: U.S. Geological Survey Software Release
Coupled inverse modelling of groundwater flow and mass transport and the worth of concentration data
J. Hydrol.
Process-oriented Modeling of Spatial Random Fields Using Copulas
Cited by (7)
Full waveform inversion using Random Mixing
2022, Computers and GeosciencesCitation Excerpt :In the second part, a brief overview of the Random Mixing approach for FWI is presented. For a more detailed description of the RM algorithm and its theoretical foundation, the interested reader is referred to Hörning and Haese (2021) and the references therein. Due to the periodic features of the linear combination, RM guarantees a monotonic decrease of the objective function.
An automatic geological 3D cross-section generator: Geopropy, an open-source library
2022, Environmental Modelling and SoftwareCitation Excerpt :The rapid development of artificial intelligence and machine learning libraries (e.g., TensorFlow (Abadi et al.), Scikit-learn (Pedregosa et al., 2011), Pytorch (Paszke et al., 2019), Pymc (Salvatier et al., 2016)) suggests a potential for expandability in geological modelling software. However, some existing computer programs are limited in this matter (e.g., EarthVision (Dynamic Graphics, 2009), RockWorks, Strater (Golden Software, 2021)), and the developments are mostly focused on reservoir properties (Chai et al., 2021; Chaikine and Gates, 2021; Idrees et al., 2021) or environmental modelling (Criollo et al., 2019; Hörning and Haese, 2021; Volk and Turner, 2019; White et al., 2021). Developing open-source software programs based on widely used programming languages brings the possibility of i) understanding and replicating the undertaken procedures, ii) customizing the code for further analysis or different purposes in case of need and iii) dynamically improving the software by implementing the latest version of machine learning and decision-making methods that have already been developed by third parties (Heron et al., 2013).
Conditional simulation of spatial rainfall fields using random mixing: A study that implements full control over the stochastic process
2021, Hydrology and Earth System Sciences
- 1
Main author. Provided most of the paper and source code.
- 2
Contributed section 3.3 and provided the data used.