From f0fd2a249e68ff80aa2b39163ce60791f70b72c1 Mon Sep 17 00:00:00 2001 From: Lukas Baldauf Date: Tue, 16 Sep 2025 11:45:59 +0200 Subject: [PATCH 1/6] load dir option plot_ens --- inftools/tistools/plot_ens.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/inftools/tistools/plot_ens.py b/inftools/tistools/plot_ens.py index 6e7aa20..b841ba1 100644 --- a/inftools/tistools/plot_ens.py +++ b/inftools/tistools/plot_ens.py @@ -1,15 +1,17 @@ -from typing import Annotated +from typing import Annotated as Atd import typer def plot_ens( - toml: Annotated[str, typer.Option("-toml")] = "restart.toml", - skip: Annotated[bool, typer.Option("-skip", help="skip initial load paths")] = False, - save: Annotated[ str, typer.Option("-save", help="save with scienceplots.") ] = "no", - pp: Annotated[ bool, typer.Option("-pp", help="partial paths version") ] = False, - cap: Annotated[ int, typer.Option("-cap", help="max paths plotted per ens") ] = 100, - time: Annotated[float, typer.Option("-time", help="divide dt by an amount") ] = 1, + toml: Atd[str, typer.Option("-toml")] = "restart.toml", + skip: Atd[bool, typer.Option("-skip", help="skip initial load paths")] = False, + save: Atd[ str, typer.Option("-save", help="save with scienceplots.") ] = "no", + pp: Atd[ bool, typer.Option("-pp", help="partial paths version") ] = False, + cap: Atd[ int, typer.Option("-cap", help="max paths plotted per ens") ] = 100, + time: Atd[float, typer.Option("-time", help="divide dt by an amount") ] = 1, + load: Atd[str, typer.Option("-load", + help = "the path directory, reads load_dir from toml if not given") ] = "", ): """Plot sampled ensemble paths with interfaces""" import os @@ -28,7 +30,8 @@ def plot_ens( toml = tomli.load(toml_file) intf = toml["simulation"]["interfaces"] datafile = toml["output"]["data_file"] - load_dir = toml["simulation"]["load_dir"] + if not load_dir: + load_dir = toml["simulation"]["load_dir"] plt.title("intfs: " + " ".join([str(i) for i in intf])) plt.axhline(intf[0], ls="--", color="k", alpha=0.5) From 5151cbf1504deb0121c0ba0d9e1c1a6c2a5ca367 Mon Sep 17 00:00:00 2001 From: Lukas Baldauf Date: Tue, 16 Sep 2025 11:47:34 +0200 Subject: [PATCH 2/6] fix wrong keyword --- inftools/tistools/plot_ens.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/inftools/tistools/plot_ens.py b/inftools/tistools/plot_ens.py index b841ba1..d5dcec7 100644 --- a/inftools/tistools/plot_ens.py +++ b/inftools/tistools/plot_ens.py @@ -30,8 +30,10 @@ def plot_ens( toml = tomli.load(toml_file) intf = toml["simulation"]["interfaces"] datafile = toml["output"]["data_file"] - if not load_dir: + if not load: load_dir = toml["simulation"]["load_dir"] + else: + load_dir = load plt.title("intfs: " + " ".join([str(i) for i in intf])) plt.axhline(intf[0], ls="--", color="k", alpha=0.5) From b7326295b3eff5126ca546942cdcb90e109f6863 Mon Sep 17 00:00:00 2001 From: Lukas Baldauf Date: Tue, 16 Sep 2025 11:58:38 +0200 Subject: [PATCH 3/6] remove hardcoded restart.toml read --- inftools/tistools/plot_ens.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inftools/tistools/plot_ens.py b/inftools/tistools/plot_ens.py index d5dcec7..427fa4f 100644 --- a/inftools/tistools/plot_ens.py +++ b/inftools/tistools/plot_ens.py @@ -26,7 +26,7 @@ def plot_ens( plt.figure(figsize=(14, 10)) # Read toml info - with open("restart.toml", "rb") as toml_file: + with open(toml, "rb") as toml_file: toml = tomli.load(toml_file) intf = toml["simulation"]["interfaces"] datafile = toml["output"]["data_file"] From bcf8bb0a1677bcbb7cff0df183978a11b1d0e4d3 Mon Sep 17 00:00:00 2001 From: Lukas Baldauf Date: Tue, 16 Sep 2025 12:00:39 +0200 Subject: [PATCH 4/6] plot_ens data file --- inftools/tistools/plot_ens.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/inftools/tistools/plot_ens.py b/inftools/tistools/plot_ens.py index 427fa4f..ee21c59 100644 --- a/inftools/tistools/plot_ens.py +++ b/inftools/tistools/plot_ens.py @@ -5,6 +5,7 @@ def plot_ens( toml: Atd[str, typer.Option("-toml")] = "restart.toml", + data: Atd[str, typer.Option("-data")] = "", skip: Atd[bool, typer.Option("-skip", help="skip initial load paths")] = False, save: Atd[ str, typer.Option("-save", help="save with scienceplots.") ] = "no", pp: Atd[ bool, typer.Option("-pp", help="partial paths version") ] = False, @@ -29,7 +30,10 @@ def plot_ens( with open(toml, "rb") as toml_file: toml = tomli.load(toml_file) intf = toml["simulation"]["interfaces"] - datafile = toml["output"]["data_file"] + if not toml["output"].get("data_file", False) and not data: + exit("Supply a infretis_data.txt file with -data") + else: + datafile = toml["output"]["data_file"] if not load: load_dir = toml["simulation"]["load_dir"] else: From 25f97b245a4433ba3dc79e79ab852d1ca2bb000a Mon Sep 17 00:00:00 2001 From: Lukas Baldauf Date: Tue, 16 Sep 2025 12:05:01 +0200 Subject: [PATCH 5/6] plot_ens data file --- inftools/tistools/plot_ens.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/inftools/tistools/plot_ens.py b/inftools/tistools/plot_ens.py index ee21c59..e3880a3 100644 --- a/inftools/tistools/plot_ens.py +++ b/inftools/tistools/plot_ens.py @@ -32,6 +32,9 @@ def plot_ens( intf = toml["simulation"]["interfaces"] if not toml["output"].get("data_file", False) and not data: exit("Supply a infretis_data.txt file with -data") + elif data: + print("Using {data}") + datafile = data else: datafile = toml["output"]["data_file"] if not load: From f454240404243984d07a98dcc9da686054203432 Mon Sep 17 00:00:00 2001 From: Lukas Baldauf Date: Tue, 16 Sep 2025 12:05:28 +0200 Subject: [PATCH 6/6] fix print --- inftools/tistools/plot_ens.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inftools/tistools/plot_ens.py b/inftools/tistools/plot_ens.py index e3880a3..4974b6b 100644 --- a/inftools/tistools/plot_ens.py +++ b/inftools/tistools/plot_ens.py @@ -33,7 +33,7 @@ def plot_ens( if not toml["output"].get("data_file", False) and not data: exit("Supply a infretis_data.txt file with -data") elif data: - print("Using {data}") + print(f"Using {data}") datafile = data else: datafile = toml["output"]["data_file"]