added cache length setting
This commit is contained in:
13
caplot.py
13
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)
|
||||
|
||||
|
||||
|
@ -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?
|
||||
|
Reference in New Issue
Block a user