This is for the pyjoulescope_ui python code. Is there a way to access the channel data from _x_dual_marker_text, or alternately can I add code to where the statistics used for the dual markers are calculated? I think that some context may be helpful, so:
I’d like to add some quantities like the overall rate of change (start to end) and maybe an asymptote which would be useful when working with storage elements like batteries.
In quantities.py, I see that quantities can be added.
in waveform_widget.py I see the quantities put into “values” in _draw_plot_statistics and _x_dual_marker_text.
If I add a new field to those with dummy data then launch and use the UI settings->Widgets->Waveforms->Waveforms to add the new quantity, I see the field and dummy data in the UI.
In _draw_plot_statistics the x and y data can be accessed so I can do the calculations I’m looking for there.
In _draw_plot_statistics it looks like what’s passed to it has already had the statistics calculated, but I don’t see where (I do see that it is passed through on_callback_response). I also don’t see a straightforward way to access the data within the marker from within _x_dual_marker_text which could be an option, but calculating once per marker generation would be lower overhead.
Hi @Jeremy - The statistics are calculated in the C part of the code using some significant optimizations. Both the sample streaming buffer and the JLS file reader use an optimization that stores zoomed out versions of the data. The statistics are pre-computed over these zoomed out views. When a dual marker requests statistics, it uses the “best” combination of zoomed out views and samples to make this super fast. Performing raw calculations over each sample can take a long time.
Would adding an “analysis” tool work for you? Just like the other analysis tools, you right click on one of the dual markers and then select Analysis. Unlike statistics, the analysis tools have a well-defined API that extends RangeToolBase
. The code includes good examples. You can even implement your custom range tool as a plugin if you want.
Your range tool can iterate over all samples to compute whatever quantities your want. One method is to open a pop-up dialog that displays results.
1 Like
Hi Matt,
Thanks for the explanation! I’m surprised more is not in C, but having so much in python is useful. Speed is indeed a concern especially if trying to run a fit to an offset exponential, but it seems worth experimenting with and for markers should only need to be run once per marker.
I think adding an analysis tool would work. I’ll look at the plugin if I want to port it to machines to run from the normal UI.
1 Like