This repository has been archived by the owner on Sep 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
349 Create OAV snapshot plan (#1437)
* (#349) Basic experiment plan for taking snapshots * Remove xtal_snapshots and xtal_snapshots_omega_end from ispyb_extras * (#349) Tidy parameter model diagram and commit image * (#349) tidyups
- Loading branch information
Showing
32 changed files
with
454 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ __pycache__/ | |
|
||
# Output | ||
*.png | ||
!docs/*.png | ||
|
||
# Distribution / packaging | ||
.Python | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
@startuml | ||
'https://plantuml.com/class-diagram | ||
title Hyperion Parameter Model | ||
|
||
abstract class BaseModel | ||
|
||
package Mixins { | ||
class WithSample | ||
class WithScan | ||
class WithOavCentring | ||
class WithSnapshot | ||
class OptionalXyzStarts | ||
class XyzStarts | ||
class OptionalGonioAngleStarts | ||
class SplitScan | ||
} | ||
|
||
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 RobotLoadThenCentre | ||
class SpecifiedGridScan | ||
class ThreeDGridScan | ||
} | ||
class TemporaryIspybExtras | ||
note bottom: To be removed | ||
|
||
|
||
BaseModel <|-- HyperionParameters | ||
BaseModel <|-- SplitScan | ||
BaseModel <|-- OptionalGonioAngleStarts | ||
BaseModel <|-- OptionalXyzStarts | ||
BaseModel <|-- TemporaryIspybExtras | ||
BaseModel <|-- WithOavCentring | ||
BaseModel <|-- WithSnapshot | ||
BaseModel <|-- WithSample | ||
BaseModel <|-- WithScan | ||
BaseModel <|-- XyzStarts | ||
|
||
RotationScan *-- TemporaryIspybExtras | ||
HyperionParameters <|-- DiffractionExperiment | ||
WithSnapshot <|-- DiffractionExperiment | ||
DiffractionExperiment <|-- DiffractionExperimentWithSample | ||
WithSample <|-- DiffractionExperimentWithSample | ||
DiffractionExperimentWithSample <|-- GridCommon | ||
GridCommon <|-- GridScanWithEdgeDetect | ||
GridCommon <|-- PinTipCentreThenXrayCentre | ||
GridCommon <|-- RobotLoadThenCentre | ||
GridCommon <|-- SpecifiedGridScan | ||
WithScan <|-- SpecifiedGridScan | ||
SpecifiedGridScan <|-- ThreeDGridScan | ||
SplitScan <|-- ThreeDGridScan | ||
WithOavCentring <|-- GridCommon | ||
DiffractionExperimentWithSample <|-- RotationScan | ||
OptionalXyzStarts <|-- RotationScan | ||
XyzStarts <|-- SpecifiedGridScan | ||
OptionalGonioAngleStarts <|-- GridCommon | ||
OptionalGonioAngleStarts <|-- RotationScan | ||
@enduml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import dataclasses | ||
from datetime import datetime | ||
|
||
from blueapi.core import BlueskyContext, MsgGenerator | ||
from bluesky import plan_stubs as bps | ||
from dodal.devices.oav.oav_detector import OAV | ||
from dodal.devices.oav.oav_parameters import OAVParameters | ||
from dodal.devices.smargon import Smargon | ||
|
||
from hyperion.device_setup_plans.setup_oav import setup_general_oav_params | ||
from hyperion.parameters.components import WithSnapshot | ||
from hyperion.parameters.constants import DocDescriptorNames | ||
from hyperion.utils.context import device_composite_from_context | ||
|
||
OAV_SNAPSHOT_GROUP = "oav_snapshot_group" | ||
|
||
|
||
@dataclasses.dataclass | ||
class OavSnapshotComposite: | ||
smargon: Smargon | ||
oav: OAV | ||
|
||
|
||
def create_devices(context: BlueskyContext) -> OavSnapshotComposite: | ||
return device_composite_from_context(context, OavSnapshotComposite) # type: ignore | ||
|
||
|
||
def _setup_oav( | ||
composite: OavSnapshotComposite, | ||
parameters: WithSnapshot, | ||
oav_parameters: OAVParameters, | ||
): | ||
yield from setup_general_oav_params(composite.oav, oav_parameters) | ||
yield from bps.abs_set( | ||
composite.oav.snapshot.directory, str(parameters.snapshot_directory) | ||
) | ||
|
||
|
||
def _take_oav_snapshot( | ||
composite: OavSnapshotComposite, parameters: WithSnapshot, omega: float | ||
): | ||
yield from bps.abs_set(composite.smargon.omega, omega, group=OAV_SNAPSHOT_GROUP) | ||
time_now = datetime.now() | ||
filename = f"{time_now.strftime('%H%M%S')}_oav_snapshot_{omega:.0f}" | ||
yield from bps.abs_set(composite.oav.snapshot.filename, filename) | ||
yield from bps.trigger(composite.oav.snapshot, group=OAV_SNAPSHOT_GROUP) | ||
yield from bps.wait(group=OAV_SNAPSHOT_GROUP) | ||
yield from bps.create(DocDescriptorNames.OAV_ROTATION_SNAPSHOT_TRIGGERED) | ||
yield from bps.read(composite.oav.snapshot) | ||
yield from bps.save() | ||
|
||
|
||
def oav_snapshot_plan( | ||
composite: OavSnapshotComposite, | ||
parameters: WithSnapshot, | ||
oav_parameters: OAVParameters, | ||
wait: bool = True, | ||
) -> MsgGenerator: | ||
omegas = parameters.snapshot_omegas_deg | ||
if not omegas: | ||
return | ||
yield from _setup_oav(composite, parameters, oav_parameters) | ||
for omega in omegas: | ||
yield from _take_oav_snapshot(composite, parameters, omega) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.