BCDA-APS / gemviz

Data visualization for tiled
https://bcda-aps.github.io/gemviz/
Other
4 stars 0 forks source link

can we use BestEffortCallback to plot a run? #111

Closed prjemian closed 1 year ago

prjemian commented 1 year ago

@rodolakis asks:

Why can't we use the (bluesky) BestEffortCallback to choose data from a run and plot it?

Originally posted by @prjemian in https://github.com/BCDA-APS/gemviz/issues/50#issuecomment-1665850096

prjemian commented 1 year ago

It is worth investigating and documenting the answer here.

A big difference is that BEC expects a document stream (start, descriptor, event, event, ... stop). The tiled server does not deliver a stream of data events. Rather, it processes such streams and delivers xarray structures for the data of each stream. We could explore the techniques used in BEC to identify the default plottable data (NeXus wants this also) and also how to generate the appropriate type of plot.

prjemian commented 1 year ago

The BEC source code: https://github.com/bluesky/bluesky/blob/master/bluesky/callbacks/best_effort.py

prjemian commented 1 year ago

Since the BEC code expects a document stream, it cannot be re-used here. I will examine the BEC code and document how it determines the plottable data. Overall, the code refines a set of initial guesses. The plottable data is assumed to be in the stream named "primary". The first guess starts with motors:

        motors = self._start_doc.get('motors')
        if motors is not None:
            GUESS = [([motor], 'primary') for motor in motors]
        else:
            GUESS = [(['time'], 'primary')]
prjemian commented 1 year ago
        # for each dimension, choose one field only
        # the plan can supply a list of fields. It's assumed the first
        # of the list is always the one plotted against
prjemian commented 1 year ago

How does BEC discover how to plot a raster image, such as grid_scan?

prjemian commented 1 year ago

Gridding is determined by some code, starting with hints["gridding"]:

            elif ndims == 2:
                # Decide whether to use LiveGrid or LiveScatter. LiveScatter is the
                # safer one to use, so it is the fallback..
                gridding = self._start_doc.get('hints', {}).get('gridding')
                if gridding == 'rectilinear':
prjemian commented 1 year ago

The first job is to identify what is an axis and signal. The NeXus terminology is clear here:

prjemian commented 1 year ago

BEC:

rank plot style
1D LivePlotPlusPeaks (one for each column that is not a dimension)
2D LiveGrid if gridding == 'rectilinear'
2D LiveScatter (fallback)
3D not handled by BEC
4D not handled by BEC
prjemian commented 1 year ago

Question is answered.