-
Notifications
You must be signed in to change notification settings - Fork 0
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
Center-of-mass #94
Comments
Proposed as CoM is a pretty "core" thing that lots of beamlines will need & it came up in LOQ bluesky testing. |
Made a PR on bluesky upstream. Now we wait.. bluesky/bluesky#1878 |
In addition to the PR above, looks like bluesky's e.g. >>> ps1 = PeakStats("x", "y")
>>> ps1.start({})
>>> ps1.event({"data": {"x": 0, "y": 0}})
>>> ps1.event({"data": {"x": 0, "y": 0}})
>>> ps1.event({"data": {"x": 1, "y": 1}})
>>> ps1.event({"data": {"x": 1, "y": 1}})
>>> ps1.event({"data": {"x": 2, "y": 0}})
>>> ps1.event({"data": {"x": 2, "y": 0}})
>>> ps1.stop({})
>>> print(f'com 1: {ps1["com"]}')
com 1: 1.0
>>> ps2 = PeakStats("x", "y")
>>> ps2.start({})
>>> ps2.event({"data": {"x": 0, "y": 0}})
>>> ps2.event({"data": {"x": 1, "y": 1}})
>>> ps2.event({"data": {"x": 2, "y": 0}})
>>> ps2.event({"data": {"x": 2, "y": 0}})
>>> ps2.event({"data": {"x": 1, "y": 1}})
>>> ps2.event({"data": {"x": 0, "y": 0}})
>>> ps2.stop({})
>>> print(f'com 2: {ps2["com"]}')
com 2: 2.0 The events above are identical, only the order of events has changed - but the CoM is reported incorrectly in the second case. This means that Concrete example with non-overlapping data that could be generated by a step scan with step=1 vs an adaptive scan with initial_step = 2 and min_step = 1 that measures exactly the same x/y points (and only needs 1 "swap" to demonstrate the bug): >>> ps1 = PeakStats("x", "y")
>>> ps1.start({})
>>> ps1.event({"data": {"x": 0, "y": 0}})
>>> ps1.event({"data": {"x": 1, "y": 1}})
>>> ps1.event({"data": {"x": 2, "y": 2}})
>>> ps1.event({"data": {"x": 3, "y": 1}})
>>> ps1.event({"data": {"x": 4, "y": 0}})
>>> ps1.stop({})
>>> print(f'com 1: {ps1["com"]}')
2.0
>>> ps2 = PeakStats("x", "y")
>>> ps2.start({})
>>> ps2.event({"data": {"x": 0, "y": 0}})
>>> ps2.event({"data": {"x": 2, "y": 2}})
>>> ps2.event({"data": {"x": 1, "y": 1}})
>>> ps2.event({"data": {"x": 3, "y": 1}})
>>> ps2.event({"data": {"x": 4, "y": 0}})
>>> ps2.stop({})
>>> print(f'com 2: {ps2["com"]}')
1.25 |
Initial test suggests non-constant x point spacing might also be yet another issue - when I first skim-read the bluesky implementation it looked like they had used the resample & linear interpolate approach, but having tested it I don't think that's true. At this point, probably best to write a completely new CoM callback, rather than trying to incrementally fix all these things in the existing one in |
When doing a continuous scan using the laser/laser diode against sample changer pos on LOQ, we used bluesky's
PeakStats
callback to get a centre of mass. It returned an implausible result, well outside the actual peak.i.e. for a peak that looked like this:
(scan uid
bed72c78-61bc-49c6-98ac-8974162b2e08
)we got a centre of mass of
507.4936482348703
- which just visually is clearly badly wrong.A few things it could have been getting confused by:
-2 -1 0 1 2 1 0 -1 -2
CoM should be able to cope with all of these, but suspect one of the above is not handled well and that's what caused a bad result.
Acceptance criteria
Planning
10/01/25 - 00:21:30
Discussed 19/12/20224 - agreed to push to next spring
The text was updated successfully, but these errors were encountered: