Skip to content

Commit

Permalink
modified examples
Browse files Browse the repository at this point in the history
  • Loading branch information
schwemro committed Oct 23, 2023
1 parent 5254edc commit d6dac96
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ OUTPUT_AVERAGE:
- "C_iso_evap_soil"
- "C_iso_s"
- "C_iso_q_ss"
- "TT_transp"
- "TT_q_ss"
- "SA_s"
- "ttavg_transp"
- "tt10_transp"
- "tt50_transp"
Expand Down
57 changes: 57 additions & 0 deletions examples/plot_scale/rietholzbach/diagnostic_polar_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,63 @@ def main(tmp_dir):
# fig.tight_layout()
fig.savefig(path, dpi=300)


file = base_path / "hydrus_benchmark" / "params_metrics.txt"
df_params_metrics = pd.read_csv(file, sep="\t")

df_params_metrics10 = df_params_metrics.copy()
df_params_metrics10.loc[:, "id"] = range(len(df_params_metrics10.index))
df_params_metrics10 = df_params_metrics10.sort_values(by="KGE_multi", ascending=False)
df_for_diag10 = df_params_metrics10.loc[: df_params_metrics10.index[9], :]
vars_sim = ["aet", "q_ss"]
for var_sim in vars_sim:
fig = de.diag_polar_plot_multi(
df_for_diag10.loc[:, f"brel_mean_{var_sim}"].values,
df_for_diag10.loc[:, f"temp_cor_{var_sim}"].values,
df_for_diag10.loc[:, f"DE_{var_sim}"].values,
df_for_diag10.loc[:, f"b_dir_{var_sim}"].values,
df_for_diag10.loc[:, f"phi_{var_sim}"].values,
df_for_diag10.loc[:, f"b_hf_{var_sim}"].values,
df_for_diag10.loc[:, f"b_lf_{var_sim}"].values,
df_for_diag10.loc[:, f"b_tot_{var_sim}"].values,
df_for_diag10.loc[:, f"err_hf_{var_sim}"].values,
df_for_diag10.loc[:, f"err_lf_{var_sim}"].values,
a0=df_for_diag10.loc[:, f"ioa0_{var_sim}"].values,
share0=onp.round(onp.max(df_for_diag10.loc[:, f"p0_{var_sim}"]), 2),
)
file = f"diag_polar_plot_{var_sim}_10_optimized_with_KGE_multi.png"
path = base_path_figs / file
# fig.tight_layout()
fig.savefig(path, dpi=300)
file = f"diag_polar_plot_{var_sim}_10_optimized_with_KGE_multi.pdf"
path = base_path_figs / file
# fig.tight_layout()
fig.savefig(path, dpi=300)

var_sim = "d18O_perc_bs"
fig = de.diag_polar_plot_multi(
df_for_diag10.loc[:, f"brel_mean_{var_sim}"].values,
df_for_diag10.loc[:, f"temp_cor_{var_sim}"].values,
df_for_diag10.loc[:, f"DE_{var_sim}"].values,
df_for_diag10.loc[:, f"b_dir_{var_sim}"].values,
df_for_diag10.loc[:, f"phi_{var_sim}"].values,
df_for_diag10.loc[:, f"b_hf_{var_sim}"].values,
df_for_diag10.loc[:, f"b_lf_{var_sim}"].values,
df_for_diag10.loc[:, f"b_tot_{var_sim}"].values,
df_for_diag10.loc[:, f"err_hf_{var_sim}"].values,
df_for_diag10.loc[:, f"err_lf_{var_sim}"].values,
)
file = f"diag_polar_plot_{var_sim}_{tms}_10_optimized_with_KGE_multi.png"
path = base_path_figs / file
# fig.tight_layout()
fig.savefig(path, dpi=300)
file = f"diag_polar_plot_{var_sim}_{tms}_10_optimized_with_KGE_multi.pdf"
path = base_path_figs / file
# fig.tight_layout()
fig.savefig(path, dpi=300)



plt.close("all")
return

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ def main(tmp_dir):
if var_sim in ["dS"]:
df_eval.loc["2000-01":"2000-06", :] = onp.nan
df_eval = df_eval.dropna()
obs_vals = df_eval.loc[:, "obs"].values
sim_vals = df_eval.loc[:, "sim"].values
obs_vals = df_eval.loc[:, "obs"].values.astype(float)
sim_vals = df_eval.loc[:, "sim"].values.astype(float)
key_kge = "KGE_" + var_sim + f"{sc1}"
df_params_metrics.loc[nrow, key_kge] = eval_utils.calc_kge(obs_vals, sim_vals)
key_kge_alpha = "KGE_alpha_" + var_sim + f"{sc1}"
Expand Down Expand Up @@ -184,8 +184,8 @@ def main(tmp_dir):
# skip first seven days for warmup
df_eval.loc[:"1997-01-07", :] = onp.nan
df_eval = df_eval.dropna()
obs_vals = df_eval.loc[:, "obs"].values
sim_vals = df_eval.loc[:, "sim"].values
obs_vals = df_eval.loc[:, "obs"].values.astype(float)
sim_vals = df_eval.loc[:, "sim"].values.astype(float)
key_kge = "KGE_" + var_sim + f"{sc1}"
df_params_metrics.loc[nrow, key_kge] = eval_utils.calc_kge(obs_vals, sim_vals)
key_kge_alpha = "KGE_alpha_" + var_sim + f"{sc1}"
Expand Down Expand Up @@ -215,8 +215,8 @@ def main(tmp_dir):
key_ioa0 = "ioa0_" + var_sim + f"{sc1}"
df_params_metrics.loc[nrow, key_ioa0] = ioa0
# mean absolute error from observations with zero values
obs0_vals = df_obs0_sim.loc[:, "obs"].values
sim0_vals = df_obs0_sim.loc[:, "sim"].values
obs0_vals = df_obs0_sim.loc[:, "obs"].values.astype(float)
sim0_vals = df_obs0_sim.loc[:, "sim"].values.astype(float)
key_mae0 = "MAE0_" + var_sim + f"{sc1}"
df_params_metrics.loc[nrow, key_mae0] = eval_utils.calc_mae(obs0_vals, sim0_vals)
# peak difference from observations with zero values
Expand All @@ -225,8 +225,8 @@ def main(tmp_dir):
# simulations and observations with non-zero values
cond_no0 = df_eval["obs"] > 0
df_obs_sim_no0 = df_eval.loc[cond_no0, :]
obs_vals_no0 = df_obs_sim_no0.loc[:, "obs"].values
sim_vals_no0 = df_obs_sim_no0.loc[:, "sim"].values
obs_vals_no0 = df_obs_sim_no0.loc[:, "obs"].values.astype(float)
sim_vals_no0 = df_obs_sim_no0.loc[:, "sim"].values.astype(float)
# number of data with non-zero observations
N_no0 = len(df_obs_sim_no0.index)
# mean absolute relative error
Expand Down
4 changes: 2 additions & 2 deletions examples/plot_scale/rietholzbach/svat_monte_carlo/svat.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from roger.cli.roger_run_base import roger_base_cli


@click.option("-ns", "--nsamples", type=int, default=1000)
@click.option("-td", "--tmp-dir", type=str, default=None)
@click.option("-ns", "--nsamples", type=int, default=10000)
@click.option("-td", "--tmp-dir", type=str, default=Path(__file__).parent / "output")
@roger_base_cli
def main(nsamples, tmp_dir):
from roger import RogerSetup, roger_routine, roger_kernel, KernelOutput
Expand Down

0 comments on commit d6dac96

Please sign in to comment.