Conditional random fields - #3
Conversation
new file: random_fields/generate_conditioned_field.py
modified: random_fields/generate_conditioned_field.py
Changes to be committed: modified: ../README.md new file: Makefile renamed: static/random_field.png -> _static/random_field.png new file: _static/random_field_1.png new file: _static/random_field_2.png new file: _static/random_field_3.png renamed: static/random_field_3D.png -> _static/random_field_3D.png new file: authors.rst new file: conf.py new file: contributions.rst new file: index.rst new file: installation.rst new file: make.bat new file: requirements.txt new file: theory.rst new file: tutorials.rst modified: ../random_fields/generate_conditioned_field.py modified: ../random_fields/generate_field.py modified: ../random_fields/utils.py
Changes committed: new file: _static/conditioned_random_field_3D.png new file: _static/kriging_mean_2D.png new file: _static/kriging_mean_3D.png new file: _static/kriging_std_2D.png new file: _static/kriging_std_3D.png new file: _static/random_field_4.png new file: _static/random_field_5.png modified: index.rst modified: tutorials.rst modified: ../random_fields/utils.py
Changes to be committed: modified: tutorials.rst modified: ../requirements.txt
aronnoordam
left a comment
There was a problem hiding this comment.
few comments about style and some stuff what is unclear for me.
Furthermore can you add tests for the added functionalities?
| def create_solver_settings_dictionary(self, model: Model, mesh_file_name: str, materials_file_name: str) -> Dict[str, Any]: | ||
| """ | ||
| Creates a dictionary containing the solver settings. | ||
|
|
||
| Args: | ||
| - model (:class:`random_fields.model.Model`): The model object containing the solver data and model parts. | ||
| - mesh_file_name (str): The name of the mesh file. | ||
| - materials_file_name (str): The name of the materials parameters json file. | ||
|
|
||
| Raises: | ||
| - ValueError: if solver_settings in model are not initialised. | ||
|
|
||
| Returns: | ||
| - Dict[str, Any]: dictionary containing the part of the project parameters | ||
| dictionary related to problem data and solver settings. | ||
| """ | ||
|
|
||
| if model.project_parameters is None: | ||
| raise ValueError("Solver settings are not initialised in model.") | ||
|
|
||
| return self.solver_io.create_settings_dictionary( | ||
| model.project_parameters, | ||
| Path(mesh_file_name).stem, | ||
| materials_file_name, | ||
| model.get_all_model_parts(), |
There was a problem hiding this comment.
this function and the class above do not exists within the RF repos, can you replace it with an existing function?
There was a problem hiding this comment.
updated with existing function
| numpy==1.24.2 | ||
| gstools==1.5.0 | ||
| matplotlib>=3.7.0 | ||
| sklearn |
There was a problem hiding this comment.
missing version, also sklearn is deprecated, i think it should be scikit-learn
There was a problem hiding this comment.
also the dependency should be added to requirements_dev.txt
There was a problem hiding this comment.
scikit-learn corrected ==1.5.1
I tried to set matplotlib version to the one used in the STEM package (3.7.4), but this breaks one of the tests on the plotting utils...
| self.kriging_std = None | ||
|
|
||
|
|
||
| def generate_conditioned(self, nodes: np.ndarray) -> None: |
There was a problem hiding this comment.
| def generate_conditioned(self, nodes: np.ndarray) -> None: | |
| def generate_conditioned(self, nodes: npt.NDArray[np.float64]) -> None: |
There was a problem hiding this comment.
corrected, but hot to properly document arrays in the docstrings? see my attempt in the docstrings
| self.kriging_mean = self.mean + np.sqrt(self.variance) * z_kriged_field | ||
| # | ||
| # create single random field at nodes and conditioning points | ||
| nodes_cpoints = np.vstack([nodes,self.conditioning_points]) |
There was a problem hiding this comment.
can you write out the variable names a bit more, e.g. nodes_cond_points. Also for example z_cond_rf_nodes instead of z_crf_nodes. This makes the code a bit more understandable
Co-authored-by: aronnoordam <51492202+aronnoordam@users.noreply.github.com>
Co-authored-by: aronnoordam <51492202+aronnoordam@users.noreply.github.com>
modified: docs/contributions.rst modified: docs/installation.rst modified: random_fields/generate_field.py modified: random_fields/utils.py modified: requirements_dev.txt new file: tests/data/kriging_mean_3D.txt new file: tests/data/kriging_std_3D.txt modified: tests/test_random_field.py
- style changes
- update docstrings
- extended test
modified: docs/contributions.rst
modified: random_fields/generate_field.py
modified: random_fields/utils.py
modified: requirements.txt
modified: requirements_dev.txt
new file: tests/data/conditioned_rf_3D.txt
deleted: tests/data/kriging_mean_3D.txt
deleted: tests/data/kriging_std_3D.txt
modified: tests/test_random_field.py
modified: requirements_dev.txt
| - z_kriged_field (array): standard-normal kriged random field | ||
| - gaussian_process (:class:sklearn.gaussian_process.GaussianProcessRegressor) | ||
| - conditioning_points (array): coordinates of the conditioning points, shape (:,`self.n_dims`) | ||
| - conditioning_values (array): values of the conditioning points, shape (:,) |
There was a problem hiding this comment.
How to document arrays in the doc strings? I've seen "Sequence(float)" here and there...
and what about shapes and defaults?
extension of random field generator with random field conditioning.
Uses
sklearas additional requirement for efficient kriging, which is not available efficiently enough in gstools.