Skip to content

Commit

Permalink
fix: ✨ adding ability to calculate normalised value of a feature
Browse files Browse the repository at this point in the history
this just makes it easier to scale scalar field between 0 and 1
  • Loading branch information
lachlangrose committed Dec 19, 2023
1 parent 99f60d2 commit 0682765
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions LoopStructural/modelling/features/_base_geological_feature.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from LoopStructural.modelling.features import FeatureType
from LoopStructural.utils import getLogger
from LoopStructural.utils.typing import NumericInput

# from LoopStructural import GeologicalModel
import numpy as np
Expand Down Expand Up @@ -39,6 +40,8 @@ def __init__(
self._model = model
self.builder = builder
self.faults_enabled = True
self._min = None
self._max = None

def __str__(self):
_str = "-----------------------------------------------------\n"
Expand Down Expand Up @@ -125,6 +128,17 @@ def evaluate_value(self, pos):
"""
raise NotImplementedError

def evaluate_normalised_value(self, pos: NumericInput):
"""Evaluate the feature value scaling between 0 and 1
Parameters
----------
pos : NumericInput
An array or arraylike object with locations
"""
value = self.evaluate_value(pos)
return (value - self.min()) / (self.max() - self.min())

def _calculate_mask(self, evaluation_points: np.ndarray) -> np.ndarray:
"""Calculate the mask for which evaluation points need to be calculated
Expand Down Expand Up @@ -183,6 +197,7 @@ def min(self):
"""
if self.model is None:
return 0

return np.nanmin(self.evaluate_value(self.model.regular_grid((10, 10, 10))))

def max(self):
Expand Down

0 comments on commit 0682765

Please sign in to comment.