Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
c3da038
Translate notebook into utilities
benk-mira Mar 25, 2025
17efc2d
support phi/theta/psi input
benk-mira Mar 25, 2025
1cd25d9
Running with property group for gradient dip/direction
benk-mira Mar 27, 2025
8a7249d
convert input dip/direction to radians
benk-mira Mar 27, 2025
4fe068b
Simplify rotations
benk-mira Mar 27, 2025
b422d9a
Fix type form for gradient_rotations in gravity/ui.json and add gradi…
benk-mira Mar 27, 2025
58694c6
Dom's comments
benk-mira Mar 28, 2025
d62ef56
fix strike and dip handling
benk-mira Mar 28, 2025
a9ae058
Add rotated_gradient subtest in gravity runtest
benk-mira Mar 28, 2025
79bfb77
Fix for array assignement. Bring back length scales in rotated operator
domfournier Mar 28, 2025
b3bbaa8
Bring back length_scales
domfournier Mar 28, 2025
dacfb88
Add rotated gradient run test
domfournier Mar 28, 2025
0edf62a
Merge pull request #176 from MiraGeoscience/GEOPY-2075b
benk-mira Mar 28, 2025
b47a375
Add backward diff gradient regularization if rotated
benk-mira Mar 31, 2025
9895c25
Simplify mechanics for backward reg
domfournier Apr 1, 2025
3732175
Use deepcopy
domfournier Apr 1, 2025
0dfa19b
refactor neighbor/corner finding and add unit test
benk-mira Apr 1, 2025
6271153
Improve docstring/typing for new methods
benk-mira Apr 1, 2025
e25f99d
Bring back gradient_type temporarly
domfournier Apr 1, 2025
27934f8
Clean up of inversion model module. Allow to not trim the dip azimut …
domfournier Apr 1, 2025
d1746f2
Merge branch 'GEOPY-2075' into GEOPY-2075_c
domfournier Apr 1, 2025
f63c829
vstack neighbors before asking for max
benk-mira Apr 1, 2025
0557fa2
Fix for MVI
domfournier Apr 1, 2025
fdfcc86
Merge branch 'GEOPY-2075' into GEOPY-2075_c
domfournier Apr 1, 2025
ff56ac1
Merge pull request #179 from MiraGeoscience/GEOPY-2075_c
benk-mira Apr 1, 2025
f5d7173
remove gradient_rotations from 2d/batch2d ui.json files
benk-mira Apr 2, 2025
dd12f83
Merge branch 'GEOPY-2075' of github.com:MiraGeoscience/simpeg-drivers…
benk-mira Apr 2, 2025
812aa95
Set target for gradient rotation runtest after validating solution in…
benk-mira Apr 2, 2025
553f637
remove rotated gradients from gravity runtest
benk-mira Apr 2, 2025
a7bb33a
Fixing tests
benk-mira Apr 2, 2025
8dd9307
more fixes
benk-mira Apr 2, 2025
e068ab3
update phi_m target on gravity runtest
benk-mira Apr 2, 2025
2f31e14
Clip out rows of zero gradients. Simplify get_regularization
domfournier Apr 2, 2025
4c2e838
Merge branch 'GEOPY-2075' of https://github.com/MiraGeoscience/simpeg…
domfournier Apr 2, 2025
94e3673
Merge branch 'develop' into GEOPY-2075
domfournier Apr 2, 2025
87cfa93
Fix driver for 1d inversions
domfournier Apr 2, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions simpeg_drivers-assets/uijson/direct_current_2d_inversion.ui.json
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,17 @@
"property": "",
"enabled": true
},
"gradient_rotation": {
"group": "Regularization",
"association": "Cell",
"dataType": "Float",
"dataGroupType": "Dip direction & dip",
"label": "Gradient rotation",
"optional": true,
"enabled": false,
"parent": "mesh",
"value": ""
},
"s_norm": {
"association": "Cell",
"dataType": "Float",
Expand Down
11 changes: 11 additions & 0 deletions simpeg_drivers-assets/uijson/direct_current_3d_inversion.ui.json
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,17 @@
"property": "",
"enabled": true
},
"gradient_rotation": {
"group": "Regularization",
"association": "Cell",
"dataType": "Float",
"dataGroupType": "Dip direction & dip",
"label": "Gradient rotation",
"optional": true,
"enabled": false,
"parent": "mesh",
"value": ""
},
"s_norm": {
"association": "Cell",
"dataType": "Float",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,17 @@
"property": "",
"enabled": true
},
"gradient_rotation": {
"group": "Regularization",
"association": "Cell",
"dataType": "Float",
"dataGroupType": "Dip direction & dip",
"label": "Gradient rotation",
"optional": true,
"enabled": false,
"parent": "mesh",
"value": ""
},
"s_norm": {
"association": "Cell",
"dataType": "Float",
Expand Down
11 changes: 11 additions & 0 deletions simpeg_drivers-assets/uijson/fem_inversion.ui.json
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,17 @@
"property": "",
"enabled": true
},
"gradient_rotation": {
"group": "Regularization",
"association": "Cell",
"dataType": "Float",
"dataGroupType": "Dip direction & dip",
"label": "Gradient rotation",
"optional": true,
"enabled": false,
"parent": "mesh",
"value": ""
},
"s_norm": {
"association": "Cell",
"dataType": "Float",
Expand Down
11 changes: 11 additions & 0 deletions simpeg_drivers-assets/uijson/gravity_inversion.ui.json
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,17 @@
"property": "",
"enabled": true
},
"gradient_rotation": {
"group": "Regularization",
"association": "Cell",
"dataType": "Float",
"dataGroupType": "Dip direction & dip",
"label": "Gradient rotation",
"optional": true,
"enabled": false,
"parent": "mesh",
"value": ""
},
"s_norm": {
"association": "Cell",
"dataType": "Float",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,17 @@
"property": "",
"enabled": true
},
"gradient_rotation": {
"group": "Regularization",
"association": "Cell",
"dataType": "Float",
"dataGroupType": "Dip direction & dip",
"label": "Gradient rotation",
"optional": true,
"enabled": false,
"parent": "mesh",
"value": ""
},
"s_norm": {
"association": "Cell",
"dataType": "Float",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,17 @@
"property": "",
"enabled": true
},
"gradient_rotation": {
"group": "Regularization",
"association": "Cell",
"dataType": "Float",
"dataGroupType": "Dip direction & dip",
"label": "Gradient rotation",
"optional": true,
"enabled": false,
"parent": "mesh",
"value": ""
},
"s_norm": {
"association": "Cell",
"dataType": "Float",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,17 @@
"property": "",
"enabled": true
},
"gradient_rotation": {
"group": "Regularization",
"association": "Cell",
"dataType": "Float",
"dataGroupType": "Dip direction & dip",
"label": "Gradient rotation",
"optional": true,
"enabled": false,
"parent": "mesh",
"value": ""
},
"s_norm": {
"association": "Cell",
"dataType": "Float",
Expand Down
11 changes: 11 additions & 0 deletions simpeg_drivers-assets/uijson/joint_surveys_inversion.ui.json
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,17 @@
"property": "",
"enabled": true
},
"gradient_rotation": {
"group": "Regularization",
"association": "Cell",
"dataType": "Float",
"dataGroupType": "Dip direction & dip",
"label": "Gradient rotation",
"optional": true,
"enabled": false,
"parent": "mesh",
"value": ""
},
"s_norm": {
"association": "Cell",
"dataType": "Float",
Expand Down
11 changes: 11 additions & 0 deletions simpeg_drivers-assets/uijson/magnetic_scalar_inversion.ui.json
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,17 @@
"property": "",
"enabled": true
},
"gradient_rotation": {
"group": "Regularization",
"association": "Cell",
"dataType": "Float",
"dataGroupType": "Dip direction & dip",
"label": "Gradient rotation",
"optional": true,
"enabled": false,
"parent": "mesh",
"value": ""
},
"s_norm": {
"association": "Cell",
"dataType": "Float",
Expand Down
11 changes: 11 additions & 0 deletions simpeg_drivers-assets/uijson/magnetic_vector_inversion.ui.json
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,17 @@
"property": "",
"enabled": true
},
"gradient_rotation": {
"group": "Regularization",
"association": "Cell",
"dataType": "Float",
"dataGroupType": "Dip direction & dip",
"label": "Gradient rotation",
"optional": true,
"enabled": false,
"parent": "mesh",
"value": ""
},
"s_norm": {
"association": "Cell",
"dataType": "Float",
Expand Down
11 changes: 11 additions & 0 deletions simpeg_drivers-assets/uijson/magnetotellurics_inversion.ui.json
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,17 @@
"property": "",
"enabled": true
},
"gradient_rotation": {
"group": "Regularization",
"association": "Cell",
"dataType": "Float",
"dataGroupType": "Dip direction & dip",
"label": "Gradient rotation",
"optional": true,
"enabled": false,
"parent": "mesh",
"value": ""
},
"s_norm": {
"association": "Cell",
"dataType": "Float",
Expand Down
9 changes: 9 additions & 0 deletions simpeg_drivers-assets/uijson/tdem_inversion.ui.json
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,15 @@
"property": "",
"enabled": true
},
"gradient_rotation": {
"group": "Regularization",
"association": "Cell",
"dataType": "Float",
"dataGroupType": "Dip direction & dip",
"label": "Gradient rotation",
"parent": "mesh",
"value": ""
},
"s_norm": {
"association": "Cell",
"dataType": "Float",
Expand Down
17 changes: 17 additions & 0 deletions simpeg_drivers-assets/uijson/tipper_inversion.ui.json
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,23 @@
"property": "",
"enabled": true
},
"gradient_phi": {
"group": "Regularization",
"main": true,
"label": "test",
"value": 9
},
Comment thread
benk-mira marked this conversation as resolved.
Outdated
"gradient_rotation": {
"group": "Regularization",
"association": "Cell",
"dataType": "Float",
"dataGroupType": "Dip direction & dip",
"label": "Gradient rotation",
"optional": true,
"enabled": false,
"parent": "mesh",
"value": ""
},
"s_norm": {
"association": "Cell",
"dataType": "Float",
Expand Down
18 changes: 18 additions & 0 deletions simpeg_drivers/components/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ def __init__(self, driver: InversionDriver):
self._length_scale_x = InversionModel(driver, "length_scale_x")
self._length_scale_y = InversionModel(driver, "length_scale_y")
self._length_scale_z = InversionModel(driver, "length_scale_z")
self._gradient_dip = InversionModel(driver, "gradient_dip")
self._gradient_direction = InversionModel(driver, "gradient_direction")
self._s_norm = InversionModel(driver, "s_norm")
self._x_norm = InversionModel(driver, "x_norm")
self._y_norm = InversionModel(driver, "y_norm")
Expand Down Expand Up @@ -256,6 +258,20 @@ def length_scale_z(self) -> np.ndarray | None:

return self._length_scale_z.model.copy()

@property
def gradient_dip(self) -> np.ndarray | None:
if self._gradient_dip.model is None:
return None

return self._gradient_dip.model.copy()

@property
def gradient_direction(self) -> np.ndarray | None:
if self._gradient_direction.model is None:
return None

return self._gradient_direction.model.copy()

@property
def s_norm(self) -> np.ndarray | None:
if self._s_norm.model is None:
Expand Down Expand Up @@ -358,6 +374,8 @@ class InversionModel:
"length_scale_x",
"length_scale_y",
"length_scale_z",
"gradient_dip",
"gradient_direction",
"s_norm",
"x_norm",
"y_norm",
Expand Down
20 changes: 20 additions & 0 deletions simpeg_drivers/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
)
from simpeg_drivers.joint.params import BaseJointOptions
from simpeg_drivers.utils.utils import tile_locations
from simpeg_drivers.utils.regularization import cell_neighbors, rotated_gradient

