-
Notifications
You must be signed in to change notification settings - Fork 4
Add plan for automatically finding the beam centre on the OAV #1496
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
base: main
Are you sure you want to change the base?
Conversation
… and the frac_of_max + add docstrings
DominicOram
left a comment
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.
Mostly reminders to myself that I will fix but would like an answer on the question around when we optimise transmission
| for zoom in zoom_levels: | ||
| LOGGER.info(f"Moving to zoom level {zoom}") | ||
| yield from bps.abs_set(oav.zoom_controller, zoom, wait=True) | ||
| yield from bps.sleep(1) |
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.
Should: Why do we have a sleep here and in the zoom device? I think probably just having one in the zoom device is better
| zoom_level_to_dict = { | ||
| "7.5x": [ | ||
| oav.zoom_controller.x_placeholder_zoom_7, | ||
| oav.zoom_controller.y_placeholder_zoom_7, | ||
| ], | ||
| "1.0x": [ | ||
| oav.zoom_controller.x_placeholder_zoom_1, | ||
| oav.zoom_controller.y_placeholder_zoom_1, | ||
| ], | ||
| "1.5x": [ | ||
| oav.zoom_controller.x_placeholder_zoom_2, | ||
| oav.zoom_controller.y_placeholder_zoom_2, | ||
| ], | ||
| "2.0x": [ | ||
| oav.zoom_controller.x_placeholder_zoom_3, | ||
| oav.zoom_controller.y_placeholder_zoom_3, | ||
| ], | ||
| "2.5x": [ | ||
| oav.zoom_controller.x_placeholder_zoom_4, | ||
| oav.zoom_controller.y_placeholder_zoom_4, | ||
| ], | ||
| "3.0x": [ | ||
| oav.zoom_controller.x_placeholder_zoom_5, | ||
| oav.zoom_controller.y_placeholder_zoom_5, | ||
| ], | ||
| "5.0x": [ | ||
| oav.zoom_controller.x_placeholder_zoom_6, | ||
| oav.zoom_controller.y_placeholder_zoom_6, | ||
| ], | ||
| "10.0x": [ | ||
| oav.zoom_controller.x_placeholder_zoom_8, | ||
| oav.zoom_controller.y_placeholder_zoom_8, | ||
| ], | ||
| } |
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 stored on the device
| LOGGER.info(f"Moving to zoom level {zoom}") | ||
| yield from bps.abs_set(oav.zoom_controller, zoom, wait=True) | ||
| yield from bps.sleep(1) | ||
| if zoom == "7.5x" or zoom == "1.0x": |
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.
Should: Why do we want to optimise transmission at specifically these zooms? Maybe a question for @olliesilvester or @aragaod
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.
I think this was a bit arbitrary. We definitely wanted to optimise transmission for zoom 7.5 because it's apparently the most important zoom level and then we noticed that this transmission wasn't as good for the low zooms so we also decided to run the optimisation for zoom 1 too during testing.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1496 +/- ##
==========================================
+ Coverage 92.29% 92.36% +0.06%
==========================================
Files 142 142
Lines 8094 8168 +74
==========================================
+ Hits 7470 7544 +74
Misses 624 624
🚀 New features to boost your workflow:
|
|
Notes after testing
|
olliesilvester
left a comment
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 worked as-is on the beamline, but the main things to address are:
- Better validation if you typo the parameters
- Less strict binary search (but we can put that into a new issue)
- Address dodgy xbpm feedback. Could add sleeps in for now, or chase up with controls
| defaults are always correct. | ||
| """ | ||
|
|
||
| LOGGER.info("prearing beamline") |
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.
| LOGGER.info("prearing beamline") | |
| LOGGER.info("Preparing beamline to take scintillator images...") |
| initial_wait_group, | ||
| ) | ||
|
|
||
| LOGGER.info("setting transmission") |
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.
| LOGGER.info("setting transmission") |
| if image_name is None: | ||
| image_name = f"{time.time_ns()}ATT{transmission * 100}" | ||
|
|
||
| LOGGER.info(f"using image name {image_name}") |
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.
| LOGGER.info(f"using image name {image_name}") | |
| LOGGER.info(f"Using image name {image_name}") |
| ) -> MsgGenerator: | ||
| """ | ||
| Prepares the beamline for oav image by making sure the pin is NOT mounted and | ||
| Prepares the beamline for oav image by making sure the pin is not mounted and |
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.
Could: mention in docstring that we're also opening shutter here
| return (yield from bps.rd(max_pixel.max_pixel_val)) | ||
|
|
||
|
|
||
| def optimise_transmission_with_oav( |
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.
Notes from testing:
- Occasionally this would hit the
StopIterationfor various reasons: We are being overly precise; there is an issue with i04's xbpm PV which is causing us to not wait for long enough,;the error margin on the transmission device is much higher than the PV suggests.
We should keep the binary search, but either increase the tolerence, or call it "done" as soon as the next iteration would involve moving the transmission by <x%
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.
Happy to put this part into a separate issue
| zoom_levels_to_centre: list[str] | None = None, | ||
| zoom_levels_to_optimise_transmission: list[str] | None = None, |
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.
Should: These should default to ["1.0x", "7.5x"] and ["1.0x", "7.5x"] respectively, then the if None part on lines 261 and 264 can be removed.
Also, we should use a string enum for the accepted zoom levels so that we can get proper validation. Right now there is no obvious error if someone typo's the zoom level parameters, the plan just ends up hanging somewhere.
| xbpm_feedback: XBPMFeedback, | ||
| transmission: float, | ||
| ): | ||
| yield from bps.trigger(xbpm_feedback, wait=True) |
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.
During testing we ended up adding a sleep after triggering xbpm feedback. This real fix is to address the issues with the PV though
Fixes #1489
Requires DiamondLightSource/dodal#1757
To test: