diff --git a/nibelungenbruecke/scripts/postprocessing/plot_influence_lines.py b/nibelungenbruecke/scripts/postprocessing/plot_influence_lines.py index 12076ac..2a86570 100644 --- a/nibelungenbruecke/scripts/postprocessing/plot_influence_lines.py +++ b/nibelungenbruecke/scripts/postprocessing/plot_influence_lines.py @@ -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() @@ -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" } \ No newline at end of file diff --git a/nibelungenbruecke/scripts/postprocessing/posterior_predictive.py b/nibelungenbruecke/scripts/postprocessing/posterior_predictive.py index dccfe04..305cb3b 100644 --- a/nibelungenbruecke/scripts/postprocessing/posterior_predictive.py +++ b/nibelungenbruecke/scripts/postprocessing/posterior_predictive.py @@ -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 @@ -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": {} diff --git a/nibelungenbruecke/scripts/postprocessing/postprocessing_runner.py b/nibelungenbruecke/scripts/postprocessing/postprocessing_runner.py new file mode 100644 index 0000000..6f4c40f --- /dev/null +++ b/nibelungenbruecke/scripts/postprocessing/postprocessing_runner.py @@ -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) \ No newline at end of file diff --git a/nibelungenbruecke/tasks/postprocess_results_tasks.py b/nibelungenbruecke/tasks/postprocess_results_tasks.py index 7ffe4a7..30a42e0 100644 --- a/nibelungenbruecke/tasks/postprocess_results_tasks.py +++ b/nibelungenbruecke/tasks/postprocess_results_tasks.py @@ -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"]) \ No newline at end of file + 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 \ No newline at end of file