1717
1818import numpy as np
1919from geoapps_utils .base import Options
20+ from geoapps_utils .utils .numerical import weighted_average
2021from geoh5py .data import (
2122 BooleanData ,
2223 DataAssociationEnum ,
2930from geoh5py .objects import DrapeModel , Grid2D , Octree , Points
3031from geoh5py .objects .surveys .electromagnetics .base import BaseEMSurvey
3132from geoh5py .ui_json import InputFile
32- from geoh5py .ui_json .utils import fetch_active_workspace
3333from 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
317327class ConductivityModelOptions (ModelOptions ):
0 commit comments