Skip to content
Open
Changes from all commits
Commits
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
15 changes: 5 additions & 10 deletions simpeg/directives/_save_geoh5.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,24 +387,19 @@ class SaveLogFilesGeoH5(BaseSaveGeoH5):
def __init__(
self,
h5_object,
start_date_time: str,
**kwargs,
):

self.time_stamp = start_date_time
super().__init__(h5_object, **kwargs)

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

Comment thread
benk-mira marked this conversation as resolved.
if iteration == 0:
with open(filepath, "w", encoding="utf-8") as f:
f.write("iteration beta phi_d phi_m time\n")
log = []
with open(
dirpath / f"SimPEG_{self.time_stamp}.log", "r", encoding="utf-8"
) as file:
with open(dirpath / "SimPEG.log", "r", encoding="utf-8") as file:
iteration = 0
for line in file:
val = re.findall(r"[+-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+-]?\d+)", line)
Expand Down Expand Up @@ -432,9 +427,9 @@ def save_log(self):
h5_object = w_s.get_entity(self.h5_object)[0]

for file in [
f"SimPEG_{self.time_stamp}.out",
f"SimPEG_{self.time_stamp}.log",
f"ChiFactors_{self.time_stamp}.log",
"SimPEG.out",
"SimPEG.log",
"ChiFactors.log",
]:
filepath = dirpath / file

Expand Down
Loading