NSLS-II / wishlist

an issue tracker for the big picture
1 stars 0 forks source link

EPU scan again... #108

Closed cmazzoli closed 8 years ago

cmazzoli commented 8 years ago
In [16]: dscan(epu2.gap,-1,1,20)
Transient Scan ID: 59291
Persistent Unique Scan ID: '3050bf7d-beae-43aa-9572-57ad7be894b7'
Run aborted
Data keys (field names) from EPU2(prefix='XF:23ID-ID{EPU:2', name='epu2', read_attrs=['gap', 'phase'], configuration_attrs=[], monitor_attrs=[]) collide with those from GapMotor2(prefix='XF:23ID-ID{EPU:2-Ax:Gap}', name='epu2_gap', parent='epu2', settle_time=0.0, read_attrs=['readback', 'setpoint', 'stop_signal'], configuration_attrs=[], monitor_attrs=[], limits=None, egu='')
LivePlot did not get any data that corresponds to the x axis. epu2_gap_readback
LivePlot did not get any data that corresponds to the y axis. sclr_ch2
/home/xf23id1/conda_envs/collection/lib/python3.4/site-packages/numpy/core/_methods.py:59: RuntimeWarning: Mean of empty slice.
  warnings.warn("Mean of empty slice.", RuntimeWarning)
/home/xf23id1/conda_envs/collection/lib/python3.4/site-packages/bluesky/run_engine.py:1279: UserWarning: A AttributeError("'LiveTable' object has no attribute '_sep_format'",) was raised during the processing of a stop Document. The error will be ignored to avoid interrupting data collection. To investigate, set RunEngine.ignore_callback_exceptions = False and run again.
  "and run again." % (exc, name.name))
/home/xf23id1/conda_envs/collection/lib/python3.4/site-packages/bluesky/run_engine.py:1279: UserWarning: A ValueError('attempt to get argmax of an empty sequence',) was raised during the processing of a stop Document. The error will be ignored to avoid interrupting data collection. To investigate, set RunEngine.ignore_callback_exceptions = False and run again.
  "and run again." % (exc, name.name))
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-16-f670b68f3d51> in <module>()
----> 1 dscan(epu2.gap,-1,1,20)

/home/xf23id1/conda_envs/collection/lib/python3.4/site-packages/bluesky/simple_scans.py in __call__(self, motor, start, finish, intervals, time, subs, **kwargs)
    286         original_times = _set_acquire_time(time)
    287         result = super().__call__(motor, start, finish, intervals + 1,
--> 288                                   subs=subs, **kwargs)
    289         _unset_acquire_time(original_times)
    290         return result

/home/xf23id1/conda_envs/collection/lib/python3.4/site-packages/bluesky/simple_scans.py in __call__(self, subs, sub_factories, *args, **kwargs)
    182         # Any remainging kwargs go the RE. To be safe, no args are passed
    183         # to RE; RE args effectively become keyword-only arguments.
--> 184         return gs.RE(self.scan, _subs, **kwargs)
    185 
    186 

/home/xf23id1/conda_envs/collection/lib/python3.4/site-packages/bluesky/run_engine.py in __call__(self, plan, subs, raise_if_interrupted, **metadata_kw)
    568                 exc = self._task.exception()
    569                 if exc is not None:
--> 570                     raise exc
    571             if raise_if_interrupted and self._interrupted:
    572                 raise RunEngineInterrupted("RunEngine was interrupted.")

/home/xf23id1/conda_envs/collection/lib/python3.4/asyncio/tasks.py in _step(***failed resolving arguments***)
    237                 # We use the `send` method directly, because coroutines
    238                 # don't have `__iter__` and `__next__` methods.
--> 239                 result = coro.send(None)
    240             else:
    241                 result = coro.throw(exc)

/home/xf23id1/conda_envs/collection/lib/python3.4/site-packages/bluesky/run_engine.py in _run(self)
    740             logger.error("Run aborted")
    741             logger.error("%s", err)
--> 742             raise err
    743         finally:
    744             self.state = 'idle'

/home/xf23id1/conda_envs/collection/lib/python3.4/site-packages/bluesky/run_engine.py in _run(self)
    714                         raise
    715                     except Exception as e:
--> 716                         self._genstack[-1].throw(e)
    717                     self.log.debug("Response: %r", response)
    718                 except KeyboardInterrupt:

/home/xf23id1/conda_envs/collection/lib/python3.4/site-packages/bluesky/plans.py in __iter__(self)
     73             yield Msg('kickoff', flyer, block_group='_flyers')
     74         yield Msg('wait', None, '_flyers')
