From 2a5c471faa5ebe02a44e207495a577eb4c1a799d Mon Sep 17 00:00:00 2001 From: Sven Augustin Date: Fri, 27 Oct 2023 12:35:04 +0200 Subject: [PATCH] added cache length setting --- caplot.py | 13 +++++++++---- plot0d.py | 5 +++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/caplot.py b/caplot.py index c6f9230..209efd4 100755 --- a/caplot.py +++ b/caplot.py @@ -6,17 +6,19 @@ warnings.filterwarnings("error") import argparse -parser = argparse.ArgumentParser() +parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument("pvname") +parser.add_argument("-n", "--num", type=int, default=1000) clargs = parser.parse_args() +from functools import partial from animation import Animation from plots import Plot0D, Plot1D, Plot2D from sources import Camera, Source -def decide_src_fun(pvname): +def decide_src_fun(pvname, num): pvname = pvname.upper() if pvname.endswith(":FPICTURE"): @@ -33,7 +35,9 @@ def decide_src_fun(pvname): if src.nelm == 1: print("Scalar") - fun = Plot0D + if num <= 0: + num = None + fun = partial(Plot0D, num) else: print("Curve") fun = Plot1D @@ -43,7 +47,8 @@ def decide_src_fun(pvname): pvname = clargs.pvname -src, fun = decide_src_fun(pvname) +num = clargs.num +src, fun = decide_src_fun(pvname, num) Animation(src, fun) diff --git a/plot0d.py b/plot0d.py index 21ee664..0cad9df 100644 --- a/plot0d.py +++ b/plot0d.py @@ -39,11 +39,12 @@ def hist(values, bins="auto"): class Plot0D: - def __init__(self, *args, **kwargs): + def __init__(self, num, *args, **kwargs): self.fig, axs = plt.subplots(1, 2) self.ax_time, self.ax_hist = ax_time, ax_hist = axs - self.cache = Cache() + print("cache length", num or "infinite") + self.cache = Cache(num) lines = ax_time.plot([0], [0]) self.plot_time = lines[0] #TODO: wtf?