diff --git a/examples/disc_brake/disc_brake_param_dep_example.py b/examples/disc_brake/disc_brake_param_dep_example.py index 8bed9fa..ad21a6a 100644 --- a/examples/disc_brake/disc_brake_param_dep_example.py +++ b/examples/disc_brake/disc_brake_param_dep_example.py @@ -245,6 +245,17 @@ def main( yscale="log", ) + # %% plot trajectories + use_train_data = False + idx_gen = "rand" + aphin_vis.plot_time_trajectories_all( + disc_brake_data, + disc_brake_data_id, + use_train_data=use_train_data, + idx_gen=idx_gen, + result_dir=result_dir, + ) + # %% 3D plots # save each test parameter set as csv for i, mu_ in enumerate(disc_brake_data.TEST.Mu): @@ -368,17 +379,6 @@ def main( close_on_end=True, ) - # %% plot trajectories - use_train_data = False - idx_gen = "rand" - aphin_vis.plot_time_trajectories_all( - disc_brake_data, - disc_brake_data_id, - use_train_data=use_train_data, - idx_gen=idx_gen, - result_dir=result_dir, - ) - # parameter variation for multiple experiment runs # requires calc_various_experiments = True diff --git a/examples/mass_spring_damper/mass_spring_damper.py b/examples/mass_spring_damper/mass_spring_damper.py index ad03ba8..34fc20b 100755 --- a/examples/mass_spring_damper/mass_spring_damper.py +++ b/examples/mass_spring_damper/mass_spring_damper.py @@ -16,7 +16,7 @@ save_weights, write_to_experiment_overview, save_evaluation_times, - save_training_times + save_training_times, ) from aphin.utils.print_matrices import print_matrices @@ -75,7 +75,13 @@ def main(config_path_to_file=None): cache_path = os.path.join(data_dir, msd_cfg["sim_name"]) # %% Load data - msd_data = Dataset.from_data(cache_path) + try: + msd_data = Dataset.from_data(cache_path) + except FileNotFoundError: + raise FileNotFoundError( + f"File could not be found. If this is the first time you run this example, please execute the data generating script `./state_space_ph/mass_spring_damper_data_gen.py` first." + ) + # split into train and test data msd_data.train_test_split(test_size=msd_cfg["test_size"], seed=msd_cfg["seed"]) # scale data @@ -162,7 +168,11 @@ def main(config_path_to_file=None): msd_data.calculate_errors(msd_data_id, domain_split_vals=[1, 1]) use_train_data = False - aphin_vis.plot_errors(msd_data, use_train_data) + aphin_vis.plot_errors( + msd_data, + use_train_data, + save_name=os.path.join(result_dir, "rms_error"), + ) msd_data.calculate_errors(msd_data_id, save_to_txt=True, result_dir=result_dir) diff --git a/examples/pendulum/pendulum.py b/examples/pendulum/pendulum.py index dd6d48b..abb3122 100755 --- a/examples/pendulum/pendulum.py +++ b/examples/pendulum/pendulum.py @@ -16,7 +16,7 @@ save_weights, write_to_experiment_overview, save_training_times, - save_evaluation_times + save_evaluation_times, ) from aphin.utils.print_matrices import print_matrices @@ -78,7 +78,12 @@ def main(config_path_to_file=None): r = pd_cfg[experiment]["r"] n_f = pd_cfg["n_n"] * pd_cfg["n_dn"] cache_path = os.path.join(data_dir, "pendulum.npz") - pendulum_data = Dataset.from_data(cache_path) + try: + pendulum_data = Dataset.from_data(cache_path) + except FileNotFoundError: + raise FileNotFoundError( + f"File could not be found. If this is the first time you run this example, please execute the data generating script `./pendulum_data_generation.py` first." + ) pendulum_data.train_test_split(test_size=0.333, seed=pd_cfg["seed"]) pendulum_data.truncate_time(trunc_time_ratio=pd_cfg["trunc_time_ratio"]) pendulum_data.states_to_features()