---> 75         yield from self._gen()
     76         for flyer in self.flyers:
     77             yield Msg('collect', flyer, block_group='_flyers')

/home/xf23id1/conda_envs/collection/lib/python3.4/site-packages/bluesky/plans.py in _gen(self)
    210             yield Msg('wait', None, 'B')
    211             for det in dets:
--> 212                 yield Msg('read', det)
    213             yield Msg('save')
    214 

/home/xf23id1/conda_envs/collection/lib/python3.4/site-packages/bluesky/run_engine.py in _run(self)
    710                         coro = self._command_registry[msg.command]
    711                         self.log.debug("Processing %r", msg)
--> 712                         response = yield from coro(msg)
    713                     except KeyboardInterrupt:
    714                         raise

/home/xf23id1/conda_envs/collection/lib/python3.4/asyncio/coroutines.py in coro(*args, **kw)
    204         @functools.wraps(func)
    205         def coro(*args, **kw):
--> 206             res = func(*args, **kw)
    207             if isinstance(res, futures.Future) or inspect.isgenerator(res):
    208                 res = yield from res

/home/xf23id1/conda_envs/collection/lib/python3.4/site-packages/bluesky/run_engine.py in _read(self, msg)
    905                     raise ValueError("Data keys (field names) from {0!r} "
    906                                      "collide with those from {1!r}"
--> 907                                      "".format(obj, known_obj))
    908             self._describe_cache[obj] = data_keys
    909             self._config_desc_cache[obj] = obj.describe_configuration()

ValueError: Data keys (field names) from EPU2(prefix='XF:23ID-ID{EPU:2', name='epu2', read_attrs=['gap', 'phase'], configuration_attrs=[], monitor_attrs=[]) collide with those from GapMotor2(prefix='XF:23ID-ID{EPU:2-Ax:Gap}', name='epu2_gap', parent='epu2', settle_time=0.0, read_attrs=['readback', 'setpoint', 'stop_signal'], configuration_attrs=[], monitor_attrs=[], limits=None, egu='')

