Skip to content

(mx-bluesky#873) Factor out drawing of crosshair from snapshot device#1095

Merged
rtuck99 merged 5 commits intomainfrom
mx-bluesky-873_move_crosshair_logic_to_callback
Mar 26, 2025
Merged

(mx-bluesky#873) Factor out drawing of crosshair from snapshot device#1095
rtuck99 merged 5 commits intomainfrom
mx-bluesky-873_move_crosshair_logic_to_callback

Conversation

@rtuck99
Copy link
Contributor

@rtuck99 rtuck99 commented Mar 6, 2025

Required for

See main PR

Checks for reviewer

  • Would the PR title make sense to a scientist on a set of release notes
  • If a new device has been added does it follow the standards
  • If changing the API for a pre-existing device, ensure that any beamlines using this device have updated their Bluesky plans accordingly
  • Have the connection tests for the relevant beamline(s) been run via dodal connect ${BEAMLINE}

@codecov
Copy link

codecov bot commented Mar 6, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.75%. Comparing base (4b701bb) to head (08b6033).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1095   +/-   ##
=======================================
  Coverage   97.75%   97.75%           
=======================================
  Files         170      171    +1     
  Lines        6851     6853    +2     
=======================================
+ Hits         6697     6699    +2     
  Misses        154      154           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rtuck99 rtuck99 marked this pull request as ready for review March 7, 2025 10:49
@rtuck99 rtuck99 requested a review from a team as a code owner March 7, 2025 10:49
Copy link
Contributor

@DominicOram DominicOram left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, couple of minor bits

Comment on lines +49 to +53
def compute_beam_centre_pixel_xy_for_mm_position(
sample_pos_mm: Sequence[float],
beam_pos_at_origin_px: Sequence[int],
microns_per_pixel: Sequence[float],
) -> Sequence[int]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should: I think this needs a docstring and better typing. It's not obvious how long the sequences of floats/ints should be so I think it would be better to use tuple[float, float]. You could even reuse Pixel as defined in oav/utils. In fact, it's only through reading how this is used in mx-bluesky that I've realised that sample_pos_mm is not the absolute sample position but rather the sample position relative to what it was when the snapshot was taken, correct?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could: Most of the maths for trying to translate beam position, smaple position is currently in the utils file, maybe this makes more sense there?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should: I think this needs a docstring and better typing. It's not obvious how long the sequences of floats/ints should be so I think it would be better to use tuple[float, float]. You could even reuse Pixel as defined in oav/utils. In fact, it's only through reading how this is used in mx-bluesky that I've realised that sample_pos_mm is not the absolute sample position but rather the sample position relative to what it was when the snapshot was taken, correct?

I started out with tuple[int, int] etc. However type checking then requires # type: ignore because the for comprehension is determined to be of type tuple[int, ...] instead of tuple[int, int]

Your assumption about the sample_pos_mm is correct. I originally started writing this before the GH ticket split, so there are some things that anticipate more information being captured from the grid snapshots, which possibly I could have tidied up more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have changed tuple[int, int] to Pixel and it makes the type-checking issue go away. I have no idea why since Pixel = tuple[int, int]. Damn you python type annotations!! <shakes fist at cloud/>

)


class SnapshotWithBeamCentre(MJPG):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should: This kind of feels redundant now? Certainly if it's just taking the snapshot then it doesn't need any reference to beam centre in either the name or holding the references?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could: We might be able to just fold the saving image on trigger into the base MJPG class as it's probably common thing you want the camera to do

@rtuck99 rtuck99 requested a review from DominicOram March 17, 2025 15:19
Copy link
Contributor

@DominicOram DominicOram left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks!

@rtuck99 rtuck99 force-pushed the mx-bluesky-873_move_crosshair_logic_to_callback branch 2 times, most recently from 936878b to 5b9b380 Compare March 25, 2025 14:04
@rtuck99 rtuck99 force-pushed the mx-bluesky-873_move_crosshair_logic_to_callback branch from 5b9b380 to 08b6033 Compare March 26, 2025 09:44
@rtuck99 rtuck99 merged commit bcf6520 into main Mar 26, 2025
19 checks passed
@rtuck99 rtuck99 deleted the mx-bluesky-873_move_crosshair_logic_to_callback branch March 26, 2025 09:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants