dimension=DIMENSION, observe_every=observe_every, ) s_ukf = s data_ukf = data H = np.array([[params["c"], (1 - params["a"] - params["b"])], [0, 1]]) # --- PLOTS --- # # fig, ax = plot_discharge_predictions( # data, filtered_prior=False, plusR=False) # ax.set_ylim(-0.1, 4.5) # plt.show() fig, ax = plot_discharge_predictions(data, filtered_prior=False, plusR=False) ax.set_title( f"UNSCENTED KF ({DIMENSION}D) Predicted Discharge R: {R} Q: {Q00_s_noise} " "\n $\sigma_{q_{obs}}$:" f"{std_q_obs} " "$\sigma_{r_{obs}}$:" f"{std_r_obs} " "$\sigma_{abc}$:" f"{std_abc} " "$\sigma_{S0}$:" f"{std_S0}" ) ax.set_ylim(-0.1, None) plt.show() # fig.savefig(plot_dir / f"001_discharge_preds_{int( random.random() * 100 )}")
) # ------ INTERPRET OUTPUT ------ # calculate error metrics r2 = calculate_r2_metrics(data) print("R2 Metrics:") print(f"Prior R2: {float(r2.loc[r2['run'] == 'prior', 'r2']):.2f}") print(f"Posterior R2: {float(r2.loc[r2['run'] == 'posterior', 'r2']):.2f}") # 1. Filtered/Prior vs. True Scatter fig, axs = plot_prior_posterior_scatter_r2(data, s, r2) plt.show() fig.savefig(plot_dir / "004_discharge_scatter.png") # 2. prior, filtered, true discharge Lineplot fig, ax = plot_discharge_predictions(data) plt.show() fig.savefig(plot_dir / "005_prior_true_sim_discharge.png") # 3. Plot the Storage Parameter (unobserved) plot_state_storage(s, data) plt.show() fig.savefig(plot_dir / "006_prior_true_sim_storage.png") fig, ax = plot_discharge_uncertainty(data) plt.show() fig.savefig(plot_dir / "007_discharge_uncertainty.png") # fig, ax = plt.subplots(figsize=(12, 4)) ax = plot_filtered_true_obs(data)
print("\\\\" "\\alpha = " f"{alpha}" "\\\\" "\\beta = " f"{beta}" "\\\\" "\\kappa = " f"{kappa}" "\\\\") # --- PLOTS --- ylim = (-0.1, 2.5) # ukf fig, ax = plot_discharge_predictions(data_ukf, filtered_prior=False, plusR=True) ax.set_title( f"UNSCENTED KF ({UKF_DIMENSION}D) Predicted Discharge R: {R} Q: {Q00_s_noise} " "\n $\sigma_{q_{obs}}$:" f"{std_q_obs} " "$\sigma_{r_{obs}}$:" f"{std_r_obs} " "$\sigma_{abc}$:" f"{std_abc} " "$\sigma_{S0}$:" f"{std_S0}") ax.set_ylim(ylim) ax.set_xlim(-1, 50) plt.show() fig.savefig(f"/Users/tommylees/Downloads/00_unscented_kf.png")