-
Notifications
You must be signed in to change notification settings - Fork 5
554 tidy oav #584
554 tidy oav #584
Conversation
and combined grid detection and scan
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.
Thanks for making a start on this but I think it still needs more cleaning up from prototyping. I think to merge it we need at least a unit test against some fake devices to confirm the plan runs through. Can you also address all the musts.
Can you write up issues for the other comments if you don't address them here? I also think this doesn't address all of the things on the issue it links. I have ticked the ones I think it fixes, can you split the others out into new issues?
| EXPERIMENT_TYPES = Union[GridScanParams, RotationScanParams] | ||
| PLAN_REGISTRY: Dict[str, Dict[str, Callable]] = { | ||
| "full_grid_scan": { | ||
| "setup": full_grid_scan.create_devices, |
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.
Must: Without all these devices in S03 yet this now means that we can't start artemis on a developer machine any more. Not sure what the best solution is here, get some dummy devices into S03 ideally...
| width = 600 | ||
| box_size_microns = 20 |
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 probably come in as parameters?
| yield from bps.abs_set(oav.snapshot.input_pv, parameters.input_plugin + ".CAM") | ||
| yield from bps.abs_set(oav.mxsc.enable_callbacks_pv, 0) |
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: I think these need to be in a finally clause
| detector_motion = Det("BL03I", name="detector_motion") | ||
| backlight = Backlight("BL03I-EA-BL-01:", name="backlight") |
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: For the fgs plan we're passing the beamline in as a param, should probably do the same here
| def wait_for_det_to_finish_moving(detector: Det, timeout=2): | ||
| LOGGER.info("Waiting for detector to finish moving") | ||
| SLEEP_PER_CHECK = 0.1 | ||
| times_to_check = int(timeout / SLEEP_PER_CHECK) | ||
| for _ in range(times_to_check): | ||
| detector_state = yield from bps.rd(detector.shutter) | ||
| detector_z_dmov = yield from bps.rd(detector.z.motor_done_move) | ||
| LOGGER.info(f"Shutter state is {'open' if detector_state==1 else 'closed'}") | ||
| LOGGER.info(f"Detector z DMOV is {detector_z_dmov}") | ||
| if detector_state == 1 and detector_z_dmov == 1: | ||
| return | ||
| yield from bps.sleep(SLEEP_PER_CHECK) | ||
| raise Exception("Detector not finished moving") |
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: This is much like the waiting for fast grid scan to be valid, e.g. messy and horrible. I think we need to put it in the device side probably? Certainly refactor it to be more Bluesky idiomatic
src/artemis/utils/oav_utils.py
Outdated
| Returns the scale of the image. The standard calculation for the image is based | ||
| on a size of (1024, 768) so we require these scaling factors. |
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: This comment is not correct in that we don't use the scaling factors
|
Fair enough, in that case, I'd like to get #595 merged first, since changes there will affect the work that needs to be done here quite a lot |
Codecov Report
@@ Coverage Diff @@
## main DiamondLightSource/hyperion#584 +/- ##
==========================================
+ Coverage 81.68% 90.01% +8.32%
==========================================
Files 30 32 +2
Lines 1376 1412 +36
==========================================
+ Hits 1124 1271 +147
+ Misses 252 141 -111
... and 1 file with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
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.
Looks good, thanks. I tried to spin out as much as possible into other issues, what's left is things we can hopefully quickly fix now
src/artemis/__main__.py
Outdated
| ) = cli_arg_parse() | ||
|
|
||
| artemis.log.set_up_logging_handlers(logging_level, dev_mode) | ||
| dodal_logging_setup(logging_level, dev_mode) |
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: I don't think this is needed, artemis.log.set_up_logging_handlers calls it for you
| # Set the python file to use for calculating the edge waveforms | ||
| current_filename = yield from bps.rd(oav.mxsc.filename) | ||
| if current_filename != filename: | ||
| LOGGER.info(f"Current python file is {current_filename}, setting to {filename}") |
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.
Nit: Message should mention that this is the coming form the OAV, it's not clear without context
| mock_setup.assert_called_once() | ||
|
|
||
|
|
||
| @pytest.mark.skip("fixed in 595") |
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: In #595? This is already merged, so we should remove this skip
| min_y = np.min(top_edge[top_edge != 0]) | ||
| max_y = np.max(bottom_edge[bottom_edge != full_oav_image_height_px]) | ||
| LOGGER.info(f"Min/max {min_y, max_y}") | ||
| # if top and bottom empty after filter use the whole image (ask neil) |
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: Neil said yes, we can remove the comment to ask him
| } | ||
|
|
||
| oav_params = OAVParameters("xrayCentring") | ||
| oav_params = OAVParameters("loopCentring", **oav_param_files) |
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: I think there is an issue using loopCentring here, spun out into #653
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.
Great, thanks for the additional tests
Fixes #554
Link to dodal PR (if required): #25
To test: