Bugfix linearsource scanspecv2#213
Conversation
Changed logic of LinearSource class to account for indexes.
There was a problem hiding this comment.
I'm sure we've got this helper somewhere else in tests/scanspec2 already...
| # Detector with total acquisition time of 1s | ||
| det = DetectorGroup(1, 10, 0.9, 0.1, ["spec_det1"]) | ||
| spec: Acquire[str, str, Never] = Acquire( | ||
| spec=Linspace("x", 0, 10, 10), fly=True, detectors=[det], stream_name="spec" |
There was a problem hiding this comment.
The numbers make my head hurt. Please could you redo the test with Linspace("x", 11, 20, 10)
| for p in w.positions(1, None): | ||
| assert len(p["x"]) == 10 | ||
| assert p["x"] == approx( | ||
| [ | ||
| -0.55555556, | ||
| 0.67901235, | ||
| 1.91358025, | ||
| 3.14814815, | ||
| 4.38271605, | ||
| 5.61728395, | ||
| 6.85185185, | ||
| 8.08641975, | ||
| 9.32098765, | ||
| 10.55555556, | ||
| ] | ||
| ) |
There was a problem hiding this comment.
Then I would expect this to have size 11, and be [0.5, ... 10.5] as we are returning bounds rather than midpoints
There was a problem hiding this comment.
I don't understand why this would be the expected behaviour. Currently all the method does is shift the first point to be the equivalent to the first lower bound and then move all the subsequent points based on that, but it does not increase the expected number of points to also include the last upper bound.
That should be an easy enough change to make though if that's the intended behaviour.
There was a problem hiding this comment.
This is the intended behaviour. The Spec should say "I want 10 points, each is 1s long". The positions function is asked "Give me points every 1s. That means it gets 11 points, from lower bound of the first point to upper bound of the last point. If it doesn't do this then we should modify it so it does.
There was a problem hiding this comment.
Okay, I'll push the changes that implement this logic.
* Changed setpoints method in the LinearSource class so that both the first lower bound and the last upper bound are returned.
While testing ScanSpecV2 I noticed that if trying to create an
Acquirespec withfly=trueand then tried making this into a scan and parsing the windows the positional values returned by the windows would be out of the expected boundaries of my motion spec. I believe this is to do with how theLinearSourceis defined where we have it use the original length passed to it to define the step size, independent of the size of the index passed insetpoints.This PR tries to address this by changing the way the step size is calculated and by adding some Unit tests to it.
Here's an example of the code I used to tests and find the initial problem: