Skip to content

Commit 4a296b0

Browse files
DG-At-DiamondfajinyuanVilltordDominicOramoliwenmandiamond
authored
Add Double Crystal Monochromator to I07 (#1648)
* Make DSpacing metadata optional * Refactor to rename and separate common and base DCM * Update src/dodal/devices/common_dcm.py Co-authored-by: Victor Rogalev <[email protected]> * Update src/dodal/beamlines/i18.py Co-authored-by: Victor Rogalev <[email protected]> * Test fixes for DCMs * Return to separate dcm with d spacing * Move energy conversion tests from i09 in to common test * Tests fixed * Add DCM to i07 * Typo correction Co-authored-by: Dominic Oram <[email protected]> * Comment update, also removed dspacing from i15 dcm * Import fixed * Standardise electron volts as eV (note capital V) * Response to review * Test rename * Test rename --------- Co-authored-by: Fajin Yuan <[email protected]> Co-authored-by: Victor Rogalev <[email protected]> Co-authored-by: Dominic Oram <[email protected]> Co-authored-by: oliwenmandiamond <[email protected]>
1 parent 0bc3a29 commit 4a296b0

File tree

20 files changed

+127
-37
lines changed

20 files changed

+127
-37
lines changed

src/dodal/beamlines/i07.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from dodal.common.beamlines.beamline_utils import device_factory
2+
from dodal.common.beamlines.beamline_utils import set_beamline as set_utils_beamline
3+
from dodal.devices.i07.dcm import DCM
4+
from dodal.log import set_beamline as set_log_beamline
5+
from dodal.utils import BeamlinePrefix, get_beamline_name
6+
7+
BL = get_beamline_name("i07")
8+
set_log_beamline(BL)
9+
set_utils_beamline(BL)
10+
PREFIX = BeamlinePrefix(BL)
11+
12+
13+
@device_factory()
14+
def dcm() -> DCM:
15+
"""Instantiate DCM using two PV bases"""
16+
dcm = DCM(
17+
f"{PREFIX.beamline_prefix}-MO-DCM-01:",
18+
f"{PREFIX.beamline_prefix}-DI-DCM-01:",
19+
"dcm",
20+
)
21+
return dcm

src/dodal/beamlines/i09.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def dcm() -> DoubleCrystalMonochromatorWithDSpacing:
4343

4444
@device_factory()
4545
def energy_source() -> DualEnergySource:
46-
return DualEnergySource(dcm().energy_in_ev, pgm().energy.user_readback)
46+
return DualEnergySource(dcm().energy_in_eV, pgm().energy.user_readback)
4747

4848

4949
# Connect will work again after this work completed

src/dodal/beamlines/i09_1.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def dcm() -> DoubleCrystalMonochromatorWithDSpacing:
3434

3535
@device_factory()
3636
def energy_source() -> EnergySource:
37-
return EnergySource(dcm().energy_in_ev)
37+
return EnergySource(dcm().energy_in_eV)
3838

3939

4040
# Connect will work again after this work completed

src/dodal/devices/b07_1/ccmc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def __init__(
6262
)
6363

6464
# energy derived signal as property
65-
self.energy_in_ev = derived_signal_r(
65+
self.energy_in_eV = derived_signal_r(
6666
self._convert_pos_to_ev, pos_signal=self.crystal
6767
)
6868
super().__init__(name=name)

src/dodal/devices/common_dcm.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ def __init__(
5353
) -> None:
5454
with self.add_children_as_readables():
5555
# Virtual motor PV's which set the physical motors so that the DCM produces requested energy
56-
self.energy_in_kev = Motor(prefix + "ENERGY")
57-
self.energy_in_ev = derived_signal_r(
58-
self._convert_keV_to_eV, energy_signal=self.energy_in_kev.user_readback
56+
self.energy_in_keV = Motor(prefix + "ENERGY")
57+
self.energy_in_eV = derived_signal_r(
58+
self._convert_keV_to_eV, energy_signal=self.energy_in_keV.user_readback
5959
)
6060

6161
self._make_crystals(prefix, xtal_1, xtal_2)

src/dodal/devices/i03/undulator_dcm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def __init__(
5858
async def set(self, value: float):
5959
await self.undulator_ref().raise_if_not_enabled()
6060
await asyncio.gather(
61-
self.dcm_ref().energy_in_kev.set(value, timeout=ENERGY_TIMEOUT_S),
61+
self.dcm_ref().energy_in_keV.set(value, timeout=ENERGY_TIMEOUT_S),
6262
self.undulator_ref().set(value),
6363
)
6464

src/dodal/devices/i07/__init__.py

Whitespace-only changes.

src/dodal/devices/i07/dcm.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
from ophyd_async.epics.core import epics_signal_r
2+
from ophyd_async.epics.motor import Motor
3+
4+
from dodal.devices.common_dcm import (
5+
DoubleCrystalMonochromator,
6+
PitchAndRollCrystal,
7+
StationaryCrystal,
8+
)
9+
10+
11+
class DCM(DoubleCrystalMonochromator[PitchAndRollCrystal, StationaryCrystal]):
12+
"""
13+
Device for i07's DCM, including temperature monitors and vertical motor which were
14+
included in GDA.
15+
"""
16+
17+
def __init__(
18+
self,
19+
motor_prefix: str,
20+
xtal_prefix: str,
21+
name: str = "",
22+
) -> None:
23+
super().__init__(motor_prefix, PitchAndRollCrystal, StationaryCrystal, name)
24+
with self.add_children_as_readables():
25+
self.vertical_in_mm = Motor(motor_prefix + "PERP")
26+
27+
# temperatures
28+
self.xtal1_temp = epics_signal_r(float, xtal_prefix + "PT100-2")
29+
self.xtal2_temp = epics_signal_r(float, xtal_prefix + "PT100-3")
30+
self.xtal1_holder_temp = epics_signal_r(float, xtal_prefix + "PT100-1")
31+
self.xtal2_holder_temp = epics_signal_r(float, xtal_prefix + "PT100-4")
32+
self.gap_motor = epics_signal_r(float, xtal_prefix + "TC-1")
33+
self.white_beam_stop_temp = epics_signal_r(float, xtal_prefix + "WBS:TEMP")

src/dodal/devices/i15/dcm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class DCM(DoubleCrystalMonochromatorBase[ThetaRollYZCrystal, ThetaYCrystal]):
3333

3434
def __init__(self, prefix: str, name: str = "") -> None:
3535
with self.add_children_as_readables():
36-
self.calibrated_energy_in_kev = Motor(prefix + "CAL")
36+
self.calibrated_energy_in_keV = Motor(prefix + "CAL")
3737
self.x1 = Motor(prefix + "X1")
3838

3939
super().__init__(prefix, ThetaRollYZCrystal, ThetaYCrystal, name)

src/dodal/devices/i22/dcm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ async def describe(self) -> dict[str, DataKey]:
107107

108108
async def read(self) -> dict[str, Reading]:
109109
default_reading = await super().read()
110-
energy: float = default_reading[f"{self.name}-energy_in_kev"]["value"]
110+
energy: float = default_reading[f"{self.name}-energy_in_keV"]["value"]
111111
if energy > 0.0:
112112
wavelength = _CONVERSION_CONSTANT / energy
113113
else:

0 commit comments

Comments
 (0)