Difference between revisions of "Ophyd"

From GISAXS
Jump to: navigation, search
(Beamlines using ophyd)
 
(4 intermediate revisions by the same user not shown)
Line 19: Line 19:
 
** grabit : screengrab, copied immediately to [[Olog]] notebook.
 
** grabit : screengrab, copied immediately to [[Olog]] notebook.
 
*** 'i' to enter interactive mode, type text, then to exit+save do 'Esc' then ':wq'.
 
*** 'i' to enter interactive mode, type text, then to exit+save do 'Esc' then ':wq'.
 +
 +
==EPICS==
 +
One can access [[EPICS]] process variables (PVs) using [http://cars9.uchicago.edu/software/python/pyepics3/ pyEpics]. There are three levels for getting/setting PV values:
 +
* caget/caput (highest level)
 +
** from epics import caget, caput
 +
** caget(pv)
 +
* PV.get/PV.put (middle level)
 +
** import epics
 +
** motor = epics.PV(pv)
 +
** motor.value
 +
** motor.put(0.0)
 +
* ca.get/ca.put (lowest level)
 +
 +
 +
Any of these methods will work; where performance is not an issue (just setting or reading a few times), any of these methods will work. However, if the values are being read or set repeatedly (e.g. inside a loop), then some methods may work better than others. In particular, "caget/caput" should not be used, since these functions create a new connection with every call. (The connection to the PV is the most time-consuming part.) Moreover, generating a connection involves broadcasting to look for the host (which affects network performance).
 +
 +
For better performance, the correct method is to make the connection at the beginning (only once), and then keep reading/setting the PV using that connection. This means using using PV.get/PV.put or ca.get/ca.put.
 +
 +
If you're reading/setting a large number of different PVs (thousands or even more), using the lowest-level (ca.get/ca.put) is the best method.
 +
 +
One can also do:
 +
* from ophyd import EpicsMotor
 +
* motor = EpicsMotor(pv, name='name')
 +
* motor.user_readback.value
 +
* motor.user_setpoint.set(0.0)
  
 
==Beamlines using ophyd==
 
==Beamlines using ophyd==
Line 25: Line 50:
 
** [[CHX]] (Coherent Hard X-rays)
 
** [[CHX]] (Coherent Hard X-rays)
 
** [[CMS]] (Complex Materials Scattering)
 
** [[CMS]] (Complex Materials Scattering)
 +
** [[SMI]] (Soft Matter Interfaces)
 +
 +
==See Also==
 +
* [https://github.com/NSLS-II/ophyd NSLS-II ophyd github]

Latest revision as of 20:43, 7 November 2016

ophyd is a Python-based interactive environment for instrument control at NSLS-II synchrotron beamlines.

Examples

  • Motors
    • wh_pos() : motor positions
    • mov(dcm_x, 1.0) : move motor
    • movr(dcm_x, -1.0) : relative motion
    • movr([dcm_x, dcm_y], [-1.0,-1.0]) : multiple motions
  • Scan
    • dscan.detectors : list
    • dscan(diff_xh, -1, 1, 25)
  • EPICS
    • Access PVs:
      • caget()
      • caput()
    • Epics signals
      • eiger1M_exposure_time = EpicsSignal('XF:11IDB-BI{Det:Eig1M}cam1:AcquireTime', rw=True, name='eiger1M_exposure_time')
  • Logging
    • grabit : screengrab, copied immediately to Olog notebook.
      • 'i' to enter interactive mode, type text, then to exit+save do 'Esc' then ':wq'.

EPICS

One can access EPICS process variables (PVs) using pyEpics. There are three levels for getting/setting PV values:

  • caget/caput (highest level)
    • from epics import caget, caput
    • caget(pv)
  • PV.get/PV.put (middle level)
    • import epics
    • motor = epics.PV(pv)
    • motor.value
    • motor.put(0.0)
  • ca.get/ca.put (lowest level)


Any of these methods will work; where performance is not an issue (just setting or reading a few times), any of these methods will work. However, if the values are being read or set repeatedly (e.g. inside a loop), then some methods may work better than others. In particular, "caget/caput" should not be used, since these functions create a new connection with every call. (The connection to the PV is the most time-consuming part.) Moreover, generating a connection involves broadcasting to look for the host (which affects network performance).

For better performance, the correct method is to make the connection at the beginning (only once), and then keep reading/setting the PV using that connection. This means using using PV.get/PV.put or ca.get/ca.put.

If you're reading/setting a large number of different PVs (thousands or even more), using the lowest-level (ca.get/ca.put) is the best method.

One can also do:

  • from ophyd import EpicsMotor
  • motor = EpicsMotor(pv, name='name')
  • motor.user_readback.value
  • motor.user_setpoint.set(0.0)

Beamlines using ophyd

  • NSLS-II
    • CSX (Coherent Soft X-rays)
    • CHX (Coherent Hard X-rays)
    • CMS (Complex Materials Scattering)
    • SMI (Soft Matter Interfaces)

See Also