Skip to content

Commit 7c38e72

Browse files
authored
Merge pull request #305 from MiraGeoscience/GEOPY-2565
GEOPY-2565: Air cells not taken into account for rotation angle models
2 parents 727e2d4 + 710de1b commit 7c38e72

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

simpeg_drivers/components/models.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -637,10 +637,9 @@ def _get_value(self, model: float | NumericData) -> np.ndarray:
637637
if isinstance(model, NumericData):
638638
model = self.obj_2_mesh(model, self.driver.inversion_mesh.entity)
639639
model = (self.driver.inversion_mesh.permutation @ model).astype(model.dtype)
640-
else:
640+
elif isinstance(model, int | float):
641641
nc = self.driver.inversion_mesh.mesh.n_cells
642-
if isinstance(model, int | float):
643-
model *= np.ones(nc)
642+
model *= np.ones(nc)
644643

645644
return model
646645

simpeg_drivers/options.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import numpy as np
1919
from geoapps_utils.base import Options
20+
from geoapps_utils.utils.numerical import weighted_average
2021
from geoh5py.data import (
2122
BooleanData,
2223
DataAssociationEnum,
@@ -29,7 +30,6 @@
2930
from geoh5py.objects import DrapeModel, Grid2D, Octree, Points
3031
from geoh5py.objects.surveys.electromagnetics.base import BaseEMSurvey
3132
from geoh5py.ui_json import InputFile
32-
from geoh5py.ui_json.utils import fetch_active_workspace
3333
from pydantic import (
3434
AliasChoices,
3535
BaseModel,
@@ -285,6 +285,8 @@ class ModelOptions(BaseModel):
285285
y_norm: float | FloatData | None = 2.0
286286
z_norm: float | FloatData = 2.0
287287

288+
_gradient_orientations: np.ndarray | None = None
289+
288290
@property
289291
def gradient_direction(self) -> np.ndarray:
290292
if self.gradient_orientations is None:
@@ -306,12 +308,20 @@ def gradient_orientations(self) -> tuple(float, float):
306308
and clockwise from horizontal for dip.
307309
"""
308310

309-
if self.gradient_rotation is not None:
311+
if self._gradient_orientations is None and self.gradient_rotation is not None:
310312
orientations = direction_and_dip(self.gradient_rotation)
311313

312-
return np.deg2rad(orientations)
314+
angles = np.deg2rad(orientations)
315+
# Deal with aircells here
316+
orientations = weighted_average(
317+
self.gradient_rotation.parent.centroids,
318+
self.gradient_rotation.parent.centroids,
319+
[angles[:, 0], angles[:, 1]],
320+
)
321+
322+
self._gradient_orientations = np.vstack(orientations).T
313323

314-
return None
324+
return self._gradient_orientations
315325

316326

317327
class ConductivityModelOptions(ModelOptions):

0 commit comments

Comments
 (0)