BCDA-APS / use_bluesky

Tools to help APS use the Bluesky Framework (https://blueskyproject.io/)
8 stars 3 forks source link

hklpy installation not working #44

Closed prjemian closed 4 years ago

prjemian commented 4 years ago

when running at APS workstation wow, get this error:

AttributeError: module 'instrument.devices.sixc' has no attribute 'calc'
In [1]: from instrument.devices import sixc                                                                             
I Thu-14:39:36 - /home/beams1/JEMIAN/.ipython/profile_bluesky/startup/instrument/devices/sixc.py
I Thu-14:39:36 - /home/beams1/JEMIAN/.ipython/profile_bluesky/startup/instrument/devices/diffractometer.py

In [2]: sixc.calc.engine.mode = "constant_phi_vertical"                                                                 
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-2-41db27f3134e> in <module>
----> 1 sixc.calc.engine.mode = "constant_phi_vertical"

AttributeError: module 'instrument.devices.sixc' has no attribute 'calc'

This is the configuration:

import gi
gi.require_version('Hkl', '5.0')
# FIXME: Aaaaaack!  Next line dumps core on fresh ubuntu 19.10!
from hkl.diffract import E6C  #this works for mu=0
# Segmentation fault (core dumped)
from hkl.util import Lattice

from bluesky import plans as bp
from bluesky import plan_stubs as bps

from ophyd import Component
from ophyd import PseudoSingle
from ophyd import SoftPositioner

from .diffractometer import AxisConstraints
from .diffractometer import DiffractometerMixin

class SixCircleDiffractometer(DiffractometerMixin, E6C):
    h = Component(PseudoSingle, '', labels=("hkl", "sixc"))
    k = Component(PseudoSingle, '', labels=("hkl", "sixc"))
    l = Component(PseudoSingle, '', labels=("hkl", "sixc"))

    mu =    Component(SoftPositioner, labels=("motor", "sixc"))
    omega = Component(SoftPositioner, labels=("motor", "sixc"))
    chi =   Component(SoftPositioner, labels=("motor", "sixc"))
    phi =   Component(SoftPositioner, labels=("motor", "sixc"))
    gamma = Component(SoftPositioner, labels=("motor", "sixc"))
    delta = Component(SoftPositioner, labels=("motor", "sixc"))

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        # since this diffractometer uses simulated motors,
        # prime the SoftPositioners (motors) with initial values
        # otherwise, position == None --> describe, etc gets borked
        for axis in (self.mu, self.omega, 
                     self.chi, self.phi, 
                     self.gamma, self.delta):
            axis.move(0)

sixc = SixCircleDiffractometer('', name='sixc')

Note also the comment (from fresh ubuntu 19.10 installation):

# FIXME: Aaaaaack!  Next line dumps core on linuxmint!
from hkl.diffract import E6C  #this works for mu=0
# Segmentation fault (core dumped)
prjemian commented 4 years ago

Maybe it is the sixc object. Try a fourc configuration instead.

``` In [5]: import gi ...: gi.require_version('Hkl', '5.0') ...: from hkl.diffract import E4CV, E4CH #this works for mu=0 ...: from hkl.util import Lattice ...: In [6]: from bluesky import plans as bp ...: from bluesky import plan_stubs as bps ...: ...: from ophyd import Component ...: from ophyd import EpicsMotor ...: from ophyd import PseudoSingle ...: from ophyd import SoftPositioner ...: ...: In [7]: from instrument.devices import AxisConstraints --------------------------------------------------------------------------- ImportError Traceback (most recent call last) in ----> 1 from instrument.devices import AxisConstraints ImportError: cannot import name 'AxisConstraints' from 'instrument.devices' (/home/beams1/JEMIAN/.ipython/profile_bluesky/startup/instrument/devices/__init__.py) In [8]: from instrument.devices.diffractometer import AxisConstraints In [9]: from instrument.devices.diffractometer import DiffractometerMixin In [10]: I0Mon Out[10]: EpicsSignalRO(read_pv='sky:scaler1.S8', name='I0Mon', parent='scaler_channels_chan08', value=0.0, timestamp=631152000.0, auto_monitor=False, string=False) In [11]: MOTOR_PV_OMEGA = "sky:m5" ...: MOTOR_PV_CHI = "sky:m6" ...: MOTOR_PV_PHI = "sky:m7" ...: MOTOR_PV_TTH = "sky:m8" ...: In [12]: class FourCircleDiffractometer(DiffractometerMixin, E4CV): ...: h = Component(PseudoSingle, '', labels=("hkl", "fourc")) ...: k = Component(PseudoSingle, '', labels=("hkl", "fourc")) ...: l = Component(PseudoSingle, '', labels=("hkl", "fourc")) ...: ...: omega = Component(EpicsMotor, MOTOR_PV_OMEGA, labels=("motor", "fourc")) ...: chi = Component(EpicsMotor, MOTOR_PV_CHI, labels=("motor", "fourc")) ...: phi = Component(EpicsMotor, MOTOR_PV_PHI, labels=("motor", "fourc")) ...: tth = Component(EpicsMotor, MOTOR_PV_TTH, labels=("motor", "fourc")) ...: In [13]: fourc = FourCircleDiffractometer('', name='fourc') ...: In [14]: fourc.engine.modes Out[14]: ['bissector', 'constant_omega', 'constant_chi', 'constant_phi', 'double_diffraction', 'psi_constant'] In [15]: fourc.calc.engine.mode = fourc.engine.modes[0] In [16]: fourc.calc.engine.mode Out[16]: 'bissector' ```

passes the simple test.

prjemian commented 4 years ago

reflection solutions for this list:

    reflections = (
        (1,0,0), 
        (1,1,0), 
        (1,0,1), 
        (1,1,1),
    )
(hkl) solution omega chi phi tth
(1, 0, 0) 0 -30.00000 -0.00000 -90.00000 -60.00000
(1, 0, 0) 1 30.00000 -0.00000 90.00000 60.00000
(1, 0, 0) 2 -150.00000 -0.00000 -90.00000 60.00000
(1, 0, 0) 3 -30.00000 180.00000 90.00000 -60.00000
(1, 0, 0) 4 30.00000 180.00000 -90.00000 60.00000
(1, 0, 0) 5 -30.00000 -180.00000 90.00000 -60.00000
(1, 0, 0) 6 30.00000 -180.00000 -90.00000 60.00000
(1, 0, 0) 7 -150.00000 180.00000 90.00000 60.00000
(1, 0, 0) 8 -150.00000 -180.00000 90.00000 60.00000
(1, 1, 0) 0 45.00000 45.00000 90.00000 90.00000
(1, 1, 0) 1 -45.00000 -45.00000 -90.00000 -90.00000
(1, 1, 0) 2 45.00000 135.00000 -90.00000 90.00000
(1, 1, 0) 3 135.00000 45.00000 90.00000 -90.00000
(1, 1, 0) 4 -135.00000 -45.00000 -90.00000 90.00000
(1, 1, 0) 5 -45.00000 -135.00000 90.00000 -90.00000
(1, 1, 0) 6 135.00000 135.00000 -90.00000 -90.00000
(1, 1, 0) 7 -135.00000 -135.00000 90.00000 90.00000
(1, 0, 1) 0 -45.00000 -0.00000 -135.00000 -90.00000
(1, 0, 1) 1 135.00000 -0.00000 45.00000 -90.00000
(1, 0, 1) 2 -45.00000 -180.00000 45.00000 -90.00000
(1, 0, 1) 3 -135.00000 -0.00000 -135.00000 90.00000
(1, 0, 1) 4 -45.00000 180.00000 45.00000 -90.00000
(1, 0, 1) 5 -135.00000 -180.00000 45.00000 90.00000
(1, 0, 1) 6 -135.00000 180.00000 45.00000 90.00000
(1, 0, 1) 7 135.00000 -180.00000 -135.00000 -90.00000
(1, 0, 1) 8 135.00000 180.00000 -135.00000 -90.00000
(1, 1, 1) 0 60.00000 35.26439 45.00000 120.00000
(1, 1, 1) 1 -60.00000 -35.26439 -135.00000 -120.00000
(1, 1, 1) 2 -60.00000 -144.73561 45.00000 -120.00000
(1, 1, 1) 3 -120.00000 -35.26439 -135.00000 120.00000
(1, 1, 1) 4 -120.00000 -144.73561 45.00000 120.00000
(1, 1, 1) 5 60.00000 144.73561 -135.00000 120.00000
prjemian commented 4 years ago

Looks as if it is working but the sixc example is not.