def record_multiple(self, ys, plotid=0, scalar=1, track_x=True, **kw): tg = self.global_time_generator if tg is None: tg = time_generator(self.scan_delays[plotid]) self.global_time_generator = tg x = tg.next() * scalar for i, yi in enumerate(ys): kw['track_x'] = False self.record(yi, x=x, series=i, **kw) ma = max(ys) mi = min(ys) if ma < self.cur_max[plotid]: self.cur_max[plotid] = -Inf if mi > self.cur_min[plotid]: self.cur_min[plotid] = Inf if track_x: dl = self.data_limits[plotid] mi = max(1, x - dl * self.scan_delays[plotid]) self.set_x_limits(# max=x, min_=mi, plotid=plotid, # pad=1 ) return x
def set_time_zero(self, plotid=0): tg = time_generator(self.scan_delays[plotid]) try: self.time_generators[plotid] = tg except IndexError: self.time_generators.append(tg)
def record_multiple(self, ys, plotid=0, scalar=1, track_x=True, **kw): tg = self.global_time_generator if tg is None: tg = time_generator(self.scan_delays[plotid]) self.global_time_generator = tg x = tg.next() * scalar for i, yi in enumerate(ys): kw['track_x'] = False self.record(yi, x=x, series=i, **kw) ma = max(ys) mi = min(ys) if ma < self.cur_max[plotid]: self.cur_max[plotid] = -Inf if mi > self.cur_min[plotid]: self.cur_min[plotid] = Inf if track_x: dl = self.data_limits[plotid] mi = max(1, x - dl * self.scan_delays[plotid]) self.set_x_limits( # max=x, min_=mi, plotid=plotid, # pad=1 ) return x
def set_time_zero(self, plotid=0): tg = time_generator(self.scan_delays[plotid]) try: self.time_generators[plotid] = tg except IndexError: self.time_generators.append(tg)
def add_time_stamped_value(self, value, frame_key=None, rawtime=False): ''' ''' if frame_key is None: frame_key = self._current_frame frame = self._get_frame(frame_key) if frame is not None: if rawtime: if self.time_gen is None: self.time_gen = time_generator() t = 0 else: t = self.time_gen.next() else: t = generate_datetimestamp() datum = (t, value) self.new_writer(frame, datum)
def add_time_stamped_value(self, value, frame_key=None, rawtime=False): ''' ''' if frame_key is None: frame_key = self._current_frame frame = self._get_frame(frame_key) if frame is not None: if rawtime: if self.time_gen is None: self.time_gen = time_generator() t = 0 else: t = next(self.time_gen) else: t = generate_datetimestamp() datum = (t, value) self.new_writer(frame, datum)
def record_multiple(self, ys, plotid=0, scalar=1, track_x=True, **kw): tg = self.global_time_generator if tg is None: tg = time_generator(self.scan_delays[plotid]) self.global_time_generator = tg x = tg.next() * scalar for i, yi in enumerate(ys): kw['track_x'] = False self.record(yi, x=x, series=i, **kw) ma = max(ys) mi = min(ys) if ma < self.cur_max[plotid]: self.cur_max[plotid] = -Inf if mi > self.cur_min[plotid]: self.cur_min[plotid] = Inf if track_x: # dl = self.data_limits[plotid] # mi = max(1, x - dl * self.scan_delays[plotid]) # ma = max(x*1.05, mi+) sw = self.scan_widths[plotid] if sw: ma = max(x*1.05, sw) mi = 0 if ma > sw: mi = ma-sw else: ma = None dl = self.data_limits[plotid] mi = max(1, x - dl * self.scan_delays[plotid]) self.set_x_limits(max_=ma, min_=mi, plotid=plotid) return x
def record(self, y, x=None, series=0, plotid=0, track_x=True, track_y=True, do_after=None, track_y_pad=5, aux=False, pad=0.1, **kw): xn, yn = self.series[plotid][series] plot = self.plots[plotid] xd = plot.data.get_data(xn) yd = plot.data.get_data(yn) if x is None: try: tg = self.time_generators[plotid] except IndexError: tg = time_generator(self.scan_delays[plotid]) self.time_generators.append(tg) nx = tg.next() else: nx = x ny = float(y) # update raw data # rx = self.raw_x[plotid][series] # ry = self.raw_y[plotid][series] # # self.raw_x[plotid][series] = hstack((rx[MAX_LIMIT:], [nx])) # self.raw_y[plotid][series] = hstack((ry[MAX_LIMIT:], [ny])) dl = self.data_limits[plotid] sd = self.scan_delays[plotid] pad = dl * pad # lim = MAX_LIMIT # pad = 100 # print lim, nx, ny lim = -dl * sd - 1000 new_xd = hstack((xd[lim:], [nx])) new_yd = hstack((yd[lim:], [ny])) # print new_xd self.cur_max[plotid] = max(self.cur_max[plotid], max(new_yd)) self.cur_min[plotid] = min(self.cur_min[plotid], min(new_yd)) def _record_(): if track_x and (self.track_x_min or self.track_x_max) \ or self.force_track_x_flag: ma = new_xd[-1] sd = self.scan_delays[plotid] mi = ma - dl * sd + pad if self.force_track_x_flag or \ ma >= dl * sd - pad: if self.force_track_x_flag: self.force_track_x_flag = False ma = dl * sd if not self.track_x_max: ma = None else: ma = ma + pad if not self.track_x_min: mi = None else: mi = max(1, mi) self.set_x_limits(max_=ma, min_=mi, plotid=plotid, # force=False # pad=10 * self.scan_delays[plotid] ) if track_y and (self.track_y_min[plotid] or self.track_y_max[plotid]): if isinstance(track_y, tuple): mi, ma = track_y if ma is None: ma = self.cur_max[plotid] if mi is None: mi = self.cur_min[plotid] else: if not self.track_y_max[plotid]: ma = None else: ma = self.cur_max[plotid] if not self.track_y_min[plotid]: mi = None else: mi = self.cur_min[plotid] self.set_y_limits(max_=ma, min_=mi, plotid=plotid, pad=track_y_pad, force=False ) if aux: self.add_datum_to_aux_plot((nx, ny), plotid, series) else: plot.data.set_data(xn, new_xd) plot.data.set_data(yn, new_yd) # self.redraw() if do_after: do_after_timer(do_after, _record_) else: _record_() return nx
def record(self, y, x=None, series=0, plotid=0, track_x=True, track_y=True, do_after=None, track_y_pad=5, aux=False, pad=0.1, **kw): xn, yn = self.series[plotid][series] plot = self.plots[plotid] xd = plot.data.get_data(xn) yd = plot.data.get_data(yn) if x is None: try: tg = self.time_generators[plotid] except IndexError: tg = time_generator(self.scan_delays[plotid]) self.time_generators.append(tg) nx = tg.next() else: nx = x ny = float(y) # update raw data # rx = self.raw_x[plotid][series] # ry = self.raw_y[plotid][series] # # self.raw_x[plotid][series] = hstack((rx[MAX_LIMIT:], [nx])) # self.raw_y[plotid][series] = hstack((ry[MAX_LIMIT:], [ny])) dl = self.data_limits[plotid] sd = self.scan_delays[plotid] pad = dl * pad # lim = MAX_LIMIT # pad = 100 # print lim, nx, ny lim = -dl * sd - 1000 new_xd = hstack((xd[lim:], [nx])) new_yd = hstack((yd[lim:], [ny])) # print new_xd self.cur_max[plotid] = max(self.cur_max[plotid], max(new_yd)) self.cur_min[plotid] = min(self.cur_min[plotid], min(new_yd)) def _record_(): if track_x and (self.track_x_min or self.track_x_max) \ or self.force_track_x_flag: ma = new_xd[-1] sd = self.scan_delays[plotid] mi = ma - dl * sd + pad if self.force_track_x_flag or \ ma >= dl * sd - pad: if self.force_track_x_flag: self.force_track_x_flag = False ma = dl * sd if not self.track_x_max: ma = None else: ma = ma + pad if not self.track_x_min: mi = None else: mi = max(1, mi) self.set_x_limits( max_=ma, min_=mi, plotid=plotid, # force=False # pad=10 * self.scan_delays[plotid] ) if track_y and (self.track_y_min[plotid] or self.track_y_max[plotid]): if isinstance(track_y, tuple): mi, ma = track_y if ma is None: ma = self.cur_max[plotid] if mi is None: mi = self.cur_min[plotid] else: if not self.track_y_max[plotid]: ma = None else: ma = self.cur_max[plotid] if not self.track_y_min[plotid]: mi = None else: mi = self.cur_min[plotid] self.set_y_limits(max_=ma, min_=mi, plotid=plotid, pad=track_y_pad, force=False) if aux: self.add_datum_to_aux_plot((nx, ny), plotid, series) else: plot.data.set_data(xn, new_xd) plot.data.set_data(yn, new_yd) # self.redraw() if do_after: do_after_timer(do_after, _record_) else: _record_() return nx