Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ classifiers = [
"Programming Language :: Python :: 3.12",
]
description = "Bluesky plans to be run on Diamond's test rigs e.g. ViSR, P45, etc"
dependencies = ["dls-dodal>=3.0.7", "scanspec>=1.0.0"]
dependencies = ["dls-dodal>=3.0.8", "scanspec>=1.0.0"]
dynamic = ["version"]
license.file = "LICENSE"
readme = "README.md"
Expand Down
16 changes: 8 additions & 8 deletions src/test_rig_bluesky/baselines/tomography_stage_baseline.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
acceleration_time: 0.001
high_limit_travel: 1000
low_limit_travel: -1000
offset: 0.0
offset_freeze_switch: Variable
set_use_switch: Use
user_setpoint: 5.00004
velocity: 30
theta.acceleration_time: 0.001
theta.high_limit_travel: 1000
theta.low_limit_travel: -1000
theta.offset: 0.0
theta.offset_freeze_switch: Variable
theta.set_use_switch: Use
theta.user_setpoint: 5.00004
theta.velocity: 30
2 changes: 1 addition & 1 deletion src/test_rig_bluesky/plans.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def serialize_spec(spec: Spec[Any]) -> Any:
"""Render a Spec as something JSON-serializable, for scan metadata.

Axes that are devices are written out by their ``name`` (e.g.
``"sample_stage-x"``), so consumers of the run's start document can tell
``"spectroscopy_stage-x"``), so consumers of the run's start document can tell
which axis is which.
"""
return spec.serialize()
Expand Down
68 changes: 32 additions & 36 deletions src/test_rig_bluesky/spectroscopy_plans.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@

LOGGER = logging.getLogger(__name__)

spectroscopy_detector = inject("spectroscopy_detector")
spectroscopy_diodes = inject("spectroscopy_diodes")
detector = inject("spectroscopy_detector")
diodes = inject("spectroscopy_diodes")
pandabox = inject("pandabox")
sample_stage = inject("spectroscopy_stage")
stage = inject("spectroscopy_stage")

# The encoder entries map to specific axes, so despite the PandA being shared
# hardware this list is spectroscopy's.
Expand All @@ -62,12 +62,12 @@


