Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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: 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/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/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.
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_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.
19 changes: 19 additions & 0 deletions docs/authors.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.. _authors:

STEM 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
----------
- Marjan Fathian <marjan.fathian@deltares.nl> `@indigocoral <https://github.com/indigocoral>`_
- Jonathan Nuttall <jonathan.nuttall@deltares.nl> `@mcgicjn2 <https://github.com/mcgicjn2>`_
- Davide Moretti <davide.moretti@tno.nl> `@morettid <https://github.com/morettid>`_
- Jelme Pennings <jelme.pennings@tno.nl> `@jkpennings <https://github.com/jkpennings>`_
- Bram van den Eijnden <bram.vandneeijnden@deltares.nl> `@bramvandeneijnden <https://github.com/bramvandeneijnden>`_


62 changes: 62 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# 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'
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": "RanndomFields",
"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 STEM 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 STEM 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)
54 changes: 54 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
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 functoinalities are used to generate conditioned random fields. See :doc:`theory` for details.


Tutorials
.........

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

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

* :ref:`tutorial3`
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`.


STEM team
=========
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
Comment thread
bramvandeneijnden marked this conversation as resolved.
35 changes: 35 additions & 0 deletions docs/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=.
set BUILDDIR=_build

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.https://www.sphinx-doc.org/
exit /b 1
)

if "%1" == "" goto help

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
2 changes: 2 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Sphinx==6.2.1
sphinx-rtd-theme==1.2.2
6 changes: 6 additions & 0 deletions docs/theory.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

.. _theory:

Theory
======

Loading