本文整理匯總了Python中pychron.graph.graph.Graph.edit_traits方法的典型用法代碼示例。如果您正苦於以下問題:Python Graph.edit_traits方法的具體用法?Python Graph.edit_traits怎麽用?Python Graph.edit_traits使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pychron.graph.graph.Graph
的用法示例。
在下文中一共展示了Graph.edit_traits方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _execute_seek
# 需要導入模塊: from pychron.graph.graph import Graph [as 別名]
# 或者: from pychron.graph.graph.Graph import edit_traits [as 別名]
def _execute_seek(self, controller, pattern):
from pychron.core.ui.gui import invoke_in_main_thread
from pychron.graph.graph import Graph
duration = pattern.duration
g = Graph()
g.edit_traits()
g.new_plot()
s, p = g.new_series()
g.new_plot()
g.new_series(type='line')
cp = CurrentPointOverlay(component=s)
s.overlays.append(cp)
w = 2
g.set_x_limits(-w, w)
g.set_y_limits(-w, w)
om = 60
g.set_x_limits(max_=om, plotid=1)
lm = self.laser_manager
sm = lm.stage_manager
st = time.time()
def update_graph(zs, zz, xx, yy):
cp.point = (xx, yy)
g.add_datum((xx, yy), plotid=0)
t = time.time() - st
g.add_datum((t, zz),
update_y_limits=True,
plotid=1)
g.add_datum((t,) * len(zs), zs,
update_y_limits=True,
plotid=1, series=1)
g.set_x_limits(max_=max(om, t + 10), plotid=1)
g.redraw()
pp = os.path.join(paths.data_dir, 'seek_pattern.txt')
with open(pp, 'w') as wfile:
cx, cy = pattern.cx, pattern.cy
wfile.write('{},{}\n'.format(cx, cy))
wfile.write('#z, x, y, n\n')
gen = pattern.point_generator()
for x, y in gen:
if not self._alive:
break
with PeriodCTX(1):
# x, y = gen.next()
# x, y = pattern.next_point
controller.linear_move(cx + x, cy + y, block=False, velocity=pattern.velocity)
mt = time.time()
zs = []
while sm.moving():
_, _, v = sm.get_brightness()
zs.append(v)
while 1:
if time.time() - mt > duration:
break
_, _, v = sm.get_brightness()
zs.append(v)
if zs:
n = len(zs)
z = sum(zs) / float(n)
self.debug('XY:({},{}) Z:{}, N:{}'.format(x, y, z, n))
pattern.set_point(z, x, y)
wfile.write('{:0.5f},{:0.3f},{:0.3f},{}\n'.format(z, x, y, n))
invoke_in_main_thread(update_graph, zs, z, x, y)
g.close_ui()