Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
8015988
added first version of conditioned random field generator
bramvandeneijnden Jun 13, 2024
dfe8826
corrections, clean-up, efficiency and commenting
bramvandeneijnden Jun 14, 2024
7e2ddfa
Added tutorial:
bramvandeneijnden Jun 28, 2024
b9324d8
Extension of tutorial to 3D conditioned random fields
bramvandeneijnden Jun 28, 2024
6b54e89
added sklearn to the requirements
bramvandeneijnden Jun 28, 2024
78643d3
deleted: random_fields/generate_conditioned_field.py
bramvandeneijnden Jun 28, 2024
5fadc51
modified: setup.cfg
bramvandeneijnden Jun 28, 2024
04170dd
modified: setup.cfg (sklearn --> scikit-learn)
bramvandeneijnden Jun 28, 2024
3b9df07
Update docs/installation.rst
bramvandeneijnden Aug 15, 2024
72e157b
Update random_fields/generate_field.py
bramvandeneijnden Aug 15, 2024
0712869
Changes for merge `Conditional random fields`
bramvandeneijnden Aug 20, 2024
b60343d
changes accounting for review comments:
bramvandeneijnden Aug 23, 2024
f76e0f0
modified: requirements.txt
bramvandeneijnden Aug 23, 2024
fadddba
Introduction of geostatistical interpretation of CPTs
bramvandeneijnden Oct 24, 2024
ecfd3e4
TODO: update dependencies...
bramvandeneijnden Oct 24, 2024
837f49b
added function to export conditioning data for visualisation
bramvandeneijnden Oct 25, 2024
0ccabe9
modified: random_fields/geostatistical_cpt_interpretation.py
bramvandeneijnden Oct 25, 2024
29e0d37
Several minor changes and fixes
bramvandeneijnden Dec 4, 2024
ae546bb
added dependencies scikit-learn and d-geolib-plus
bramvandeneijnden Dec 4, 2024
5bc2477
minor fix
bramvandeneijnden Dec 4, 2024
59eebfc
set numpy version from ==1.24 to >= 1.24
bramvandeneijnden Dec 4, 2024
5a1b431
updated docstrings and cleanup
bramvandeneijnden Dec 6, 2024
13f246a
scipy requirements weakened
bramvandeneijnden Dec 6, 2024
be3acd2
Update geostatistical_cpt_interpretation.py
bramvandeneijnden Dec 10, 2024
d1a77a0
updated authors.rst
brunozc Jan 7, 2025
ec7bc72
Correct GitHub username casing in documentation configuration
brunozc Jan 7, 2025
bb76a5c
Update dependency versions in requirements and setup configuration
brunozc Jan 9, 2025
6ac10e0
Add configuration files for flake8, mypy, and pre-commit; update CPTt…
brunozc Jan 9, 2025
72105fc
updated documentation
brunozc Jan 10, 2025
860e7ee
style fixed
brunozc Jan 10, 2025
98f6940
WIP
brunozc Jan 10, 2025
21da906
Sort file list in CPT directory and update default seed value for geo…
brunozc Jan 13, 2025
47d5c2b
Update dependencies and enhance documentation for CPT-based random fi…
brunozc Jan 13, 2025
da38c12
Fix package naming for d-geolib-plus in requirements files
brunozc Jan 13, 2025
93dd70c
Add unit tests for conditional 2D random field generation using GEF a…
brunozc Jan 13, 2025
cc45031
Downgrade scipy version to 1.13.1 in requirements files
brunozc Jan 13, 2025
f19560f
Refactor code for improved readability and maintainability in random …
brunozc Jan 13, 2025
c94a6d3
fixed test for linux
brunozc Jan 14, 2025
ea2eb6a
Fix file path for 3D random field test on Windows and remove skip marker
brunozc Jan 14, 2025
6d04569
Add Read the Docs configuration file for documentation build
brunozc Jan 14, 2025
6439e69
Enhance plotting functions to support conditional points and customiz…
brunozc Jan 14, 2025
268d135
fixed style
brunozc Jan 14, 2025
e224365
Update 3D random field test to use pickle format and change output fi…
brunozc Jan 14, 2025
290abe0
Rename "STEM team" to "Random Fields team" in documentation and corre…
brunozc Jan 14, 2025
60b7837
Update tutorial to reflect 2D/3D conditioned Random Field on CPT data
brunozc Jan 14, 2025
ecc4d98
Update tutorial heading to use "and" for clarity in 2D and 3D conditi…
brunozc Jan 14, 2025
2833dbc
fixed bug in test
brunozc Jan 14, 2025
c4a686f
Update output file format in 3D random field test from PNG to EPS
brunozc Jan 14, 2025
50b54ca
Add tests for ElasticityFieldsFromCpt and RandomFieldProperties
brunozc Jan 14, 2025
963cf01
Refactor assertions in 3D conditioned random field test to use np.tes…
brunozc Jan 14, 2025
e7247be
Increase precision of assertions in 3D conditioned random field test …
brunozc Jan 14, 2025
caa7cd6
Update GitHub Actions workflow to allow manual triggering and broaden…
brunozc Jan 14, 2025
8d5e1d3
Fix formatting in tutorial_4.rst by adding missing newlines for bette…
brunozc Jan 14, 2025
69fe1a3
Improve mathematical notation in tutorial_4.rst for clarity and consi…
brunozc Jan 14, 2025
1f6152a
Refactor ElasticityFieldsFromCpt class to improve variable naming and…
brunozc Jan 14, 2025
580569b
Update docs/tutorial_4.rst
brunozc Jan 15, 2025
1753666
Update docs/conf.py
brunozc Jan 15, 2025
829600e
Update docs/tutorial_4.rst
brunozc Jan 15, 2025
1461715
Update random_fields/generate_field.py
brunozc Jan 15, 2025
cc0faad
Update random_fields/generate_field.py
brunozc Jan 15, 2025
9d1dc3d
Enhance calibration method to accept three boolean indices and add va…
brunozc Jan 16, 2025
83cbce7
Merge branch 'main' into CPT_conditioning_continued
brunozc Feb 20, 2025
33b2815
update: refine dependencies and remove redundant entries in setup.cfg
brunozc Feb 20, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[flake8]
ignore = F403, F405, W503, W504
max-line-length = 120
per-file-ignores = __init__.py:F401
7 changes: 4 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ name: Tests