mlogger = logging.getLogger("distributed")
mlogger.setLevel(logging.WARNING)
Expand Down Expand Up @@ -440,6 +441,7 @@ def get_regularization(self):
return BaseRegularization(mesh=self.inversion_mesh.mesh)

reg_funcs = []
is_rotated = self.params.gradient_rotation is not None
for mapping in self.mapping:
reg = Sparse(
self.inversion_mesh.mesh,
Expand All @@ -448,10 +450,14 @@ def get_regularization(self):
reference_model=self.models.reference,
)

if is_rotated:
neighbors = cell_neighbors(reg.regularization_mesh)

# Adjustment for 2D versus 3D problems
comps = "sxz" if "2d" in self.params.inversion_type else "sxyz"
avg_comps = "sxy" if "2d" in self.params.inversion_type else "sxyz"
weights = ["alpha_s"] + [f"length_scale_{k}" for k in comps[1:]]

for comp, avg_comp, objfct, weight in zip(
comps, avg_comps, reg.objfcts, weights
):
Expand All @@ -467,6 +473,20 @@ def get_regularization(self):
)
norm = getattr(reg.regularization_mesh, f"aveCC2F{avg_comp}") * norm

if is_rotated:
Grad = rotated_gradient(
mesh=reg.regularization_mesh.mesh,
neighbors=neighbors,
axis=comp,
dip=self.models.gradient_dip,
direction=self.models.gradient_direction,
)
setattr(
reg.regularization_mesh.mesh,
f"_stencil_cell_gradient_{comp}",
Grad,
)

objfct.set_weights(**{comp: weight})
objfct.norm = norm

Expand Down
3 changes: 2 additions & 1 deletion simpeg_drivers/joint/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from geoapps_utils.driver.data import BaseData
from geoh5py.data import FloatData
from geoh5py.groups import SimPEGGroup, UIJsonGroup
from geoh5py.groups import PropertyGroup, SimPEGGroup, UIJsonGroup
from geoh5py.objects import DrapeModel, Octree
from geoh5py.shared.utils import fetch_active_workspace
from pydantic import ConfigDict, field_validator, model_validator
Expand Down Expand Up @@ -69,6 +69,7 @@ class BaseJointOptions(BaseData):
length_scale_x: float | FloatData = 1.0
length_scale_y: float | FloatData | None = 1.0
length_scale_z: float | FloatData = 1.0
gradient_rotation: PropertyGroup | None = None
s_norm: float | FloatData | None = 0.0
x_norm: float | FloatData = 2.0
y_norm: float | FloatData | None = 2.0
Expand Down
Loading