facontidavide / PlotJuggler

The Time Series Visualization Tool that you deserve.
https://www.plotjuggler.io
Mozilla Public License 2.0
4.35k stars 608 forks source link

[Feature Request] Use Filtered Data as a new Timeseries #511

Open Bartimaeus- opened 3 years ago

Bartimaeus- commented 3 years ago

It would be nice to be able to treat filtered data as a new timeseries that could be used for the following: -Input to custom time series (apply a filter and then run it through a custom function). You could also do [custom series->apply filter->use as input to another custom series] -Apply multiple filters sequentially to data (ex: apply a scale and then a moving average)

The main things that I am running into right now is the need to scale data to match units. I have custom functions that I want to apply to different datasets and sometimes data is given as milliVolts or Volts, milliAmps or Amps, etc. and I'd like to calculate power as well as watthours, and scaling the data as an input so the units all match simplifies the reuse of functions

The other main use case I have for this is applying a moving RMS filter to the data and then running it through a custom function so you can calculate the max RMS power for a given duration in a dataset. (apply moving RMS filter, then put it through a custom function to get the max value)

Treating them as a new time series would also have the benefit of being able to view the filtered values in the left hand column, but that seems a much lower priority image

facontidavide commented 3 years ago

I think it is a good idea, but it will take time before I implemnt this

Bartimaeus- commented 2 years ago

I've implemented basic functionality for the feature:

https://user-images.githubusercontent.com/2954254/136670890-59b3b389-97ca-4c83-990b-f16c79124c7e.mp4

Some notes on the feature: -Curves are only copied if a transform has been applied -Curves that are hidden on the plot are not copied -There should be a better way to modify the TransformedTimeseries class -Names of the copies are the original series name with "_copy" added. Future change could be made to allow user customization of the name of the new series

The code can be found here, I can make a pull request if it looks good https://github.com/Bartimaeus-/PlotJuggler

facontidavide commented 2 years ago

The problem I see with your implementation is that the new curve is not saved in the Layout files.

To do it "right", I need a large refactoring of some internal class hierarchies.

Stay tuned.

Bartimaeus- commented 2 years ago

A limitation to the way I did it is that it only copies the contents from the plot into the new series and there is no dynamic link from the new series to the old one. Giving access to the built-in transformations within the custom series Lua scripts might be simpler and more powerful than simply copying the data from the plot into a new series. This essentially is what Excel does with the functions that are callable in custom formulas

Example workflow: image

Apply transformations: image

Output is a custom series with a call to the correct lua function (user could also use these functions however they want in a custom Lua script) image

facontidavide commented 2 years ago

The problem here (maybe a bad decision) is that those transforms are treated differently than the one generated with Lua.

The solution you propose is valid, but I think I can do better.

I want to do this change, but to make it "right" I need to think carefully :smile: