Recent

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

AL

  • Full Member
  • ***
  • Posts: 209
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 »
Laz 2.1.0, fpc 3.3.1, Win10
Laz 2.1.0, fpc 3.3.1, Mac OS Mojave running on VMWare
Laz 2.1.0  fpc 3.3.1 Ubuntu 20.04

Thaddy

  • Hero Member
  • *****
  • Posts: 10585
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 »

wp

  • Hero Member
  • *****
  • Posts: 7745
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).
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

AL

  • Full Member
  • ***
  • Posts: 209
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
Laz 2.1.0, fpc 3.3.1, Win10
Laz 2.1.0, fpc 3.3.1, Mac OS Mojave running on VMWare
Laz 2.1.0  fpc 3.3.1 Ubuntu 20.04

 

TinyPortal © 2005-2018