Recent

Author Topic: Peak detection in TAChart ?  (Read 149 times)

AL

  • New Member
  • *
  • Posts: 12
Peak detection in TAChart ?
« on: November 14, 2019, 07:23:21 pm »
Is there a way to detect peaks with TAChart in a TlineSeries?

Thanks,

Al
« Last Edit: November 14, 2019, 07:30:07 pm by AL »

Thaddy

  • Hero Member
  • *****
  • Posts: 9273
Re: Peak detection in TAChart
« Reply #1 on: November 14, 2019, 07:31:21 pm »
You should not misuse the TaChart for that:TaChart is the presentation layer, not the compute layer.
 You should detect peaks in the data before you display it. And that is a simple max run.
« Last Edit: November 14, 2019, 07:37:22 pm by Thaddy »
also related to equus asinus.

wp

  • Hero Member
  • *****
  • Posts: 6444
Re: Peak detection in TAChart ?
« Reply #2 on: November 14, 2019, 07:56:31 pm »
No automatic peak detection, I agree with Thaddy.

There is a manual interactive peak detection with some limitations, though. Look at example "distancedemo" in folder "demo/distance" of your Lazarus installation, page "Fit": Select "Find peak" in the "Measure" box, then, holding the RIGHT mouse button down, drag from the somewhere below the peak to somewhere after the peak. The routine will fit a parabola to the data in the range spanned by the mouse range and display y and y value of the parabola's extremum.

Note, however, that this does not separate overlapping peaks or subtract a varying background. Therefore, the peak producing the shoulder near x=6 is reported at an incorrect value (7.75, but from the construction of the curve it should be at 2*pi = 6.28; finding the correct value requires more effort).
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

AL

  • New Member
  • *
  • Posts: 12
Re: Peak detection in TAChart
« Reply #3 on: November 14, 2019, 08:51:32 pm »
WP:  Thanks for pointing that demo.  This is interesting, I will study that.

You should not misuse the TaChart for that:TaChart is the presentation layer, not the compute layer.
 You should detect peaks in the data before you display it. And that is a simple max run.
This is what I tought, but I wanted to ask, just in case.  This package is so good, you never know.
At the moment, this is what I do, looking for max ( up to 3 peaks), but I need something a little fancier.

Thank you both for your quick answers