Skip to content

Commit

Permalink
Merge pull request #7 from APS-4ID-POLAR/instrument-utilities
Browse files Browse the repository at this point in the history
Instrument utilities
  • Loading branch information
gfabbris authored Sep 23, 2024
2 parents 19dad53 + eddd6f1 commit 946007d
Show file tree
Hide file tree
Showing 10 changed files with 3,049 additions and 62 deletions.
23 changes: 12 additions & 11 deletions instrument/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,22 @@
from apstools.utils import *

from hkl.user import (
cahkl,
cahkl_table,
calc_UB,
list_samples,
new_sample,
or_swap,
select_diffractometer,
set_energy,
setor,
show_sample,
show_selected_diffractometer,
update_sample,
wh,
pa,
)
# cahkl,
# cahkl_table,
# calc_UB,
# list_samples,
# new_sample,
# or_swap,
# set_energy,
# setor,
# show_sample,
# update_sample,
# wh,
# )

from hkl.util import (
list_orientation_runs,
Expand Down
3 changes: 2 additions & 1 deletion instrument/devices/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

from .simulated_scaler import scaler
from .scaler_4idtest import scaler_4tst
from .scaler_4idCTR8 import scaler_ctr8
# from .scaler_4idCTR8 import scaler_ctr8
from .simulated_sixc import psic, sixcpsi
from .polar_diffractometer import polar, polar_psi
from .simulated_fourc_vertical import fourc
from .simulated_new_diffractometer import diffract
Expand Down
1 change: 0 additions & 1 deletion instrument/devices/polar_diffractometer.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from hkl.user import select_diffractometer
from ..session_logs import logger
logger.info(__file__)
from hkl.diffract import Diffractometer


class SixCircleDiffractometer(ApsPolar):
Expand Down
82 changes: 82 additions & 0 deletions instrument/devices/simulated_sixc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
"""
Simulated psic
"""

__all__ = ["psic"]

from ophyd import Component, PseudoSingle, Kind, Signal, EpicsMotor
from ..framework import sd
import gi

gi.require_version("Hkl", "5.0")
# MUST come before `import hkl`
from hkl.geometries import E6C
from hkl.user import select_diffractometer
from ..session_logs import logger

logger.info(__file__)


class SixCircleDiffractometer(E6C):
"""
E6C: huber diffractometer in 6-circle geometry with energy.
4-ID-D setup.
"""

# HKL and 4C motors
h = Component(PseudoSingle, "", labels=("hkl", "psic"))
k = Component(PseudoSingle, "", labels=("hkl", "psic"))
l = Component(PseudoSingle, "", labels=("hkl", "psic"))

mu = Component(EpicsMotor, "m9", labels=("motor", "psic"))
omega = Component(EpicsMotor, "m10", labels=("motor", "psic"))
chi = Component(EpicsMotor, "m11", labels=("motor", "psic"))
phi = Component(EpicsMotor, "m12", labels=("motor", "psic"))
delta = Component(EpicsMotor, "m13", labels=("motor", "psic"))
gamma = Component(EpicsMotor, "m14", labels=("motor", "psic"))

# Explicitly selects the real motors
# _real = ['theta', 'chi', 'phi', 'tth']
_real = "mu omega chi phi delta gamma".split()

# Energy
energy = Component(Signal, value=8)
energy_update_calc_flag = Component(Signal, value=1)
energy_offset = Component(Signal, value=0)

# TODO: This is needed to prevent busy plotting.
@property
def hints_test(self):
fields = []
for _, component in self._get_components_of_kind(Kind.hinted):
if (~Kind.normal & Kind.hinted) & component.kind:
c_hints = component.hints
fields.extend(c_hints.get("fields", []))
return {"fields": fields}


psic = SixCircleDiffractometer("4idsoftmotors:", name="psic")


class SixcPSI(E6C):
"""
Our 6-circle. Eulerian.
"""

# the reciprocal axes are called "pseudo" in hklpy
psi = Component(PseudoSingle, "")

# the motor axes are called "real" in hklpy
mu = Component(EpicsMotor, "m9", labels=("motor", "sixcpsi"))
omega = Component(EpicsMotor, "m10", labels=("motor", "sixcpsi"))
chi = Component(EpicsMotor, "m11", labels=("motor", "sixcpsi"))
phi = Component(EpicsMotor, "m12", labels=("motor", "sixcpsi"))
delta = Component(EpicsMotor, "m13", labels=("motor", "sixcpsi"))
gamma = Component(EpicsMotor, "m14", labels=("motor", "sixcpsi"))


sixcpsi = SixcPSI("", name="sixcpsi", engine="psi")

select_diffractometer(psic)
sd.baseline.append(psic)
Loading

0 comments on commit 946007d

Please sign in to comment.