def spectroscopy(
spectroscopy_detector: AravisDetector = spectroscopy_detector,
sample_stage: XYZStage = sample_stage,
detector: AravisDetector = detector,
stage: XYZStage = stage,
pmac: PmacIO = pmac,
pandabrick: HDFPanda = pandabrick,
pandabox: HDFPanda = pandabox,
spectroscopy_diodes: RGBDiodes = spectroscopy_diodes,
diodes: RGBDiodes = diodes,
spec: Spec[Movable] | None = None,
exposure_time: float = 0.1,
amplifier_range: EnzLocumRange | None = None,
Expand All @@ -78,19 +78,15 @@ def spectroscopy(
"""Do a spectroscopy scan, acquiring from the camera and the RGB diodes."""
# The range is only recorded once per scan, as configuration, so it must not
# change between points
scan_range = amplifier_range or (
yield from bps.rd(spectroscopy_diodes.amplifier.range)
)
scan_range = amplifier_range or (yield from bps.rd(diodes.amplifier.range))
if scan_range == EnzLocumRange.AUTO:
raise ValueError("The diode amplifier must be on a fixed range, not Auto")

if amplifier_range is not None:
yield from bps.abs_set(
spectroscopy_diodes.amplifier.range, amplifier_range, wait=True
)
yield from bps.abs_set(diodes.amplifier.range, amplifier_range, wait=True)

yield from load_settings(
device=spectroscopy_detector,
device=detector,
design_name="spectroscopy_detector_baseline",
whitelist_pvs=[
"hdf-nd_array_port",
Expand Down Expand Up @@ -126,17 +122,17 @@ def spectroscopy(
# outside of a run.
# See: https://github.com/DiamondLightSource/blueapi/issues/1211
yield from bps.mv(
*(spectroscopy_detector.driver.acquire_time, exposure_time),
*(detector.driver.acquire_time, exposure_time),
*(
spectroscopy_detector.driver.acquire_period,
detector.driver.acquire_period,
exposure_time + MANTA_ACQUIRE_PERIOD_PAD,
),
group="spectroscopy_detector_aquire",
group="detector_aquire",
)

params: list[NDAttributeParam] = []
for channel in list(spectroscopy_detector.roistat.channels.keys()): # type: ignore
roistatn = spectroscopy_detector.roistat.channels[channel] # type: ignore
for channel in list(detector.roistat.channels.keys()): # type: ignore
roistatn = detector.roistat.channels[channel] # type: ignore
assert isinstance(roistatn, NDROIStatNIO)

channel_name = yield from bps.rd(roistatn.name_)
Expand All @@ -151,11 +147,11 @@ def spectroscopy(
)
)

yield from setup_ndattributes(spectroscopy_detector.roistat, params) # type: ignore
yield from setup_ndattributes(detector.roistat, params) # type: ignore

yield from load_settings(
device=sample_stage,
design_name="sample_stage_baseline",
device=stage,
design_name="spectroscopy_stage_baseline",
whitelist_pvs=[
"x-acceleration_time",
"x-velocity",
Expand All @@ -164,7 +160,7 @@ def spectroscopy(
],
)

spec = spec or Line(sample_stage.x, 0, 5, 5) # type: ignore
spec = spec or Line(stage.x, 0, 5, 5) # type: ignore

# write json-serializable form of spec into metadata
if metadata is None:
Expand All @@ -181,32 +177,34 @@ def spectroscopy(
)
yield from fly_scan(
spec,
spectroscopy_detector,
detector,
pmac=pmac,
pandabrick=pandabrick,
exposure_time=exposure_time,
detector_deadtime=MANTA_DETECTOR_DEADTIME,
pandabrick_whitelist=PANDA_WHITELIST,
metadata=metadata,
pandabox=pandabox,
diodes=spectroscopy_diodes,
diodes=diodes,
)
elif scan_type == ScanType.STEP:
LOGGER.info("Performing a step scan.")
yield from spec_scan(
{spectroscopy_detector, spectroscopy_diodes, sample_stage},
{detector, diodes, stage},
spec, # type: ignore
metadata=metadata,
)
else:
raise ValueError(f"Unsupported scan type: {scan_type}")


def demo_spectroscopy(
spectroscopy_detector: AravisDetector = spectroscopy_detector,
sample_stage: XYZStage = sample_stage,
detector: AravisDetector = detector,
stage: XYZStage = stage,
pmac: PmacIO = pmac,
pandabrick: HDFPanda = pandabrick,
pandabox: HDFPanda = pandabox,
spectroscopy_diodes: RGBDiodes = spectroscopy_diodes,
diodes: RGBDiodes = diodes,
total_number_of_scan_points: int = 25,
grid_size: float = 5.0,
grid_origin_x: float = 0.0,
Expand Down Expand Up @@ -239,23 +237,21 @@ def demo_spectroscopy(

# Move to the start point
# pmac should handle premove
yield from bps.mv(
*(sample_stage.x, xmin), *(sample_stage.y, ymin), group="initial_move"
)
yield from bps.mv(*(stage.x, xmin), *(stage.y, ymin), group="initial_move")

grid = Line(sample_stage.y, ymin, ymax, ysteps) * ~Line( # type: ignore
sample_stage.x, # type: ignore
grid = Line(stage.y, ymin, ymax, ysteps) * ~Line( # type: ignore
stage.x, # type: ignore
xmin,
xmax,
xsteps,
)
yield from spectroscopy(
spectroscopy_detector=spectroscopy_detector,
sample_stage=sample_stage,
detector=detector,
stage=stage,
pmac=pmac,
pandabrick=pandabrick,
pandabox=pandabox,
spectroscopy_diodes=spectroscopy_diodes,
diodes=diodes,
spec=grid,
exposure_time=exposure_time,
metadata=metadata,
Expand Down
Loading
Loading