In [17]: gs.DETS
Out[17]: 
[EpicsMotor(prefix='XF:23ID1-ES{Dif-Ax:Th}Mtr', name='theta', settle_time=0.0, read_attrs=['user_readback', 'user_setpoint'], configuration_attrs=['motor_egu'], monitor_attrs=[]),
 EpicsMotor(prefix='XF:23ID1-ES{Dif-Ax:Del}Mtr', name='delta', settle_time=0.0, read_attrs=['user_readback', 'user_setpoint'], configuration_attrs=['motor_egu'], monitor_attrs=[]),
 EpicsMotor(prefix='XF:23ID1-ES{Dif-Ax:Gam}Mtr', name='gamma', settle_time=0.0, read_attrs=['user_readback', 'user_setpoint'], configuration_attrs=['motor_egu'], monitor_attrs=[]),
 EpicsMotor(prefix='XF:23ID1-ES{Dif-Ax:X}Mtr', name='sx', settle_time=0.0, read_attrs=['user_readback', 'user_setpoint'], configuration_attrs=['motor_egu'], monitor_attrs=[]),
 EpicsMotor(prefix='XF:23ID1-ES{Dif-Ax:Y}Mtr', name='say', settle_time=0.0, read_attrs=['user_readback', 'user_setpoint'], configuration_attrs=['motor_egu'], monitor_attrs=[]),
 EpicsMotor(prefix='XF:23ID1-ES{Dif-Ax:Z}Mtr', name='saz', settle_time=0.0, read_attrs=['user_readback', 'user_setpoint'], configuration_attrs=['motor_egu'], monitor_attrs=[]),
 Cryoangle(prefix='', name='cryoangle', settle_time=0.0, read_attrs=['readback', 'setpoint'], configuration_attrs=[], monitor_attrs=[], limits=None, egu=''),
 Temperature(prefix='XF:23ID1-ES{TCtrl:1', name='temp', read_attrs=['a', 'b'], configuration_attrs=[], monitor_attrs=[]),
 PGMEnergy(prefix='XF:23ID1-OP{Mono', name='pgm_en', parent='pgm', settle_time=0.0, read_attrs=['readback', 'setpoint', 'stop_signal'], configuration_attrs=[], monitor_attrs=[], limits=None, egu=''),
 EPU1(prefix='XF:23ID-ID{EPU:1', name='epu1', read_attrs=['gap', 'phase'], configuration_attrs=[], monitor_attrs=[]),
 EPU2(prefix='XF:23ID-ID{EPU:2', name='epu2', read_attrs=['gap', 'phase'], configuration_attrs=[], monitor_attrs=[]),
 SlitsGapCenter(prefix='XF:23ID1-OP{Slt:1', name='slt1', read_attrs=['xg', 'xc', 'yg', 'yc'], configuration_attrs=[], monitor_attrs=[]),
 SlitsGapCenter(prefix='XF:23ID1-OP{Slt:2', name='slt2', read_attrs=['xg', 'xc', 'yg', 'yc'], configuration_attrs=[], monitor_attrs=[]),
 SlitsXY(prefix='XF:23ID1-OP{Slt:3', name='slt3', read_attrs=['x', 'y'], configuration_attrs=[], monitor_attrs=[]),
 Mirror(prefix='XF:23IDA-OP:1{Mir:1', name='m1a', read_attrs=['z', 'y', 'x', 'pit', 'yaw', 'rol'], configuration_attrs=[], monitor_attrs=[]),
 MotorMirror(prefix='XF:23ID1-OP{Mir:3', name='m3a', read_attrs=['x', 'pit', 'bdr'], configuration_attrs=[], monitor_attrs=[]),
 EpicsSignal(read_pv='XF:23ID1-OP{TCtrl:1-Chan:A}T-I', name='mono_tempa', value=298.4, timestamp=1457048274.523504, pv_kw={}, auto_monitor=False, string=False, write_pv='XF:23ID1-OP{TCtrl:1-Chan:A}T-I', limits=False, put_complete=False),
 EpicsSignal(read_pv='XF:23ID1-OP{TCtrl:1-Chan:B}T-I', name='mono_tempb', value=298.4, timestamp=1457048274.68544, pv_kw={}, auto_monitor=False, string=False, write_pv='XF:23ID1-OP{TCtrl:1-Chan:B}T-I', limits=False, put_complete=False),
 EpicsSignal(read_pv='XF:23ID1-OP{Mon-Water}P-I', name='mono_pres', value=8.8248842055945, timestamp=1457048277.640424, pv_kw={}, auto_monitor=False, string=False, write_pv='XF:23ID1-OP{Mon-Water}P-I', limits=False, put_complete=False),
 EpicsSignal(read_pv='XF:23ID-SR{}I-I', name='ring_curr', value=150.12286447430674, timestamp=1457048277.612793, pv_kw={}, auto_monitor=False, string=False, write_pv='XF:23ID-SR{}I-I', limits=False, put_complete=False),
 EpicsScaler(prefix='XF:23ID1-ES{Sclr:1}', name='sclr', read_attrs=['channels', 'time'], configuration_attrs=['preset_time', 'presets', 'gates'], monitor_attrs=[]),
 EpicsSignal(read_pv='XF:23ID1-OP{TCtrl:1-Chan:A}T-I', name='mono_tempa', value=298.4, timestamp=1457048274.523504, pv_kw={}, auto_monitor=False, string=False, write_pv='XF:23ID1-OP{TCtrl:1-Chan:A}T-I', limits=False, put_complete=False),
 EpicsSignal(read_pv='XF:23ID1-OP{TCtrl:1-Chan:B}T-I', name='mono_tempb', value=298.4, timestamp=1457048274.68544, pv_kw={}, auto_monitor=False, string=False, write_pv='XF:23ID1-OP{TCtrl:1-Chan:B}T-I', limits=False, put_complete=False),
 EpicsSignal(read_pv='XF:23ID1-OP{Mon-Water}P-I', name='mono_pres', value=8.8248842055945, timestamp=1457048277.640424, pv_kw={}, auto_monitor=False, string=False, write_pv='XF:23ID1-OP{Mon-Water}P-I', limits=False, put_complete=False)]

In [18]: 
tacaswell commented 8 years ago

Sigh, should have seen this one coming. Fix one issue just to show another...

The issue is that when we collect data for and Event the result of all the read calls get merged together. There is a check to make sure that there is not a name collision (as you would be upset if there were two different devices which both exposed a field 'x' and one of them clobbered the other). In this case they are the same object but that information has been lost.

@danielballan I think the solution here is that the plans just need to get smarter and look for more interesting relationships before handing off to the RE.

@dchabot @klauer I think ophyd needs to grow obj.related(other) and/or obj.common_ancestor(other) and then someone needs to understand a bit of graph theory.

licode commented 8 years ago

Maybe use networkx for graph structure.

danielballan commented 8 years ago

I think that defining __contains__ (so that epu.gap in epu is True) and using root are sufficient.

obj.common_ancestor(other) is obj.root == other.root

To solve this particular issue, plans should check (obj in other or other in obj).

ghost commented 8 years ago

Fixed in ophyd and bluesky in the last cycle @klauer @danielballan