Commit c2568293 authored by Lukas Riedel's avatar Lukas Riedel

Add exponential converter to PFG module

* Add ExponentialConverter to module, with option to use it in
* Add option 'converter=exponential' to default PFG parameters
* Add section 'converter.exponential' with option 'varianceScaling'
    to default PFG parameters
parent 2afad121
......@@ -50,10 +50,12 @@ adding an empty line, make text **bold** or ``monospaced``.
<parameter name="converter">
<definition> Identifier of the random field converter. The converter is
applied after the random field is created and modifies it.
Use ``exponential`` for creating a suitable Miller scaling field.
<values> none, binary </values>
<values> none, binary, exponential </values>
<suggestion> binary </suggestion>
<comment> none, binary </comment>
<comment> none, binary, exponential </comment>
<parameter name="tempDir">
......@@ -136,4 +138,17 @@ adding an empty line, make text **bold** or ``monospaced``.
<suggestion> 0 1 </suggestion>
<category name="converter.exponential">
<parameter name="varianceScaling">
<definition> Substract the variance from the random field values before
applying the exponential. For a random field with ``gaussian``
covariance, this will result in a conductivity field with the same
macroscopic properties that a homogeneous field, in the sense that
average water flux is the same (Roth 1995).
<values> bool </values>
<suggestion> true </suggestion>
from dorie.parfield.converter.base import BaseConverter
from dorie.parfield.converter.binary import BinaryConverter
from dorie.parfield.converter.exponential import ExponentialConverter
......@@ -31,4 +31,4 @@ class BinaryConverter(BaseConverter):
self._dataset = np.where(self._random_field > 0,
\ No newline at end of file
import numpy as np
from dorie.parfield.converter import BaseConverter
from dorie.utilities.text_to_bool import text_to_bool
class ExponentialConverter(BaseConverter):
"""Convert the random field by applying the natural exponential function.
This converter takes values from a floating-point valued random field
and applies the natural exponential function to it. If the original
values follow a normal distribution, the resulting values will follow a
log-normal distribution.
def __init__(self, param, input_file):
super(ExponentialConverter, self).__init__(param, input_file)
def _create_dataset(self):
"""Create the dataset which will be written into the target file.
Apply ``exp`` to all values.
Optionally, the field can be adjusted by the random field variance.
If the resulting field is applied as Miller scaling field, and the
original field was normally distributed, the resulting field will have
the same macroscopic properties as an unscaled field, in the sense
that average water flux is the same (Roth 1995).
if self._random_field is None:
raise RuntimeError("Error reading the random field!")
scale = text_to_bool(self._read_parameter("converter.exponential",
if scale:
variance = float(self._read_parameter("stochastic", "variance"))
variance = 0.0
self._dataset = np.exp(self._random_field - variance)
......@@ -10,7 +10,9 @@ import subprocess
import multiprocessing
import configparser
from dorie.parfield.converter import BaseConverter, BinaryConverter
from dorie.parfield.converter import BaseConverter,
Script invoking random field generaor and converter.
......@@ -79,6 +81,8 @@ if __name__ == "__main__":
BaseConverter(args["param"], input_file=input_file)
elif conv == "binary":
BinaryConverter(args["param"], input_file=input_file)
elif conv == "exponential":
ExponentialConverter(args["param"], input_file=input_file)
raise RuntimeError("Unrecognized converter {}".format(conv))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment