Skip to content

Commit 8a9cf45

Browse files
authored
Merge pull request #134 from MiraGeoscience/GEOPY-1029
GEOPY-1029
2 parents 7297f79 + da9525f commit 8a9cf45

2 files changed

Lines changed: 27 additions & 6 deletions

File tree

simpeg/directives/_directives.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2676,8 +2676,14 @@ class ScaleMisfitMultipliers(InversionDirective):
26762676
Parameters
26772677
----------
26782678
2679-
path : str
2679+
filepath : str
26802680
Path to save the chi-factors log file.
2681+
nesting : list of lists
2682+
Nested list structure that matches the structure of the misfit functions in the inverse problem.
2683+
target_chi : float
2684+
Target chi-factor for the misfit functions. Misfit functions with chi-factors below this value will be scaled more aggressively.
2685+
headers : list of str
2686+
List of headers for the chi-factors log file.
26812687
"""
26822688

26832689
def __init__(
@@ -2695,9 +2701,9 @@ def __init__(
26952701
self.headers = headers
26962702

26972703
if path is None:
2698-
path = pathlib.Path("./")
2704+
path = pathlib.Path("./ChiFactors.log")
26992705

2700-
self.filepath = path / "ChiFactors.log"
2706+
self.filepath = path
27012707

27022708
super().__init__(**kwargs)
27032709

simpeg/directives/_save_geoh5.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -384,16 +384,27 @@ def joint_index(self, value: list[int] | None):
384384

385385

386386
class SaveLogFilesGeoH5(BaseSaveGeoH5):
387+
def __init__(
388+
self,
389+
h5_object,
390+
start_date_time: str,
391+
**kwargs,
392+
):
393+
394+
self.time_stamp = start_date_time
395+
super().__init__(h5_object, **kwargs)
387396

388397
def write(self, iteration: int, **_):
389398
dirpath = Path(self._workspace.h5file).parent
390-
filepath = dirpath / "SimPEG.out"
399+
filepath = dirpath / f"SimPEG_{self.time_stamp}.out"
391400

392401
if iteration == 0:
393402
with open(filepath, "w", encoding="utf-8") as f:
394403
f.write("iteration beta phi_d phi_m time\n")
395404
log = []
396-
with open(dirpath / "SimPEG.log", "r", encoding="utf-8") as file:
405+
with open(
406+
dirpath / f"SimPEG_{self.time_stamp}.log", "r", encoding="utf-8"
407+
) as file:
397408
iteration = 0
398409
for line in file:
399410
val = re.findall(r"[+-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+-]?\d+)", line)
@@ -420,7 +431,11 @@ def save_log(self):
420431
with fetch_active_workspace(self._workspace, mode="r+") as w_s:
421432
h5_object = w_s.get_entity(self.h5_object)[0]
422433

423-
for file in ["SimPEG.out", "SimPEG.log", "ChiFactors.log"]:
434+
for file in [
435+
f"SimPEG_{self.time_stamp}.out",
436+
f"SimPEG_{self.time_stamp}.log",
437+
f"ChiFactors_{self.time_stamp}.log",
438+
]:
424439
filepath = dirpath / file
425440

426441
if not filepath.is_file():

0 commit comments

Comments
 (0)