Refactor wrapped scan plans so they more user friendly - #2050
Refactor wrapped scan plans so they more user friendly#2050oliwenmandiamond wants to merge 57 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2050 +/- ##
=======================================
Coverage 99.28% 99.28%
=======================================
Files 366 370 +4
Lines 14367 14397 +30
=======================================
+ Hits 14264 14294 +30
Misses 103 103 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
EmsArnold
left a comment
There was a problem hiding this comment.
A few comments, but hopefully nothing too onerous. I would like to try it on test rig or similar if it hasn't been tested there yet.
…/DiamondLightSource/dodal into refactor_scans_so_they_are_flatter
…*args requirements
…/DiamondLightSource/dodal into refactor_scans_so_they_are_flatter
| Examples: | ||
| Scan one motor from 0 to 10 using 11 points:: | ||
|
|
||
| num_grid_scan([detector], (x_motor, 0, 10, 11)) |
There was a problem hiding this comment.
Though it's possible to use the different gird_scan plans for scanning one motor, is this something we want to be advertising/promoting? In my mind, grid_scans should only be used for scanning in 2 or more dimensions, but happy to be told differently if there's a use case I'm missing.
There was a problem hiding this comment.
It is perfectly valid, though you get the most functionality if you use more than one motor. I personally don't think we should be blocking the use of one motor though if bluesky plans themselves are perfectly okay with handling it.
The doc string of bp.grid_scan is
(function) def grid_scan(
detectors: Sequence[Readable[Unknown]],
*args: Unknown,
snake_axes: Iterable[Unknown] | bool | None = None,
per_step: PerStep | None = None,
md: CustomPlanMetadata | None = None
) -> MsgGenerator[str]
Scan over a mesh; each motor is on an independent trajectory.
Parameters
detectors : list or tuple
list of 'readable' objects
*args
patterned like (motor1, start1, stop1, num1, motor2, start2, stop2, num2, motor3, start3, stop3, num3, ... motorN, startN, stopN, numN)
The first motor is the "slowest", the outer loop. For all motors except the first motor, there is a "snake" argument: a boolean indicating whether to following snake-like, winding trajectory or a simple left-to-right trajectory.
snake_axes : boolean or iterable, optional
which axes should be snaked, either False (do not snake any axes), True (snake all axes) or a list of axes to snake. "Snaking" an axis is defined as following snake-like, winding trajectory instead of a simple left-to-right trajectory. The elements of the list are motors that are listed in args. The list must not contain the slowest (first) motor, since it can't be snaked.
per_step : callable, optional
hook for customizing action of inner loop (messages per step). See docstring of bluesky.plan_stubs.one_nd_step (the default) for details.
md : dict, optional
metadata
See Also
bluesky.plans.rel_grid_scan bluesky.plans.inner_product_scan bluesky.plans.scan_nd
There was a problem hiding this comment.
I agree there's no reason to block it, but I'm not sure we need to put a one-motor example within the docstring for scans intended for indepentent trajectories.
From the bluesky plan docstring(s) it looks like the pattern for example concurrent scans (scan, list_scan) is one axis and then n axes, while independent scans (grid_scan, etc.) is only for n axes. I would lean toward keeping this format here.
|
In principle, I think the refactor is good. I think the move to supplying parameters as sets of trajectories makes the plans more user friendly. I think the grouping into trajectories is a good compromise between an un-typed list of all *args and minimisation of brackets which the original wrapping used. That being said, until this is handled in blueAPI, relying on I haven't made up my mind whether I prefer the pattern of It would be worth updating the description now (or in the near future if there are changes coming) to capture the current syntax to accomplish a 1D and nD scan. |
Yes, I will try and pin down a timeline with core team on when *args will be fixed and way up worth waiting for that for this to be merged or force us not use *args as the wait is too long.
I opted for Specific scans such as step_scan also require different arguements for the primary trajectory and all extra ones. The primary is
I'm not sure what you mean here, isn't this the point of clearly static type checking the plan with documentation and examples so they will notice and understand the difference between the two different types of scan? One takes num as argument and the other gives it the primary trajectory.
Yes I will update the description shortly! |
Sorry, this was poorly articulated on my part! For scans which take the same type for the initial trajectory and any subsequent trajectories, users shouldn't care about the differences between the first trajectory and any further trajectories (within that singular scan type). They should still care deeply about the differences between concurrent vs independent nD scans, and step vs list vs num scans. My comment about users noticing the difference between scan types comes more from a science-driven perspective. For example, if you're interested in determining resolution you'll always need to know your step size - and thus will likely want to define your scan based on step size. Conversely if you always want a constant number of steps (for example if you're rotating around an arc or full circle), you may never think about step size. From my experience, users will be unlikely to use both From an end-user point of view, I question why I should care about the difference between |
This change aims to make the scan syntax much more user friendly. Some examples are show below:
Old syntax
New syntax
This assumes BlueAPI supports *args
For demo using with BlueAPI client, please see DiamondLightSource/blueapi#1662
Instructions to reviewer on how to test:
Checks for reviewer
dodal connect ${BEAMLINE}