sardana-org / sardana

Moved to GitLab: https://gitlab.com/sardana-org/sardana
39 stars 52 forks source link

access the trend window from a macro #889

Open dschick opened 6 years ago

dschick commented 6 years ago

Hej all,

I would like to draw a simple vertical line into the trend window using a macro. The macro should indicate the current position of the motor of the last scan.

Is this possible from Sardana via the taurus API?

reszelaz commented 6 years ago

It sounds very attactive. But I'm affraid that currently it is not possible and won't be easy to implement.

We could implement something similar to Macro Plotting. If I remember correctly this works in the following way: when a macro requests to plot, this request is sent with a Tango event to the client which does the plotting on the client machine.

But first we need to overcome this TODO which is explained with more details in #166.

dschick commented 6 years ago

Okay, so macroplotting would then just replot the current data in the trend window, which would require to store that data always until the next scan happens. And in addition to the data a horizontal line is plotted where the scan motor is or was.

I guess using matplotlib this is quite esay, despite of the fact, that the scan data needs to be stored for all counters. This would then also be questionable if one wants to store the statistics or the scan data in the env, see discussion in #290. In the later case, the stats are only calculated on demand and not always.

dschick commented 4 years ago

I am just wondering if plotting extra data (lines) in the showscan online window could be implemented with the newtaurus_pyqtgraph backend?

reszelaz commented 3 years ago

I just came accross this issue again. I think it won't be actually so difficult. Let's forget about the previous approach explained by me earlier.

In the showscan we receive the RecordData events. One option would be to use this attribute and pass the stats after the record_end data. The stats are calculated in the post-scan hook. Not sure where and how exactly we could make this push event there in the GScan - this will require further investigation.

Another option is to listen in the showscan also to the environment events. Then filter only the ScanStats events.

@tiagocoutinho how difficult would be then to plot the ~horizontal~ vertical line in the pyqtgraph?

dschick commented 3 years ago

Hi @reszelaz , thanks for remembering it! I was actually asking to plot vertical lines in the pyqtgraph in order to visualize the position of the motor of the last scan, when you type where or show the new position after doing the pic or cen macros. This saves a lot of time when aligning your experment as you do not have to read the values by hand.

So in this scenario you could always throw an event whithin these three macros.

I guess it might clutter the plot a bit, if you always plot the statistics as lines in the graph for all plotted counters, or what do you have in mind?

reszelaz commented 3 years ago

I read it too fast and wrote too fast as well:) Of course here we are talking about the vertical lines.

I though about automatic plotting after executing the scanstats macro (here plotting a line at the current position of the motor does not have too much sense). But you though about plotting on demand, right? So, the trigger for plotting would be the where macro. And all three lines should be plotted at the same time?

Thanks!

dschick commented 3 years ago

I was also a bit too quick:

so the general requirement would be to plot a vertical line at any position using a macor on demand.

The ESRF SPEC macros are working such, that where simple shows the current position of the motor that was involved in the scan. pic and cen first move to the peak or CoM positions and then show again the current position of the motor in the last plot.