Forums

Measuring Peak Value

Started by Wolfgang September 7, 2004
Dear all,

I've a stream of sampled values which were filtered and downsampled.
I'm interested in the (exact) maximum value of an incomming peak.
Is there a simpler way of finding that peak value instead of upsampling 
and searching the greatest value ?
(The frequency content of the peak reaches half of the sampling rate,
hence i've not a lot values around the maximum without resampling with a higher frequency.)

                            All suggestions are wellcome.
                                                                                Wolfgang



"Wolfgang" <never@nowhere.com> wrote 

> I've a stream of sampled values which were filtered and downsampled. > I'm interested in the (exact) maximum value of an incomming peak. > Is there a simpler way of finding that peak value instead of upsampling > and searching the greatest value ? > (The frequency content of the peak reaches half of the sampling rate, > hence i've not a lot values around the maximum without resampling with > a higher frequency.)
Wolfgang, One way to approach this problem is to fit the peak, and one sample either side of the peak, to a parabola and then solve for the position of the peak of the parabola. Depending on the shape of your peak, this may or may not be an accurate way to do things. Ciao, Peter K.
"Wolfgang" <never@nowhere.com> wrote in message
news:chkoiv$6kl$05$1@news.t-online.com...
> Dear all, > > I've a stream of sampled values which were filtered and downsampled. > I'm interested in the (exact) maximum value of an incomming peak. > Is there a simpler way of finding that peak value instead of upsampling > and searching the greatest value ? > (The frequency content of the peak reaches half of the sampling rate, > hence i've not a lot values around the maximum without resampling with a
higher frequency.) Wolfgang, If the frequency content of the peak indeed reaches half the sampling rate, then it's undersampled. Sampling must be higher than 2x ..... I take it you mean you want the peak value of the signal before sampling. Is that right? If so, you need to interpolate / reconstruct the data in the vicinity of apparent peaks in order to find the peak value. So, interpolation in regions may be easier than more general upsampling. I don't know how robust that might be - better for higher sample rates I should think. Fred
Hello Fred, 

> If the frequency content of the peak indeed reaches half the sampling rate, > then it's undersampled. Sampling must be higher than 2x .....
You're right. But it's not undersampled. Sampling is higher than 2x. I only want to point out that the peak is not "sampled well" (not a lot points around).
> I take it you mean you want the peak value of the signal before sampling. > Is that right?
Yes it is. The exact problem is that I've peaks with sampled values on different places on the peak (phase relations between peak and sample frequency is not fixed). Now I've to distinguish between peaks depending on the "original" hight. Unfortunately the shape of the peak is not fixed.
> If so, you need to interpolate / reconstruct the data in the vicinity of > apparent peaks in order to find the peak value. So, interpolation in > regions may be easier than more general upsampling. I don't know how robust > that might be - better for higher sample rates I should think.
Yes thats exactly what I was looking for. I was wondering if there is an interpolation method giving me the EXACT value of the peak as I know that the frequency content of the signal is limited to half the sampling frequency. Hence sampled values represent the original signal in an exact way. Hence amplitude information is "hidden in" there. If I perform upsampling e.g. by a factor of 2 I reduce my error, so I can decide which error is o.k. and define the upsampling factor backwards. But I thought it's stupid to estimate a value which is given precisely. Thanks for your suggestions, Wolfgang
"Wolfgang" <never@nowhere.com> wrote in message news:<chkoiv$6kl$05$1@news.t-online.com>...
> Dear all, > > I've a stream of sampled values which were filtered and downsampled. > I'm interested in the (exact) maximum value of an incomming peak. > Is there a simpler way of finding that peak value instead of upsampling > and searching the greatest value ? > (The frequency content of the peak reaches half of the sampling rate, > hence i've not a lot values around the maximum without resampling with a higher frequency.) > > All suggestions are wellcome. > Wolfgang
Sounds like an under-determined problem. If you expect the peak to be between two samples, you probably sample at a too low frequency. If you are looking for finer time localization of the peak than the sample interval, you might be able to achieve this by means of cross spectra, but that requires additional knowledge of the waveform you are looking for. It's usually better to first determine what a system will be used for, and then design it, than vice versa. Rune
Wolfgang wrote:

> Hello Fred, > > >>If the frequency content of the peak indeed reaches half the sampling rate, >>then it's undersampled. Sampling must be higher than 2x ..... > > > You're right. But it's not undersampled. Sampling is higher than 2x. I only want to > point out that the peak is not "sampled well" (not a lot points around). > > >>I take it you mean you want the peak value of the signal before sampling. >>Is that right? > > > Yes it is. The exact problem is that I've peaks with sampled values > on different places on the peak (phase relations between peak and sample frequency > is not fixed). Now I've to distinguish between peaks depending on the "original" hight. > Unfortunately the shape of the peak is not fixed. > > >>If so, you need to interpolate / reconstruct the data in the vicinity of >>apparent peaks in order to find the peak value. So, interpolation in >>regions may be easier than more general upsampling. I don't know how robust >>that might be - better for higher sample rates I should think. > > > Yes thats exactly what I was looking for. I was wondering if there is an interpolation method > giving me the EXACT value of the peak as I know that the frequency content of the signal > is limited to half the sampling frequency. Hence sampled values represent the original signal > in an exact way. Hence amplitude information is "hidden in" there. > If I perform upsampling e.g. by a factor of 2 I reduce my error, so I can decide which > error is o.k. and define the upsampling factor backwards. But I thought it's stupid to > estimate a value which is given precisely. > > Thanks for your suggestions, Wolfgang
Assuming that there is no significant aliasing -- a shaky assumption if the sampling frequency is as low as you suggest -- the peak of the reconstructed signal will be the same as the peak of the sampled signal. Upsampling is one way to approximate the reconstruction. A DAC and filter is another (think of it as an analog computer!). Maybe there's a third way; I don't know. Whatever method you use, it is needed only in the vicinity of the peaks you need to measure. Jerry -- Engineering is the art of making what you want from things you can get. &#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;
"Wolfgang" <never@nowhere.com> wrote in message
news:chkoiv$6kl$05$1@news.t-online.com...
> Dear all, > > I've a stream of sampled values which were filtered and downsampled. > I'm interested in the (exact) maximum value of an incomming peak. > Is there a simpler way of finding that peak value instead of upsampling > and searching the greatest value ? > (The frequency content of the peak reaches half of the sampling rate, > hence i've not a lot values around the maximum without resampling with a
higher frequency.)
> > All suggestions are wellcome. >
Wolfgang
> > >
Hello Wolfgang, This is not the simplest method in terms of computation, but it will yield a very precise result. http://personal.atl.bellsouth.net/p/h/physics/dspintrp.pdf IHTH, Clay S. Turner
"Wolfgang" <never@nowhere.com> wrote in message
news:chm95h$hso$07$1@news.t-online.com...
> Hello Fred, > > > If the frequency content of the peak indeed reaches half the sampling
rate,
> > then it's undersampled. Sampling must be higher than 2x ..... > > You're right. But it's not undersampled. Sampling is higher than 2x. I
only want to
> point out that the peak is not "sampled well" (not a lot points around). > > > I take it you mean you want the peak value of the signal before
sampling.
> > Is that right? > > Yes it is. The exact problem is that I've peaks with sampled values > on different places on the peak (phase relations between peak and sample
frequency
> is not fixed). Now I've to distinguish between peaks depending on the
"original" hight.
> Unfortunately the shape of the peak is not fixed. > > > If so, you need to interpolate / reconstruct the data in the vicinity of > > apparent peaks in order to find the peak value. So, interpolation in > > regions may be easier than more general upsampling. I don't know how
robust
> > that might be - better for higher sample rates I should think. > > Yes thats exactly what I was looking for. I was wondering if there is an
interpolation method
> giving me the EXACT value of the peak as I know that the frequency content
of the signal
> is limited to half the sampling frequency. Hence sampled values represent
the original signal
> in an exact way. Hence amplitude information is "hidden in" there. > If I perform upsampling e.g. by a factor of 2 I reduce my error, so I can
decide which
> error is o.k. and define the upsampling factor backwards. But I thought
it's stupid to
> estimate a value which is given precisely.
Wolfgang, OK - well this gives the opportunity to ponder what might be possible and what's going on here: Let's assume that you do an ideal reconstruction. Let's assume that you will reconstruct by convolving with a sinc function - which, of course, has infinite extent. You choose the sinc function to have zero crossings at the sample interval so there is only one non-zero sinc per sample. To make this practical, you actually use a time-limited sinc with samples from -N to +N. To make this practical, you don't do a full convolution. What you do is add up all the sinc contributions in the range of a peak. By "all" I mean sincs weighted by +/-M samples around the peak. This is a very brute force method of interpolation. Of course, if the zero crossing intervals aren't the same as the sample interval then the sum becomes much more laborious to compute. With some experimentation you can increase M until you get diminishing returns. With some experimentation you can increase N until you get diminshing returns. I like this approach because it's immediately clear what changes occur in the peak of interest. Once you know the parameters N and M, you might then use a different method for computation noting that time domain convolution can be had via frequency domain multiplication. You might also window the sinc without disturbing the zero crossing interval. Or, you may not care about the zero crossing interval if you're doing the computations in the frequency domain. Windowing the sinc is equivalent to convolving the frequency domain by the sinc-like transform of the window - so that will cause some spreading in frequency but probably not have much affect on the peaks. Not as elegant as other methods but it sounds like you need to develop some confidence in the method and this would do it for me. It's interesting to note that the peak values you compute are being defined in diminishing amounts by: first: the nearest two samples and more the nearest sample. second: the sidelobes of the sincs from the next nearest samples and so forth. Eventually you are adding smaller and smaller "tails" of the sincs from further separated samples - that's easy enough to visualize and to ponder how much they should matter! Because of this, you might consider using the IFFT of a triangular shaped lo wpass which will give you a "sinc"-like time function that tapers as 1/t^3 in the tails. That may be more suitable but won't emphasize the high frequency content as much - which may be important in your peak calculation. This says that high frequency detailed content in the peaks is contained in the tails of the sincs - removed from the peak itself - which seems a bit strange. I've not thought about it further .... Fred
Jerry Avins <jya@ieee.org> wrote in message news:<413f08aa$0$6931$61fed72c@news.rcn.com>...
> Assuming that there is no significant aliasing -- a shaky assumption if > the sampling frequency is as low as you suggest -- the peak of the > reconstructed signal will be the same as the peak of the sampled signal.
I'm afraid that this is not quite true. "Analog" peak levels can go as high as +6 dB beyond digital sample values for some (strange) signals. So this requires that we scan through all the regions in the digital signal where digital values are within -6...0 dB of the peak digital value. Still it makes sense to scan only through these regions using bandlimited interpolation (referenced in some of previous posts). Best regards, Alex
Wolfgang wrote:

> Dear all, > > I've a stream of sampled values which were filtered and > downsampled. I'm interested in the (exact) maximum value of an > incomming peak. Is there a simpler way of finding that peak value > instead of upsampling and searching the greatest value ? > (The frequency content of the peak reaches half of the sampling > rate, hence i've not a lot values around the maximum without > resampling with a higher frequency.) > > All suggestions are wellcome. >
Wolfgang Hi Wolfgang, This is a receipt from a practical application: 1) with traditional sampling (no tricks, constant sampling distance), the maximum frequency which doesn't force aliasing, is half of the sampling frequency Fs, and this can only be a sine function, which doesn't change neither frequency nor amplitude, because otherwise it would have higher frequency component. 2) If such a high frequency peak (almost at Fs/2) occurs, it must look almost like the peak of a sine (because higher frequency components are not allowed). The only trouble is if your samples aren't taken at the maximum point. In worst case the samples are around the zero crossings. 3) Given what I discussed in 2), the task can be reduced to find the maximum value of a sine, defined by few points on the shape. Since the function of the signal is reduced to be almost exactly f(t)=a*sin(wt), which has three variables, you need at least 3 points (samples) to get it defined. 4) I'd use the derivate to get further information: f'(t)=aw*cos(wt) This function has zero crossings where the maximum and minimum values of the sine are located. 5) Calculate the slope between every two consequent samples (around where the peak is assumed). If you find two consequent slopes where first is positive and next is negative, you know a maximum is between (this means around the middle of the three points). 6) Interpolate between both slopes (which are related to the center between both samples. The time point where this interpolation crosses zero, is the time location of the maximum. 7) Interpolate between the left and middle sample to calculate the value at the maximum from 6) 8) Do the same with middle and right sample. 9) Take the average between result from 7) and 8) and you have a good estimation for the maximum. (I'm sure you could get a closer estimation just by applying some fundamental trigonometric calculations) I guess that this receipt works quite well, because I used it some time ago. Hopefully, I didn't forget something. Bernhard