# Controls when the workflow will run
on:
push:
branches: [ "**" ]
pull_request:
branches: [ "main" ]
branches: [ "**" ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
test:
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ pytest_cache/*
build/*
random_fields.egg-info/*
.coverage
.tox/*
.tox/*
docs/build/*
21 changes: 21 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
repos:
- repo: local
hooks:
- id: yapf
name: yapf
language: python
entry: yapf
args: [-i]
types: [python]
- id: mypy
name: mypy
language: python
entry: mypy
files: "^random_fields/"
args: [ --config-file, "pyproject.toml" ]
types: [python]
- id: flake8
name: flake8
language: python
entry: flake8
files: "^random_fields/"
28 changes: 28 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Set the OS, Python version, and other tools you might need
build:
os: ubuntu-22.04
tools:
python: "3.11"
jobs:
pre_build:
- sphinx-apidoc -o docs ./random_fields
- pip install .

# Build documentation in the "docs/" directory with Sphinx
sphinx:
configuration: docs/conf.py

# Optionally, but recommended,
# declare the Python requirements required to build your documentation
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
python:
install:
- requirements: docs/requirements.txt


12 changes: 12 additions & 0 deletions .style.yapf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[style]
based_on_style = pep8
SPLIT_ALL_TOP_LEVEL_COMMA_SEPARATED_VALUES = False
dedent_closing_brackets = False
EACH_DICT_ENTRY_ON_SEPARATE_LINE = True
FORCE_MULTILINE_DICT = False
coalesce_brackets = True
column_limit = 120
split_arguments_when_comma_terminated = True
SPLIT_BEFORE_FIRST_ARGUMENT = False
#SPLIT_PENALTY_FOR_ADDED_LINE_SPLIT = 1
ALLOW_SPLIT_BEFORE_DICT_VALUE = False
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ plot2D([np.array([x.ravel(), y.ravel()]).T], [rf.random_field], title="Random Fi

The result is the following random field:

![Random field 2D](./docs/static/random_field.png)
![Random field 2D](./docs/_static/random_field.png)

## Example in 3D

Expand Down Expand Up @@ -127,4 +127,4 @@ plot3D([np.array([x.ravel(), y.ravel(), z.ravel()]).T], [rf.random_field], title
```
The result is the following random field:

![Random field 3D](./docs/static/random_field_3D.png)
![Random field 3D](./docs/_static/random_field_3D.png)
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
Binary file added docs/_static/2D_cpt_conditioned_field.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/conditioned_random_field_3D.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/coordinates_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/coordinates_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/kriging_mean_2D.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/kriging_mean_3D.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/kriging_std_2D.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/kriging_std_3D.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/marginal_distribution.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file added docs/_static/random_field_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/random_field_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/random_field_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file added docs/_static/random_field_3d_young.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/random_field_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/random_field_5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions docs/authors.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.. _authors:

Random Fields team
==================

Maintainers
-----------
- Bruno Zuada Coelho <bruno.zuadacoelho@deltares.nl> `@brunozc <https://github.com/brunozc>`_
- Aron Noordam <aron.noordam@deltares.nl> `@aronnoordam <https://github.com/aronnoordam>`_

Developers
----------
- Bram van den Eijnden <bram.vandneeijnden@deltares.nl> `@bramvandeneijnden <https://github.com/bramvandeneijnden>`_
- Davide Moretti <davide.moretti@tno.nl> `@morettid <https://github.com/morettid>`_
60 changes: 60 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

import random_fields

project = 'RandomFields'
copyright = '2024, STEM team'

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
copyright = '2024, STEM team'
copyright = '2025, STEM team'

author = 'STEM team'
version = random_fields.__version__

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

extensions = ['sphinx.ext.autodoc', 'sphinx_rtd_theme', 'sphinx.ext.intersphinx']

templates_path = ['_templates']
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']

# to add __init__ documentation to the build
autoclass_content = 'both'

# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = 'sphinx_rtd_theme'
html_static_path = ['_static']

# # Configure the RTD theme options
html_theme_options = {
'logo_only': False,
'display_version': True,
'prev_next_buttons_location': 'bottom',
'style_external_links': True, # Toc options
'collapse_navigation': False,
'sticky_navigation': True,
'navigation_depth': 2,
'includehidden': True,
'titles_only': True,
}

# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
html_show_sphinx = False
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
html_show_copyright = True
# If true shows the source link to the rst code
html_show_sourcelink = False

# Link to the github
html_context = {
"display_github": True,
"github_user": "StemVibrations",
"github_repo": "RandomFields",
"github_version": "main",
"conf_py_path": "/docs/",
}
111 changes: 111 additions & 0 deletions docs/contributions.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
Code contribution
=================

Steps for submitting your code
------------------------------

When contributing code follow this checklist:

#. Fork the repository on GitHub.
#. Create an issue with the desired feature or bug fix.
#. Make your modifications or additions in a feature branch.
#. Make changes and commit your changes using a descriptive commit message.
#. Provide tests for your changes, and ensure they all pass.
#. Provide documentation for your changes, in accordance with the style of the rest of the project (see :ref:`style_guide`).
#. Create a pull request to RandomFields main branch. The STEM team will review and discuss your Pull Request with you.

For any questions, please get in contact with one of the members of :doc:`authors`.


.. _style_guide:

Code style guide
----------------
The additional features should follow the style of the RandomFields project.

We follow the PEP 8 style guide for Python code, with our custom modifications as defined in the
`Yapf file <../../.style.yapf>`_ and the `flake8 file <../../.flake8>`_. These files can be ran manually by using the
following command from the root directory of the project:

.. code-block::

pre-commit run --all-files


The class or function name should be clear and descriptive of the functionality it provides.

There should be a docstring at the beginning of the class or function describing its purpose and usage.
The docstring should be in the form of a triple-quoted string.

The class or function must have a type annotation.
The class should specify the attributes and inheritance.
The function should specify the arguments, exceptions and returns (in this order).
The return type annotation should be in the form of a comment after the closing parenthesis of the arguments.

Please, avoid inheritance, and favour composition when writing your code.

An example of a class:

.. code-block::

class ClassName(object):
"""
Work in progress: docstring style to be specified

Inheritance:
-:class:`object`

Attributes:
- <attribute_name_1> (<attribute type>): <attribute description>,shape (n,m)
- <attribute_name_2> (<attribute type>): <attribute description>,shape (m,)


"""
def __init__(self,<args>,...):
"""
Constructor of the RandomFields class

Args:
- <arg>: (<type>) <description>, shape (n,m,), default
"""
self.attribute_name_1: <attribute_type> = <value>
self.attribute_name_2: <attribute_type> = <value>


An example of a function:

.. code-block::

def generate(self, nodes: npt.NDArray[np.float64]) -> None:
"""
Generate random field

Args:
- nodes (ndarray): The nodes of the random field. shape (:,`self.n_dim`)

Raises:
- ValueError: if dimensions of `nodes` do not match dimensions of the model

Returns:

"""

# check dimensions of nodes agrees with dimensions of model
if nodes.shape[1] != self.n_dim:
raise ValueError(f'Dimensions of nodes: {nodes.shape[1]} do not match dimensions of model: {self.n_dim}')

# scale of fluctuation
scale_fluctuation = np.ones(self.n_dim) * self.vertical_scale_fluctuation

# apply the anisotropy to the other dimensions
mask = np.arange(len(scale_fluctuation)) != self.v_dim
scale_fluctuation[mask] = scale_fluctuation[mask] * self.anisotropy

model = self.random_field_model(dim = self.n_dim,
var = self.variance,
len_scale = scale_fluctuation,
angles = self.angle)
self.random_field = gs.SRF(model,
mean = self.mean,
seed = self.seed)
self.random_field(nodes.T)
60 changes: 60 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
RandomFields
====
Python package to generate random fields in 2D or 3D on unstructured grids.


User guide
==========

Background information
......................
The random fields are generated using `gstools <https://geostat-framework.readthedocs.io/en/latest/>`_.

Currently, the following covariance models are available:

* Gaussian
* Exponential
* Matern
* Linear (not for conditioned random fields)

Additional functionalities are used to generate conditioned random fields.


Tutorials
.........

* :ref:`tutorial1`
1D unconditioned and conditioned random field generation.

* :ref:`tutorial2`
2D unconditioned and conditioned random field simulation.

* :ref:`tutorial3`
3D unconditioned and conditioned random field simulation.

* :ref:`tutorial4`
Non-normal Gaussian fields and conditioning based on CPT data.


How to contribute
=================
If you want to contribute to RandomFields please follow the steps defined in :doc:`contributions`.


Random Fields team
==================
The Random Field package is part of the STEM is a research programme that results from a
collaboration between the following partners:

* `ProRail <https://www.prorail.nl>`_
* `Deltares <https://www.deltares.nl>`_
* `TNO <https://www.tno.nl>`_
* `TU Delft <https://www.tudelft.nl>`_

The :doc:`authors`.


Package documentation
=====================

The :doc:`random_fields` documentation.
10 changes: 10 additions & 0 deletions docs/installation.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
RandomFields installation
=================

.. _python_random_fields:

RandomFields Python package
-------------------


To be copied from STEM
Loading