Skip to content

Commit

Permalink
Postprocessing overhaul
Browse files Browse the repository at this point in the history
  • Loading branch information
danielandresarcones committed Mar 20, 2024
1 parent d19cae7 commit f2c523d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import numpy as np
from nibelungenbruecke.scripts.utilities.loaders import load_influence_lines, load_sensors

def plot_influence_lines(parameters:dict):
def plot_influence_lines_run(parameters:dict):
''' Plot a list of influence lines from a h5 file into np.arrays'''

input_parameters = _get_default_parameters()
Expand Down Expand Up @@ -30,6 +30,7 @@ def _get_default_parameters():
return {
"sensors_path": "input/sensors/sensors_displacements.json",
"influence_lines_path": "input/data/line_test.h5",
"file_dep": ["input/sensors/sensors_displacements.json", "input/data/line_test.h5"],
"output_path": "output/figures/influence_lines",
"output_format": "png"
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

# local imports (inference data post-processing)

def posterior_predictive(parameters:dict):
def posterior_predictive_run(parameters:dict):
"Generates synthetic data according to a process especified in the parameters"

# Initialize defaults
Expand Down Expand Up @@ -70,6 +70,7 @@ def _get_default_parameters():
"forward_model_path": "probeye_forward_model_bridge",
"input_sensors_path": "input/sensors/sensors_displacements_probeye_input.json",
"output_sensors_path": "input/sensors/sensors_displacements_probeye_output.json",
"file_dep": ["input/sensors/sensors_displacements_probeye_input.json", "input/sensors/sensors_displacements_probeye_output.json"],
"problem_parameters": ["rho", "mu", "lambda"],
"parameters_key_paths": [[],[],[]],
"model_parameters": {}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import importlib

def postprocess_run(parameters: dict):

for task, load_task in parameters.items():
module = importlib.import_module("nibelungenbruecke.scripts.postprocessing."+task)
functions = {name: value for name, value in vars(module).items() if callable(value)and name.endswith("_run")}
for name, value in functions.items():
value(load_task)
23 changes: 8 additions & 15 deletions nibelungenbruecke/tasks/postprocess_results_tasks.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
import json
import numpy as np

from nibelungenbruecke.scripts.postprocessing.plot_influence_lines import plot_influence_lines
from nibelungenbruecke.scripts.postprocessing.postprocessing_runner import postprocess_run

def task_plot_influence_lines():
def task_postprocess_run():
postprocess_parameters_path = "./input/settings/postprocess_parameters.json"
with open(postprocess_parameters_path, 'r') as f:
postprocess_parameters = json.load(f)

plot_influence_lines_parameters = postprocess_parameters["plot_influence_lines"]
return {'actions': [(plot_influence_lines,[],{'parameters':plot_influence_lines_parameters})],
'file_dep': [plot_influence_lines_parameters["sensors_path"],plot_influence_lines_parameters["influence_lines_path"]],
'targets': [plot_influence_lines_parameters["output_path"]+plot_influence_lines_parameters["output_format"]],
'uptodate': [True]}

if __name__ == "__main__":

postprocess_parameters_path = "./input/settings/postprocess_parameters.json"
with open(postprocess_parameters_path, 'r') as f:
postprocess_parameters = json.load(f)

plot_influence_lines(postprocess_parameters["plot_influence_lines"])
dependencies = list(np.concatenate([task["file_dep"] for task in postprocess_parameters.values()]).flat)
return {'actions': [(postprocess_run,[],{'parameters':postprocess_parameters})],
'file_dep': dependencies,
'targets': [],
'uptodate': [False]} # Normally always to be run

0 comments on commit f2c523d

Please sign in to comment.