From 2e878303a5f39fe85e0d5db7a4a184507989b95d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Sierro?= Date: Wed, 11 Oct 2023 15:21:07 +0200 Subject: [PATCH] added auto range functions --- src/scgenerator/plotting.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/scgenerator/plotting.py b/src/scgenerator/plotting.py index c502157..31ef28c 100644 --- a/src/scgenerator/plotting.py +++ b/src/scgenerator/plotting.py @@ -1155,6 +1155,16 @@ def annotate_fwhm( ax.text(x, y, arrow_label, transform=trans, **text_kwargs) +def auto_time_range(t: np.ndarray, t_int: np.ndarray, threshold: float) -> PlotRange: + imin, imax = math.span_above(t_int, t_int.max() * threshold) + return PlotRange(t[imin] * 1e15, t[imax] * 1e15, "fs") + + +def auto_wl_range(wl: np.ndarray, wl_int: np.ndarray, threshold: float) -> PlotRange: + imin, imax = math.span_above(wl_int, wl_int.max() * threshold) + return PlotRange(wl[imin] * 1e9, wl[imax] * 1e9, "nm") + + def summary_plot( specs: Spectrum, z: Sequence[float] | None = None,