Skip to content
This repository has been archived by the owner on Sep 2, 2024. It is now read-only.

Commit

Permalink
Do multiple rotation scans in a single detector arming event (#1473)
Browse files Browse the repository at this point in the history
* (#960) add parameters for multi rotation scan

* (#960) add multi rotation plan

* (#960) add abstract methods to params

* (#960) add test for multi rotation scan

* (#960) add test for documents output in multi scan

* (#960) test for vds start dset

* (#960) correctly link VDSes

* (#960) scratch that, use the omega vector to record scan direction

* (#960) add a test for ispyb deposition

* update uml

* move getting max values and calculation into rotation core

* separate calculation and logging

* add some docstrings to DocumentCapturer

* improve logging in rotation calcs
  • Loading branch information
dperl-dls authored Aug 14, 2024
1 parent 2f31177 commit 32ca80d
Show file tree
Hide file tree
Showing 37 changed files with 1,057 additions and 176 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"python.testing.pytestArgs": [],
"python.testing.pytestArgs": ["-v"],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"python.analysis.autoImportCompletions": true,
Expand Down
24 changes: 18 additions & 6 deletions docs/param_hierarchy.puml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@startuml
@startuml hyperion_parameter_model
'https://plantuml.com/class-diagram
title Hyperion Parameter Model

Expand All @@ -13,22 +13,26 @@ package Mixins {
class XyzStarts
class OptionalGonioAngleStarts
class SplitScan
class RotationScanPerSweep
class RotationExperiment
}

class HyperionParameters
note bottom: Base class for all experiment parameter models

package Experiments {
class DiffractionExperiment
class DiffractionExperimentWithSample
class GridCommon
class GridScanWithEdgeDetect
class PinTipCentreThenXrayCentre
class RotationScan
class MultiRotationScan
class RobotLoadThenCentre
class SpecifiedGridScan
class ThreeDGridScan
}

class HyperionParameters
note bottom: Base class for all experiment parameter models

class TemporaryIspybExtras
note bottom: To be removed

Expand All @@ -45,6 +49,10 @@ BaseModel <|-- WithScan
BaseModel <|-- XyzStarts

RotationScan *-- TemporaryIspybExtras
MultiRotationScan *-- TemporaryIspybExtras
OptionalGonioAngleStarts <|-- RotationScanPerSweep
OptionalXyzStarts <|-- RotationScanPerSweep
DiffractionExperimentWithSample <|-- RotationExperiment
HyperionParameters <|-- DiffractionExperiment
WithSnapshot <|-- DiffractionExperiment
DiffractionExperiment <|-- DiffractionExperimentWithSample
Expand All @@ -58,8 +66,12 @@ WithScan <|-- SpecifiedGridScan
SpecifiedGridScan <|-- ThreeDGridScan
SplitScan <|-- ThreeDGridScan
WithOavCentring <|-- GridCommon
DiffractionExperimentWithSample <|-- RotationScan
OptionalXyzStarts <|-- RotationScan
WithScan <|-- RotationScan
RotationScanPerSweep <|-- RotationScan
MultiRotationScan *-- RotationScanPerSweep
RotationExperiment <|-- RotationScan
RotationExperiment <|-- MultiRotationScan
SplitScan <|-- MultiRotationScan
XyzStarts <|-- SpecifiedGridScan
OptionalGonioAngleStarts <|-- GridCommon
OptionalGonioAngleStarts <|-- RotationScan
Expand Down
15 changes: 8 additions & 7 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,19 @@ install_requires =
# If a constraint is not set here or if the dependency is pinned to a hash
# it will be auto-pinned to the latest release version by the pre-release workflow
#
annotated_types
flask-restful
ispyb
nexgen
numpy
opentelemetry-distro
opentelemetry-exporter-jaeger
semver
pydantic
scipy
pyepics
pyzmq
scanspec
numpy
pyepics
ispyb
nexgen
scipy
semver
#
# These dependencies may be issued as pre-release versions and should have a pin constraint
# as by default pip-install will not upgrade to a pre-release.
Expand All @@ -40,7 +41,7 @@ install_requires =
ophyd-async >= 0.3a5
bluesky >= 1.13.0a4
blueapi >= 0.4.3-rc1
dls-dodal @ git+https://github.com/DiamondLightSource/dodal.git@ce3193e0d6e0400752673b8a843cd4530ce71adb
dls-dodal @ git+https://github.com/DiamondLightSource/dodal.git

[options.entry_points]
console_scripts =
Expand Down
20 changes: 10 additions & 10 deletions src/hyperion/device_setup_plans/manipulate_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,22 +82,22 @@ def cleanup_sample_environment(

def move_x_y_z(
smargon: Smargon,
x: float | None = None,
y: float | None = None,
z: float | None = None,
x_mm: float | None = None,
y_mm: float | None = None,
z_mm: float | None = None,
wait=False,
group="move_x_y_z",
):
"""Move the x, y, and z axes of the given smargon to the specified position. All
axes are optional."""

LOGGER.info(f"Moving smargon to x, y, z: {(x, y, z)}")
if x:
yield from bps.abs_set(smargon.x, x, group=group)
if y:
yield from bps.abs_set(smargon.y, y, group=group)
if z:
yield from bps.abs_set(smargon.z, z, group=group)
LOGGER.info(f"Moving smargon to x, y, z: {(x_mm, y_mm, z_mm)}")
if x_mm:
yield from bps.abs_set(smargon.x, x_mm, group=group)
if y_mm:
yield from bps.abs_set(smargon.y, y_mm, group=group)
if z_mm:
yield from bps.abs_set(smargon.z, z_mm, group=group)
if wait:
yield from bps.wait(group)

Expand Down
3 changes: 1 addition & 2 deletions src/hyperion/device_setup_plans/setup_zebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ def setup_zebra_for_rotation(
"Disallowed rotation direction provided to Zebra setup plan. "
"Use RotationDirection.POSITIVE or RotationDirection.NEGATIVE."
)
# TODO Actually set the rotation direction in here.
# See https://github.com/DiamondLightSource/hyperion/issues/1273
yield from bps.abs_set(zebra.pc.dir, direction.value, group=group)
LOGGER.info("ZEBRA SETUP: START")
# must be on for shutter trigger to be enabled
yield from bps.abs_set(zebra.inputs.soft_in_1, SoftInState.YES, group=group)
Expand Down
6 changes: 5 additions & 1 deletion src/hyperion/experiment_plans/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@
from hyperion.experiment_plans.robot_load_then_centre_plan import (
robot_load_then_centre,
)
from hyperion.experiment_plans.rotation_scan_plan import rotation_scan
from hyperion.experiment_plans.rotation_scan_plan import (
multi_rotation_scan,
rotation_scan,
)

__all__ = [
"flyscan_xray_centre",
"grid_detect_then_xray_centre",
"rotation_scan",
"pin_tip_centre_then_xray_centre",
"multi_rotation_scan",
"robot_load_then_centre",
]
8 changes: 7 additions & 1 deletion src/hyperion/experiment_plans/experiment_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
RobotLoadThenCentre,
ThreeDGridScan,
)
from hyperion.parameters.rotation import RotationScan
from hyperion.parameters.rotation import MultiRotationScan, RotationScan


def not_implemented():
Expand All @@ -38,6 +38,7 @@ class ExperimentRegistryEntry(TypedDict):
ThreeDGridScan
| GridScanWithEdgeDetect
| RotationScan
| MultiRotationScan
| PinTipCentreThenXrayCentre
| RobotLoadThenCentre
]
Expand Down Expand Up @@ -70,6 +71,11 @@ class ExperimentRegistryEntry(TypedDict):
"param_type": RobotLoadThenCentre,
"callbacks_factory": create_robot_load_and_centre_callbacks,
},
"multi_rotation_scan": {
"setup": rotation_scan_plan.create_devices,
"param_type": MultiRotationScan,
"callbacks_factory": create_rotation_callbacks,
},
}


Expand Down
4 changes: 1 addition & 3 deletions src/hyperion/experiment_plans/flyscan_xray_centre_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ def flyscan_xray_centre(
md={
"subplan_name": CONST.PLAN.GRIDSCAN_OUTER,
CONST.TRIGGER.ZOCALO: CONST.PLAN.DO_FGS,
"zocalo_environment": parameters.zocalo_environment,
"hyperion_parameters": parameters.json(),
"activate_callbacks": [
"GridscanNexusFileCallback",
Expand Down Expand Up @@ -291,7 +292,6 @@ def run_gridscan(
feature_controlled.fgs_motors,
fgs_composite.eiger,
fgs_composite.synchrotron,
parameters.zocalo_environment,
[parameters.scan_points_first_grid, parameters.scan_points_second_grid],
parameters.scan_indices,
do_during_run=read_during_collection,
Expand All @@ -303,7 +303,6 @@ def kickoff_and_complete_gridscan(
gridscan: FastGridScanCommon,
eiger: EigerDetector,
synchrotron: Synchrotron,
zocalo_environment: str,
scan_points: list[AxesPoints[Axis]],
scan_start_indices: list[int],
do_during_run: Callable[[], MsgGenerator] | None = None,
Expand All @@ -313,7 +312,6 @@ def kickoff_and_complete_gridscan(
@bpp.run_decorator(
md={
"subplan_name": CONST.PLAN.DO_FGS,
"zocalo_environment": zocalo_environment,
"scan_points": scan_points,
"scan_start_indices": scan_start_indices,
}
Expand Down
Loading

0 comments on commit 32ca80d

Please sign in to comment.