-
Notifications
You must be signed in to change notification settings - Fork 0
Conditional random fields #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
bramvandeneijnden
wants to merge
13
commits into
main
Choose a base branch
from
CPT_conditioning
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
8015988
added first version of conditioned random field generator
bramvandeneijnden dfe8826
corrections, clean-up, efficiency and commenting
bramvandeneijnden 7e2ddfa
Added tutorial:
bramvandeneijnden b9324d8
Extension of tutorial to 3D conditioned random fields
bramvandeneijnden 6b54e89
added sklearn to the requirements
bramvandeneijnden 78643d3
deleted: random_fields/generate_conditioned_field.py
bramvandeneijnden 5fadc51
modified: setup.cfg
bramvandeneijnden 04170dd
modified: setup.cfg (sklearn --> scikit-learn)
bramvandeneijnden 3b9df07
Update docs/installation.rst
bramvandeneijnden 72e157b
Update random_fields/generate_field.py
bramvandeneijnden 0712869
Changes for merge `Conditional random fields`
bramvandeneijnden b60343d
changes accounting for review comments:
bramvandeneijnden f76e0f0
modified: requirements.txt
bramvandeneijnden File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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>`_ | ||
|
|
||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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/", | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| Sphinx==6.2.1 | ||
| sphinx-rtd-theme==1.2.2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
|
|
||
| .. _theory: | ||
|
|
||
| Theory | ||
| ====== | ||
|
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.