├── requirements.txt ├── results └── simulations.png ├── data └── conditions.txt ├── LICENSE ├── src └── 00_condition_ensemble.py ├── README.md ├── .gitignore └── spec-file.txt /requirements.txt: -------------------------------------------------------------------------------- 1 | gstools==1.2.1 2 | matplotlib 3 | -------------------------------------------------------------------------------- /results/simulations.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GeoStat-Examples/template/master/results/simulations.png -------------------------------------------------------------------------------- /data/conditions.txt: -------------------------------------------------------------------------------- 1 | # 1.row: condition positions 2 | # 2.row: condition values 3 | 2.999999999999999889e-01 1.899999999999999911e+00 1.100000000000000089e+00 3.299999999999999822e+00 4.700000000000000178e+00 4 | 4.699999999999999734e-01 5.600000000000000533e-01 7.399999999999999911e-01 1.469999999999999973e+00 1.739999999999999991e+00 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 GeoStat-Examples 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/00_condition_ensemble.py: -------------------------------------------------------------------------------- 1 | """ 2 | Example: Conditioning with Ordinary Kriging 3 | ------------------------------------------- 4 | 5 | Here we use ordinary kriging in 1D (for plotting reasons) with 5 given observations/conditions, 6 | to generate an ensemble of conditioned random fields. 7 | The estimated mean can be accessed by ``srf.mean``. 8 | """ 9 | import numpy as np 10 | import matplotlib.pyplot as plt 11 | import gstools as gs 12 | 13 | # condtions 14 | cond = np.loadtxt("../data/conditions.txt") 15 | cond_pos = cond[0] 16 | cond_val = cond[1] 17 | gridx = np.linspace(0.0, 15.0, 151) 18 | 19 | ############################################################################### 20 | 21 | # spatial random field class 22 | model = gs.Gaussian(dim=1, var=0.5, len_scale=2) 23 | srf = gs.SRF(model) 24 | srf.set_condition(cond_pos, cond_val, "ordinary") 25 | 26 | ############################################################################### 27 | 28 | fields = [] 29 | for i in range(100): 30 | # print(i) if i % 10 == 0 else None 31 | fields.append(srf(gridx, seed=i)) 32 | label = "Conditioned ensemble" if i == 0 else None 33 | plt.plot(gridx, fields[i], color="k", alpha=0.1, label=label) 34 | plt.plot(gridx, np.full_like(gridx, srf.mean), label="estimated mean") 35 | plt.plot(gridx, np.mean(fields, axis=0), linestyle=":", label="Ensemble mean") 36 | plt.plot(gridx, srf.krige_field, linestyle="dashed", label="kriged field") 37 | plt.scatter(cond_pos, cond_val, color="k", zorder=10, label="Conditions") 38 | plt.legend() 39 | plt.show() 40 | plt.savefig("../results/simulations.png") 41 | 42 | ############################################################################### 43 | # As you can see, the kriging field coincides with the ensemble mean of the 44 | # conditioned random fields and the estimated mean is the mean of the far-field. 45 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![GS-Frame](https://img.shields.io/badge/github-GeoStat_Framework-468a88?logo=github&style=flat)](https://github.com/GeoStat-Framework) 2 | [![Gitter](https://badges.gitter.im/GeoStat-Examples/community.svg)](https://gitter.im/GeoStat-Examples/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) 3 | 4 | # Template 5 | 6 | This is a template for an example repository. 7 | 8 | You can create a new example by simply clicking on "Use this template". 9 | 10 | The included example is showing the generation of a conditioned random field ensemble 11 | in 1D taken from [GSTools](https://geostat-framework.readthedocs.io/projects/gstools/en/stable/examples/06_conditioned_fields/00_condition_ensemble.html#sphx-glr-examples-06-conditioned-fields-00-condition-ensemble-py). 12 | 13 | 14 | ## Structure 15 | 16 | Please try to organize your example in the given Structure 17 | - `data/` - here you should place your input data 18 | - `src/` - here you should place your python scripts 19 | - `results/` - here your computed results and plots should be stored 20 | - `README.md` - please describe your example in the readme, potentially showing results 21 | - `LICENSE` - the default license is MIT, you can use another one if wanted 22 | 23 | 24 | ## Python environment 25 | 26 | To make the example reproducible, it would be a good practice to provide one of 27 | the following files: 28 | - `requirements.txt` - requirements for [pip](https://pip.pypa.io/en/stable/user_guide/#requirements-files) to install all needed packages 29 | - `spec-file.txt` - specification file to create the original [conda environment](https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#building-identical-conda-environments) 30 | 31 | 32 | ## Workflow 33 | 34 | After finalizing your work, you should tag the repository with a version like `v1.0`. 35 | 36 | Then, a [Zenodo](https://zenodo.org/) release will be created, so you can cite the repository in you publication. 37 | 38 | Please keep your `master` branch in line with the latest release. 39 | For further development use the `develop` branch and update `master` with pull-requests. 40 | 41 | 42 | ## Contact 43 | 44 | You can contact us via . 45 | 46 | 47 | ## License 48 | 49 | MIT © 2020 50 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | pip-wheel-metadata/ 24 | share/python-wheels/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | MANIFEST 29 | 30 | # PyInstaller 31 | # Usually these files are written by a python script from a template 32 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 33 | *.manifest 34 | *.spec 35 | 36 | # Installer logs 37 | pip-log.txt 38 | pip-delete-this-directory.txt 39 | 40 | # Unit test / coverage reports 41 | htmlcov/ 42 | .tox/ 43 | .nox/ 44 | .coverage 45 | .coverage.* 46 | .cache 47 | nosetests.xml 48 | coverage.xml 49 | *.cover 50 | *.py,cover 51 | .hypothesis/ 52 | .pytest_cache/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | target/ 76 | 77 | # Jupyter Notebook 78 | .ipynb_checkpoints 79 | 80 | # IPython 81 | profile_default/ 82 | ipython_config.py 83 | 84 | # pyenv 85 | .python-version 86 | 87 | # pipenv 88 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 89 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 90 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 91 | # install all needed dependencies. 92 | #Pipfile.lock 93 | 94 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 95 | __pypackages__/ 96 | 97 | # Celery stuff 98 | celerybeat-schedule 99 | celerybeat.pid 100 | 101 | # SageMath parsed files 102 | *.sage.py 103 | 104 | # Environments 105 | .env 106 | .venv 107 | env/ 108 | venv/ 109 | ENV/ 110 | env.bak/ 111 | venv.bak/ 112 | 113 | # Spyder project settings 114 | .spyderproject 115 | .spyproject 116 | 117 | # Rope project settings 118 | .ropeproject 119 | 120 | # mkdocs documentation 121 | /site 122 | 123 | # mypy 124 | .mypy_cache/ 125 | .dmypy.json 126 | dmypy.json 127 | 128 | # Pyre type checker 129 | .pyre/ 130 | -------------------------------------------------------------------------------- /spec-file.txt: -------------------------------------------------------------------------------- 1 | # This file may be used to create an environment using: 2 | # $ conda create --name --file 3 | # platform: linux-64 4 | @EXPLICIT 5 | https://conda.anaconda.org/conda-forge/linux-64/_libgcc_mutex-0.1-conda_forge.tar.bz2 6 | https://conda.anaconda.org/conda-forge/linux-64/ca-certificates-2020.4.5.1-hecc5488_0.tar.bz2 7 | https://conda.anaconda.org/conda-forge/linux-64/ld_impl_linux-64-2.34-h53a641e_0.tar.bz2 8 | https://conda.anaconda.org/conda-forge/linux-64/libgfortran-ng-7.3.0-hdf63c60_5.tar.bz2 9 | https://conda.anaconda.org/conda-forge/linux-64/libstdcxx-ng-9.2.0-hdf63c60_2.tar.bz2 10 | https://conda.anaconda.org/conda-forge/linux-64/llvm-openmp-10.0.0-hc9558a2_0.tar.bz2 11 | https://conda.anaconda.org/conda-forge/linux-64/mpi-1.0-openmpi.tar.bz2 12 | https://conda.anaconda.org/conda-forge/linux-64/_openmp_mutex-4.5-1_llvm.tar.bz2 13 | https://conda.anaconda.org/conda-forge/linux-64/libgcc-ng-9.2.0-h24d8f2e_2.tar.bz2 14 | https://conda.anaconda.org/conda-forge/linux-64/expat-2.2.9-he1b5a44_2.tar.bz2 15 | https://conda.anaconda.org/conda-forge/linux-64/icu-64.2-he1b5a44_1.tar.bz2 16 | https://conda.anaconda.org/conda-forge/linux-64/jpeg-9c-h14c3975_1001.tar.bz2 17 | https://conda.anaconda.org/conda-forge/linux-64/libffi-3.2.1-he1b5a44_1007.tar.bz2 18 | https://conda.anaconda.org/conda-forge/linux-64/libiconv-1.15-h516909a_1006.tar.bz2 19 | https://conda.anaconda.org/conda-forge/linux-64/libopenblas-0.3.9-h5ec1e0e_0.tar.bz2 20 | https://conda.anaconda.org/conda-forge/linux-64/libuuid-2.32.1-h14c3975_1000.tar.bz2 21 | https://conda.anaconda.org/conda-forge/linux-64/libxkbcommon-0.10.0-he1b5a44_0.tar.bz2 22 | https://conda.anaconda.org/conda-forge/linux-64/ncurses-6.1-hf484d3e_1002.tar.bz2 23 | https://conda.anaconda.org/conda-forge/linux-64/nspr-4.25-he1b5a44_0.tar.bz2 24 | https://conda.anaconda.org/conda-forge/linux-64/openssl-1.1.1g-h516909a_0.tar.bz2 25 | https://conda.anaconda.org/conda-forge/linux-64/pcre-8.44-he1b5a44_0.tar.bz2 26 | https://conda.anaconda.org/conda-forge/linux-64/pthread-stubs-0.4-h14c3975_1001.tar.bz2 27 | https://conda.anaconda.org/conda-forge/linux-64/xorg-libxau-1.0.9-h14c3975_0.tar.bz2 28 | https://conda.anaconda.org/conda-forge/linux-64/xorg-libxdmcp-1.1.3-h516909a_0.tar.bz2 29 | https://conda.anaconda.org/conda-forge/linux-64/xz-5.2.5-h516909a_0.tar.bz2 30 | https://conda.anaconda.org/conda-forge/linux-64/zlib-1.2.11-h516909a_1006.tar.bz2 31 | https://conda.anaconda.org/conda-forge/linux-64/gettext-0.19.8.1-hc5be6a0_1002.tar.bz2 32 | https://conda.anaconda.org/conda-forge/linux-64/hdf5-1.10.5-nompi_h3c11f04_1104.tar.bz2 33 | https://conda.anaconda.org/conda-forge/linux-64/libblas-3.8.0-16_openblas.tar.bz2 34 | https://conda.anaconda.org/conda-forge/linux-64/libllvm9-9.0.1-he513fc3_1.tar.bz2 35 | https://conda.anaconda.org/conda-forge/linux-64/libpng-1.6.37-hed695b0_1.tar.bz2 36 | https://conda.anaconda.org/conda-forge/linux-64/libxcb-1.13-h14c3975_1002.tar.bz2 37 | https://conda.anaconda.org/conda-forge/linux-64/libxml2-2.9.10-hee79883_0.tar.bz2 38 | https://conda.anaconda.org/conda-forge/linux-64/openmpi-4.0.3-hdf1f1ad_1.tar.bz2 39 | https://conda.anaconda.org/conda-forge/linux-64/readline-8.0-hf8c457e_0.tar.bz2 40 | https://conda.anaconda.org/conda-forge/linux-64/tk-8.6.10-hed695b0_0.tar.bz2 41 | https://conda.anaconda.org/conda-forge/linux-64/freetype-2.10.1-he06d7ca_0.tar.bz2 42 | https://conda.anaconda.org/conda-forge/linux-64/libcblas-3.8.0-16_openblas.tar.bz2 43 | https://conda.anaconda.org/conda-forge/linux-64/libclang-9.0.1-default_hde54327_0.tar.bz2 44 | https://conda.anaconda.org/conda-forge/linux-64/liblapack-3.8.0-16_openblas.tar.bz2 45 | https://conda.anaconda.org/conda-forge/linux-64/sqlite-3.30.1-hcee41ef_0.tar.bz2 46 | https://conda.anaconda.org/conda-forge/linux-64/fontconfig-2.13.1-h86ecdb6_1001.tar.bz2 47 | https://conda.anaconda.org/conda-forge/linux-64/nss-3.47-he751ad9_0.tar.bz2 48 | https://conda.anaconda.org/conda-forge/linux-64/python-3.8.2-he5300dc_7_cpython.tar.bz2 49 | https://conda.anaconda.org/conda-forge/linux-64/glib-2.64.2-h6f030ca_0.tar.bz2 50 | https://conda.anaconda.org/conda-forge/noarch/mpmath-1.1.0-py_0.tar.bz2 51 | https://conda.anaconda.org/conda-forge/noarch/pyparsing-2.4.7-pyh9f0ad1d_0.tar.bz2 52 | https://conda.anaconda.org/conda-forge/linux-64/python_abi-3.8-1_cp38.tar.bz2 53 | https://conda.anaconda.org/conda-forge/noarch/six-1.14.0-py_1.tar.bz2 54 | https://conda.anaconda.org/conda-forge/noarch/tqdm-4.45.0-pyh9f0ad1d_1.tar.bz2 55 | https://conda.anaconda.org/conda-forge/linux-64/certifi-2020.4.5.1-py38h32f6830_0.tar.bz2 56 | https://conda.anaconda.org/conda-forge/noarch/cycler-0.10.0-py_2.tar.bz2 57 | https://conda.anaconda.org/conda-forge/linux-64/dbus-1.13.6-he372182_0.tar.bz2 58 | https://conda.anaconda.org/conda-forge/linux-64/gstreamer-1.14.5-h36ae1b5_2.tar.bz2 59 | https://conda.anaconda.org/conda-forge/linux-64/kiwisolver-1.2.0-py38hbf85e49_0.tar.bz2 60 | https://conda.anaconda.org/conda-forge/linux-64/mpi4py-3.0.3-py38h246a051_1.tar.bz2 61 | https://conda.anaconda.org/conda-forge/linux-64/numpy-1.18.1-py38h8854b6b_1.tar.bz2 62 | https://conda.anaconda.org/conda-forge/noarch/python-dateutil-2.8.1-py_0.tar.bz2 63 | https://conda.anaconda.org/conda-forge/linux-64/tornado-6.0.4-py38h1e0a361_1.tar.bz2 64 | https://conda.anaconda.org/conda-forge/linux-64/gst-plugins-base-1.14.5-h0935bb2_2.tar.bz2 65 | https://conda.anaconda.org/conda-forge/linux-64/h5py-2.10.0-nompi_py38h513d04c_102.tar.bz2 66 | https://conda.anaconda.org/conda-forge/noarch/pyevtk-1.1.2-pyh24bf2e0_0.tar.bz2 67 | https://conda.anaconda.org/conda-forge/linux-64/scipy-1.4.1-py38h18bccfc_3.tar.bz2 68 | https://conda.anaconda.org/conda-forge/linux-64/setuptools-46.1.3-py38h32f6830_0.tar.bz2 69 | https://conda.anaconda.org/conda-forge/noarch/hankel-1.0.2-py_0.tar.bz2 70 | https://conda.anaconda.org/conda-forge/linux-64/matplotlib-base-3.2.1-py38h2af1d28_0.tar.bz2 71 | https://conda.anaconda.org/conda-forge/linux-64/qt-5.12.5-hd8c4c69_1.tar.bz2 72 | https://conda.anaconda.org/conda-forge/linux-64/schwimmbad-0.3.1-py38h32f6830_0.tar.bz2 73 | https://conda.anaconda.org/conda-forge/noarch/wheel-0.34.2-py_1.tar.bz2 74 | https://conda.anaconda.org/conda-forge/noarch/emcee-3.0.2-pyh5ca1d4c_0.tar.bz2 75 | https://conda.anaconda.org/conda-forge/noarch/pip-20.1-pyh9f0ad1d_0.tar.bz2 76 | https://conda.anaconda.org/conda-forge/linux-64/pyqt-5.12.3-py38hcca6a23_1.tar.bz2 77 | https://conda.anaconda.org/conda-forge/linux-64/gstools-1.2.1-py38h950e882_0.tar.bz2 78 | https://conda.anaconda.org/conda-forge/linux-64/matplotlib-3.2.1-0.tar.bz2 79 | --------------------------------------------------------------------------------