Skip to content

Commit 79ba55a

Browse files
authored
Merge pull request #78 from MiraGeoscience/GEOPY-2045
GEOPY-2045: Phi-d at Iter 0 shows as nan in the *.out file
2 parents 826b686 + 59b4871 commit 79ba55a

7 files changed

Lines changed: 744 additions & 651 deletions

File tree

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ repos:
2121
- flake8-mutable==1.2.0
2222
- flake8-rst-docstrings==0.3.0
2323
- flake8-docstrings==1.7.0
24+
- flake8-pyproject==1.2.3
2425
- repo: https://github.com/MiraGeoscience/pre-commit-hooks
2526
rev: v1.1.0
2627
hooks:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ exclude_also = [
136136
directory = "coverage_html_report"
137137

138138
[tool.black]
139-
required-version = '24.3.0'
139+
required-version = '25.1.0'
140140
target-version = ['py38', 'py39', 'py310', 'py311']
141141

142142
[tool.flake8]

simpeg/dask/potential_fields/magnetics/simulation.py

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,40 @@
1+
import numpy as np
12
from ....potential_fields.magnetics import Simulation3DIntegral as Sim
2-
from ...simulation import getJtJdiag
3+
from ....utils import sdiag, mkvc
4+
5+
6+
def dask_getJtJdiag(self, m, W=None, f=None):
7+
"""
8+
Return the diagonal of JtJ
9+
"""
10+
11+
self.model = m
12+
13+
self.model = m
14+
if W is None:
15+
W = np.ones(self.Jmatrix.shape[0])
16+
else:
17+
W = W.diagonal()
18+
19+
if getattr(self, "_gtg_diagonal", None) is None:
20+
if not self.is_amplitude_data:
21+
diag = np.asarray(np.einsum("i,ij,ij->j", W**2, self.Jmatrix, self.Jmatrix))
22+
else:
23+
ampDeriv = self.ampDeriv
24+
J = (
25+
ampDeriv[0, :, None] * self.Jmatrix[::3]
26+
+ ampDeriv[1, :, None] * self.Jmatrix[1::3]
27+
+ ampDeriv[2, :, None] * self.Jmatrix[2::3]
28+
)
29+
diag = ((W[:, None] * J) ** 2).sum(axis=0).compute()
30+
self._gtg_diagonal = diag
31+
else:
32+
diag = self._gtg_diagonal
33+
34+
return mkvc((sdiag(np.sqrt(diag)) @ self.chiDeriv).power(2).sum(axis=0))
35+
36+
37+
Sim.getJtJdiag = dask_getJtJdiag
338

439

540
@property
@@ -14,5 +49,4 @@ def G(self):
1449

1550

1651
Sim._delete_on_model_update = []
17-
Sim.getJtJdiag = getJtJdiag
1852
Sim.G = G

simpeg/directives/__init__.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,15 +118,24 @@
118118
ScalingMultipleDataMisfits_ByEig,
119119
JointScalingSchedule,
120120
UpdateSensitivityWeights,
121-
VectorInversion,
121+
Update_IRLS,
122+
ScaleMisfitMultipliers,
123+
)
124+
125+
from ._save_geoh5 import (
126+
BaseSaveGeoH5,
122127
SaveDataGeoH5,
123128
SaveLogFilesGeoH5,
124129
SaveModelGeoH5,
125130
SavePropertyGroup,
126131
SaveSensitivityGeoH5,
127-
Update_IRLS,
132+
)
133+
134+
from ._regularization import UpdateIRLS, SphericalUnitsWeights
135+
136+
from ._vector_models import (
137+
VectorInversion,
128138
ProjectSphericalBounds,
129-
ScaleMisfitMultipliers,
130139
)
131140

132141
from .pgi_directives import (
@@ -135,8 +144,6 @@
135144
PGI_AddMrefInSmooth,
136145
)
137146

138-
from ._regularization import UpdateIRLS, SphericalUnitsWeights
139-
140147
from .sim_directives import (
141148
SimilarityMeasureInversionDirective,
142149
SimilarityMeasureSaveOutputEveryIteration,

0 commit comments

Comments
 (0)