-
Notifications
You must be signed in to change notification settings - Fork 4
Add vmxm gridscan plan #1636
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Add vmxm gridscan plan #1636
Changes from all commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
a94ab98
WIP begin making callbacks generic
olliesilvester 5a2c51f
wip
olliesilvester 0a84a71
wip
olliesilvester 40fa5c4
wip
olliesilvester 0ff8cc8
Merge remote-tracking branch 'origin/main' into 364_make_nexus_callba…
olliesilvester 0fa10d9
Some fixes
olliesilvester 757ac75
Partially fix nexus tests
olliesilvester 145a648
Fix nexus tests
olliesilvester e63677e
fix test
olliesilvester c2a232d
fix typing
olliesilvester 860562b
Address some todos and add validator
olliesilvester 0070405
Merge branch 'main' into 364_make_nexus_callbacks_generic
olliesilvester ab8fd89
Merge branch 'main' into 364_make_nexus_callbacks_generic
olliesilvester 7c037bb
Fixes from merge
olliesilvester bf9449f
Add test
olliesilvester 16885da
Remove SingleGrid class
olliesilvester d856a8c
don't implement dummy mode xrc results for 2d grids
olliesilvester a31185d
Link to issue in comments
olliesilvester 20d1d60
Merge remote-tracking branch 'origin/main' into 364_make_nexus_callba…
olliesilvester 668c8e0
Keep up to date
olliesilvester 0e68e2b
Add vmxm FGS entry point
olliesilvester 945cb4c
Fixes and tests
olliesilvester 4a93d73
Typo
olliesilvester 6198594
make codecov happy
olliesilvester 638a8c1
improve tests
olliesilvester 0e03d9b
Merge remote-tracking branch 'origin/main' into 364_make_nexus_callba…
rtuck99 f388814
Merge remote-tracking branch 'origin/main' into 364_make_nexus_callba…
rtuck99 28cff71
Update uv.lock
rtuck99 176d60b
Tidy gridscan plantUML
rtuck99 f36a3f3
Merge branch '364_make_nexus_callbacks_generic' into add_vmxm_gridsca…
rtuck99 e5dcb4e
Make ruff happy
rtuck99 7ede7d8
Update uv.lock
rtuck99 db8fd0f
Merge remote-tracking branch 'origin/main' into add_vmxm_gridscan_plan
rtuck99 a6e89af
Rename composite as suggested
rtuck99 eeb623c
Merge remote-tracking branch 'origin/main' into add_vmxm_gridscan_plan
rtuck99 d0a8f0c
Unpin dodal
rtuck99 dfc3863
Add todo
rtuck99 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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
Empty file.
Empty file.
45 changes: 45 additions & 0 deletions
45
src/mx_bluesky/beamlines/i02_1/device_setup_plans/setup_zebra.py
This file contains hidden or 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,45 @@ | ||
| import bluesky.plan_stubs as bps | ||
| from dodal.devices.zebra.zebra import Zebra | ||
|
|
||
| from mx_bluesky.common.parameters.constants import PlanGroupCheckpointConstants | ||
|
|
||
| ZEBRA_STATUS_TIMEOUT = 30 | ||
|
|
||
|
|
||
| # Control Eiger from motion controller. Fast shutter is configured in GDA | ||
| def setup_zebra_for_gridscan( | ||
| zebra: Zebra, | ||
| ttl_detector: int | None = None, | ||
| group=PlanGroupCheckpointConstants.SETUP_ZEBRA_FOR_GRIDSCAN, | ||
| wait=True, | ||
| ): | ||
| """ | ||
| Assumes that the motion controller, as part of its gridscan PLC, will send triggers as required to the zebra's | ||
| IN1_TTL to control the detector. The fast shutter is configured in GDA, don't need to touch it in Bluesky for now. | ||
| """ | ||
| ttl_detector = ttl_detector or zebra.mapping.outputs.TTL_EIGER | ||
| yield from bps.abs_set( | ||
| zebra.output.out_pvs[ttl_detector], | ||
| zebra.mapping.sources.IN1_TTL, | ||
| ) | ||
| if wait: | ||
| yield from bps.wait(group, timeout=ZEBRA_STATUS_TIMEOUT) | ||
|
|
||
|
|
||
| def tidy_up_zebra_after_gridscan( | ||
| zebra: Zebra, | ||
| ttl_detector: int | None = None, | ||
| group=PlanGroupCheckpointConstants.TIDY_ZEBRA_AFTER_GRIDSCAN, | ||
| wait=False, | ||
| ): | ||
| """Revert zebra to state expected by GDA""" | ||
| ttl_detector = ttl_detector or zebra.mapping.outputs.TTL_EIGER | ||
|
|
||
| yield from bps.abs_set( | ||
| zebra.output.out_pvs[ttl_detector], | ||
| zebra.mapping.sources.OR1, | ||
| group=group, | ||
| ) | ||
|
|
||
| if wait: | ||
| yield from bps.wait(group) |
This file contains hidden or 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,138 @@ | ||
| from functools import partial | ||
|
|
||
| import bluesky.preprocessors as bpp | ||
| import pydantic | ||
| from bluesky.utils import MsgGenerator | ||
| from dodal.beamlines.i02_1 import ZebraFastGridScanTwoD | ||
| from dodal.common import inject | ||
| from dodal.devices.attenuator.attenuator import ReadOnlyAttenuator | ||
| from dodal.devices.common_dcm import DoubleCrystalMonochromatorBase | ||
| from dodal.devices.fast_grid_scan import ( | ||
| set_fast_grid_scan_params as set_flyscan_params_plan, | ||
| ) | ||
| from dodal.devices.flux import Flux | ||
| from dodal.devices.s4_slit_gaps import S4SlitGaps | ||
| from dodal.devices.undulator import BaseUndulator | ||
| from dodal.devices.zebra.zebra import Zebra | ||
|
|
||
| from mx_bluesky.beamlines.i02_1.device_setup_plans.setup_zebra import ( | ||
| setup_zebra_for_gridscan, | ||
| tidy_up_zebra_after_gridscan, | ||
| ) | ||
| from mx_bluesky.beamlines.i02_1.parameters.gridscan import SpecifiedTwoDGridScan | ||
| from mx_bluesky.common.experiment_plans.common_flyscan_xray_centre_plan import ( | ||
| BeamlineSpecificFGSFeatures, | ||
| common_flyscan_xray_centre, | ||
| construct_beamline_specific_fast_gridscan_features, | ||
| ) | ||
| from mx_bluesky.common.external_interaction.callbacks.common.zocalo_callback import ( | ||
| ZocaloCallback, | ||
| ) | ||
| from mx_bluesky.common.external_interaction.callbacks.xray_centre.ispyb_callback import ( | ||
| GridscanISPyBCallback, | ||
| generate_start_info_from_omega_map, | ||
| ) | ||
| from mx_bluesky.common.external_interaction.callbacks.xray_centre.nexus_callback import ( | ||
| GridscanNexusFileCallback, | ||
| ) | ||
| from mx_bluesky.common.parameters.constants import ( | ||
| EnvironmentConstants, | ||
| PlanNameConstants, | ||
| ) | ||
| from mx_bluesky.common.parameters.device_composites import ( | ||
| FlyScanEssentialDevices, | ||
| GonioWithOmegaType, | ||
| ) | ||
| from mx_bluesky.common.parameters.gridscan import GenericGrid | ||
| from mx_bluesky.common.utils.log import LOGGER | ||
|
|
||
|
|
||
| def create_gridscan_callbacks() -> tuple[ | ||
| GridscanNexusFileCallback, GridscanISPyBCallback | ||
| ]: | ||
| return ( | ||
| GridscanNexusFileCallback(param_type=SpecifiedTwoDGridScan), | ||
| GridscanISPyBCallback( | ||
| param_type=GenericGrid, | ||
| emit=ZocaloCallback( | ||
| PlanNameConstants.DO_FGS, | ||
| EnvironmentConstants.ZOCALO_ENV, | ||
| generate_start_info_from_omega_map, | ||
| ), | ||
| ), | ||
| ) | ||
|
|
||
|
|
||
| @pydantic.dataclasses.dataclass(config={"arbitrary_types_allowed": True}) | ||
| class I021FlyScanXRayCentreComposite(FlyScanEssentialDevices[GonioWithOmegaType]): | ||
| """All devices which are directly or indirectly required by this plan""" | ||
|
|
||
| zebra: Zebra | ||
| zebra_fast_grid_scan: ZebraFastGridScanTwoD | ||
| dcm: DoubleCrystalMonochromatorBase | ||
| attenuator: ReadOnlyAttenuator | ||
| flux: Flux | ||
| undulator: BaseUndulator | ||
| s4_slit_gaps: S4SlitGaps | ||
|
|
||
|
|
||
| def construct_i02_1_specific_features( | ||
| fgs_composite: I021FlyScanXRayCentreComposite, | ||
| parameters: SpecifiedTwoDGridScan, | ||
| ) -> BeamlineSpecificFGSFeatures: | ||
| signals_to_read_pre_flyscan = [ | ||
| fgs_composite.synchrotron.synchrotron_mode, | ||
| fgs_composite.gonio, | ||
| fgs_composite.dcm.energy_in_keV, | ||
| fgs_composite.undulator.current_gap, | ||
| fgs_composite.s4_slit_gaps, | ||
| ] | ||
|
|
||
| signals_to_read_during_collection = [ | ||
| fgs_composite.attenuator.actual_transmission, | ||
| fgs_composite.flux.flux_reading, | ||
| fgs_composite.dcm.energy_in_keV, | ||
| fgs_composite.eiger.bit_depth, | ||
| fgs_composite.eiger.cam.roi_mode, | ||
| fgs_composite.eiger.ispyb_detector_id, | ||
| ] | ||
|
|
||
| return construct_beamline_specific_fast_gridscan_features( | ||
| partial(_zebra_triggering_setup), | ||
| partial(_tidy_plan, fgs_composite, group="flyscan_zebra_tidy", wait=True), | ||
| partial( | ||
| set_flyscan_params_plan, | ||
| fgs_composite.zebra_fast_grid_scan, | ||
| parameters.fast_gridscan_params, | ||
| ), | ||
| fgs_composite.zebra_fast_grid_scan, | ||
| signals_to_read_pre_flyscan, | ||
| signals_to_read_during_collection, # type: ignore # See : https://github.com/bluesky/bluesky/issues/1809 | ||
| ) | ||
|
|
||
|
|
||
| def _zebra_triggering_setup(fgs_composite: I021FlyScanXRayCentreComposite, _): | ||
| yield from setup_zebra_for_gridscan(fgs_composite.zebra) | ||
|
|
||
|
|
||
| def _tidy_plan( | ||
| fgs_composite: I021FlyScanXRayCentreComposite, group, wait=True | ||
| ) -> MsgGenerator: | ||
| LOGGER.info("Tidying up Zebra") | ||
| yield from tidy_up_zebra_after_gridscan(fgs_composite.zebra) | ||
|
|
||
|
|
||
| def i02_1_gridscan_plan( | ||
| parameters: SpecifiedTwoDGridScan, | ||
| composite: I021FlyScanXRayCentreComposite = inject(""), | ||
| ) -> MsgGenerator: | ||
| """BlueAPI entry point for i02-1 grid scans""" | ||
|
|
||
| beamline_specific = construct_i02_1_specific_features(composite, parameters) | ||
| callbacks = create_gridscan_callbacks() | ||
|
|
||
| @bpp.subs_decorator(callbacks) | ||
| def decorated_flyscan_plan(): | ||
| yield from common_flyscan_xray_centre(composite, parameters, beamline_specific) | ||
|
|
||
| yield from decorated_flyscan_plan() |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
Empty file.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be removed:
DETECTOR_SIZE_PER_BEAMLINEshould be removed #1748