Skip to content

Master-side online analyses for scans #389

@dnadlinger

Description

@dnadlinger

As it says in the title: It would be useful to be able to run online analyses (i.e. while the scan is running) also master-side with custom code rather than just the pre-defined fits in the applets.

This came out of a discussion on how to show randomised benchmarking (RBM) data as it comes in. ABaQuS (one of the Oxford experiments) currently have a local patch that (if I understand correctly) allows running an arbitrary callback after points have been completed, which they use to directly update some datasets to show a preliminary fit while the scan is still in progress. It would obviously be nicer to do this is in a way better integrated with the rest of ndscan. But of course, we already have the concept of online analysis execution in ndscan, so let's just extend this to be able to run with custom code master-side as well!

People (such as @hartytp) have been wanting custom online analyses for a while anyway. The OI implementation appears to allow the experiment to just specify a Python class to run on the client, with the actual implementation still being executed on the client. This works, but has the disadvantage of having to keep the code in sync. (They seem to be using this only to plug in the ionics_fits library, which is fairly static, presumably somewhat circumventing this issue.) just serialises the entire code and ships that to the applets. Our approach would be an alternative to that.

In summary:

  • The basic idea is that the (sub)scan runner gains support to execute the online part of default analyses during the scan.
  • This is done on the master, presumably as a background process to avoid slowing down experimental progress (similar to how applets currently execute online fits as new points come in).
    • The subscan can re-use the same analysis for both "live" and "default analysis" phases. This could be automatically handled by ndscan as an option.
  • Both for top-level scans and for subscans that have the "preview" enabled, the respective scan runner loop updates the analysis_results datasets (and plot annotations) as new points keep coming in.
    • This doesn't require any concept of "pushing point previews" to result channels, as the mutability only happens at the top level analysis_results (and as such doesn't run up against the ndscan "functional" execution model, or doesn't have any problems with jagged arrays for incomplete subscan points, etc.).
  • We'll need to make sure the applet handles changing analysis results.
    • Currently, the code might make the assumption that non-online analysis results only arrive once at the end – check!

At this point, we should be able to e.g. implement the Lorentzian online fit to a fluorescence scan as a custom online analysis rather than client side OnlineFit without much of a visible difference.


@JammyL This is part 2 of the RBM live analysis discussion we had on 2023-05-05 (part 1 being off-to-the-side previews for subscans).

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-appletInvolves the ndscan plot appletsA-experimentInvolves the experiment-side codeC-new-featureThis is a request for major new functionality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions