Skip to content

Commit

Permalink
fixing missing parentheses and indentation errors arising from trying…
Browse files Browse the repository at this point in the history
… to code through github
  • Loading branch information
bch0w committed Jul 14, 2023
1 parent baa3a7c commit 55156c6
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 24 deletions.
1 change: 1 addition & 0 deletions seisflows/workflow/forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ def evaluate_initial_misfit(self):
self.system.run(run_list, path_model=self.path.model_init,
save_residuals=os.path.join(self.path.eval_grad,
"residuals_{src}_1_0.txt")
)

def prepare_data_for_solver(self, **kwargs):
"""
Expand Down
52 changes: 28 additions & 24 deletions seisflows/workflow/inversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,10 @@ def evaluate_initial_misfit(self):
[self.run_forward_simulations,
self.evaluate_objective_function],
path_model=path_model,
save_residuals=os.path.join(self.path.eval_grad,
f"residuals_{{src}}_{self.iteration}_0.txt")
save_residuals=os.path.join(
self.path.eval_grad,
f"residuals_{{src}}_{self.iteration}_0.txt")
)

# Rename exported synthetic traces so they are not overwritten by
# future forward simulations
Expand Down Expand Up @@ -435,28 +437,30 @@ def perform_line_search(self):
)
sys.exit(-1)

def _evaluate_line_search_misfit(self):
"""Convenience fuinction to wrap forward solver and misfit calc"""
# Define where we are in the inversion for file passing between
# preprocess and workflow modules
iteration = self.iteration
step_count = self.optimize.step_count + 1

self.system.run(
[self.run_forward_simulations,
self.evaluate_objective_function],
path_model=os.path.join(self.path.eval_func, "model"),
save_residuals=os.path.join(self.path.eval_func,
f"residuals_{{src}}_{iteration}_{step_count}.txt")
)

residuals_files = glob(os.path.join(self.path.eval_func,
f"residuals_*_{iteration}_{step_count}.txt"))

residuals = self.preprocess.read_residuals(residuals_files)
total_misfit = self.preprocess.sum_residuals(residuals)
logger.debug(f"misfit for trial model (f_try) == {total_misfit:.2E}")
self.optimize.save_vector(name="f_try", m=total_misfit)
def _evaluate_line_search_misfit(self):
"""Convenience fuinction to wrap forward solver and misfit calc"""
# Define where we are in the inversion for file passing between
# preprocess and workflow modules
iteration = self.iteration
step_count = self.optimize.step_count + 1

self.system.run(
[self.run_forward_simulations,
self.evaluate_objective_function],
path_model=os.path.join(self.path.eval_func, "model"),
save_residuals=os.path.join(
self.path.eval_func,
f"residuals_{{src}}_{iteration}_{step_count}.txt")
)

residuals_files = glob(os.path.join(
self.path.eval_func, f"residuals_*_{iteration}_{step_count}.txt")
)

residuals = self.preprocess.read_residuals(residuals_files)
total_misfit = self.preprocess.sum_residuals(residuals)
logger.debug(f"misfit for trial model (f_try) == {total_misfit:.2E}")
self.optimize.save_vector(name="f_try", m=total_misfit)

def finalize_iteration(self):
"""
Expand Down

0 comments on commit 55156c6

Please sign in to comment.