Skip to content

Commit 75075cc

Browse files
committed
Change directive
1 parent 891dc26 commit 75075cc

3 files changed

Lines changed: 31 additions & 2 deletions

File tree

simpeg/directives/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@
125125
SaveDataGeoH5,
126126
SaveLogFilesGeoH5,
127127
SaveLPModelGroup,
128+
SaveModelGroup,
128129
SaveModelGeoH5,
129130
SavePGIModel,
130131
SavePropertyGroup,

simpeg/directives/_save_geoh5.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,32 @@ def write(self, iteration: int, **_):
510510
prop_group.add_properties(properties)
511511

512512

513+
class SaveModelGroup(SavePropertyGroup):
514+
"""
515+
Save the model as a property group in the geoh5 file
516+
"""
517+
518+
def __init__(
519+
self,
520+
h5_object,
521+
group_type: GroupTypeEnum = GroupTypeEnum.MULTI,
522+
**kwargs,
523+
):
524+
self.group_type = group_type
525+
526+
super().__init__(h5_object, **kwargs)
527+
528+
def get_names(
529+
self, component: str, channel: int | None, iteration: int
530+
) -> tuple[str, str]:
531+
"""
532+
Format the data and property_group name.
533+
"""
534+
channel_name, _ = super().get_names(component, channel, iteration)
535+
536+
return channel_name, component
537+
538+
513539
class SaveLPModelGroup(SavePropertyGroup):
514540
"""
515541
Save the model as a property group in the geoh5 file

simpeg/directives/_vector_models.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,10 @@ def endIter(self):
161161
self.opt.xc = model
162162

163163
if (
164-
self.invProb.phi_d < self.target
165-
) and self.mode == "cartesian" and self.inversion_type == "magnetic vector":
164+
(self.invProb.phi_d < self.target)
165+
and self.mode == "cartesian"
166+
and self.inversion_type == "magnetic vector"
167+
):
166168
print("Switching MVI to spherical coordinates")
167169
self.mode = "spherical"
168170
self.cartesian_model = model

0 commit comments

Comments
 (0)