PDA

View Full Version : about filtering signal


Rex_chaos
10-08-2003, 03:47 PM
Hi,
I am using fft in DSP. However, I found that the alising is very
serious in my case. I am going to use a hamming window for smoothing.
However, my signal has a constanst background(the base is not zero).
The effect of hamming window will cut part of the background. Does
anyone know how to design a window for smoothing and can also keep the
background of signal constant?

Thanks in advance.

Jerry Avins
10-08-2003, 05:16 PM
Rex_chaos wrote:

> Hi,
> I am using fft in DSP. However, I found that the alising is very
> serious in my case. I am going to use a hamming window for smoothing.
> However, my signal has a constanst background(the base is not zero).
> The effect of hamming window will cut part of the background. Does
> anyone know how to design a window for smoothing and can also keep the
> background of signal constant?
>
> Thanks in advance.

Are you looking at the right problem? The FFT won't cause aliasing, but
it will reveal it if the data were originally undersampled. In general,
windows (Hamm or any other) achieve reduced sidelobe width by allowing a
broadened main lobe. They also reduce component frequencies' calculated
amplitudes by a constant for all frequencies. This amounts to a gain
change.

Jerry
--
"I view the progress of science as ... the slow erosion of the
tendency to dichotomize." Barbara Smuts, U. Mich.
ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ

Rex_chaos
10-09-2003, 03:18 AM
Jerry Avins <[email protected]> wrote in message news:<[email protected]>...
> Rex_chaos wrote:
>
> > Hi,
> > I am using fft in DSP. However, I found that the alising is very
> > serious in my case. I am going to use a hamming window for smoothing.
> > However, my signal has a constanst background(the base is not zero).
> > The effect of hamming window will cut part of the background. Does
> > anyone know how to design a window for smoothing and can also keep the
> > background of signal constant?
> >
> > Thanks in advance.
>
> Are you looking at the right problem? The FFT won't cause aliasing, but
> it will reveal it if the data were originally undersampled. In general,
> windows (Hamm or any other) achieve reduced sidelobe width by allowing a
> broadened main lobe. They also reduce component frequencies' calculated
> amplitudes by a constant for all frequencies. This amounts to a gain
> change.
>
> Jerry


Thanks. I think I misuderstand the concept of alising. I am talking
about the side effect caused by the periodic boundary condition of
fft. I am handling a signal with a constant energy background.
However, I found that there is a oscillating wave ocuured at the tail
of the signal and affect the head due to the periodic boundary
condition. A hamming window is used to lower the effect, it does work,
however, the constant energy background is also damaged. Besides
applying a window, is there any way to reduce the side effect and keep
the background at the same time?

Thanks in advance.

Jerry Avins
10-09-2003, 05:24 AM
Rex_chaos wrote:

> Jerry Avins <[email protected]> wrote in message news:<[email protected]>...
>
>>Rex_chaos wrote:
>>
>> > Hi,
>> > I am using fft in DSP. However, I found that the alising is very
>> > serious in my case. I am going to use a hamming window for smoothing.
>> > However, my signal has a constanst background(the base is not zero).
>> > The effect of hamming window will cut part of the background. Does
>> > anyone know how to design a window for smoothing and can also keep the
>> > background of signal constant?
>> >
>> > Thanks in advance.
>>
>>Are you looking at the right problem? The FFT won't cause aliasing, but
>>it will reveal it if the data were originally undersampled. In general,
>>windows (Hamm or any other) achieve reduced sidelobe width by allowing a
>>broadened main lobe. They also reduce component frequencies' calculated
>>amplitudes by a constant for all frequencies. This amounts to a gain
>>change.
>>
>>Jerry
>
>
>
> Thanks. I think I misuderstand the concept of alising. I am talking
> about the side effect caused by the periodic boundary condition of
> fft. I am handling a signal with a constant energy background.
> However, I found that there is a oscillating wave ocuured at the tail
> of the signal and affect the head due to the periodic boundary
> condition. A hamming window is used to lower the effect, it does work,
> however, the constant energy background is also damaged. Besides
> applying a window, is there any way to reduce the side effect and keep
> the background at the same time?
>
> Thanks in advance.

As far as aliasing goes, it was matter of words, not ideas. I'm clear
now. What do you mean by "damaged"? The apparent amplitudes of all
frequencies are reduced in proportion to the area under the window of
choice to a rectangular window (which is the same as no window at all).
It's easy to calculate that ratio and apply its inverse as a correction,
but for most applications, it doesn't matter.

Jerry
--
"I view the progress of science as ... the slow erosion of the
tendency to dichotomize." Barbara Smuts, U. Mich.
ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ

Jim Thomas
10-09-2003, 02:20 PM
Rex_chaos wrote:

> I am handling a signal with a constant energy background.
> However, I found that there is a oscillating wave ocuured at the tail
> of the signal and affect the head due to the periodic boundary
> condition. A hamming window is used to lower the effect, it does work,
> however, the constant energy background is also damaged.

What do you mean by "constant energy background"? Perhaps your signal
has a DC component?

> Besides applying a window, is there any way to reduce the side
> effect and keep the background at the same time?

The only other way I know of is to choose the size of the FFT such that
it matches the period of your input signal. In other words, if the
input signal has a period of 445 samples, use a 445 point FFT.

--
Jim Thomas Principal Applications Engineer Bittware, Inc
[email protected] http://www.bittware.com (703) 779-7770
Air conditioning may have destroyed the ozone layer - but it's been
worth it!

Rex_chaos
10-09-2003, 05:35 PM
> As far as aliasing goes, it was matter of words, not ideas. I'm clear
> now. What do you mean by "damaged"? The apparent amplitudes of all
> frequencies are reduced in proportion to the area under the window of
> choice to a rectangular window (which is the same as no window at all).
> It's easy to calculate that ratio and apply its inverse as a correction,
> but for most applications, it doesn't matter.
>
Thanks for reply. Actually, I am working with a so-called split-step
fourier method in my project. The evolution of the signal based on the
reorganization of the spectrum. In my case, the constant background,
on which the signal travels, is very vital. However, it is the
periodic boundary condition leads to some oscillating waves that force
the signal go into ruin quickly. Somebody suggests that a strong
absorber will be placed on the boundary. I tried but still no good, I
wonder if the constant background is unlikely to keep in discrete
space with finite-width spectrum. I also try a rectangular window to
filter the spectrum. However, it leads to another issue: a sharp drop.
Since I must take the numerical deriviate of the signal before
reorganization of the spectrum. Numerical deriviate of a signal with a
sharp drop will produce some unwanted data. It's annoying!!!

Jerry Avins
10-09-2003, 07:21 PM
Rex_chaos wrote:

>>As far as aliasing goes, it was matter of words, not ideas. I'm clear
>>now. What do you mean by "damaged"? The apparent amplitudes of all
>>frequencies are reduced in proportion to the area under the window of
>>choice to a rectangular window (which is the same as no window at all).
>>It's easy to calculate that ratio and apply its inverse as a correction,
>>but for most applications, it doesn't matter.
>>
>
> Thanks for reply. Actually, I am working with a so-called split-step
> fourier method in my project. The evolution of the signal based on the
> reorganization of the spectrum. In my case, the constant background,
> on which the signal travels, is very vital. However, it is the
> periodic boundary condition leads to some oscillating waves that force
> the signal go into ruin quickly. Somebody suggests that a strong
> absorber will be placed on the boundary. I tried but still no good, I
> wonder if the constant background is unlikely to keep in discrete
> space with finite-width spectrum. I also try a rectangular window to
> filter the spectrum. However, it leads to another issue: a sharp drop.
> Since I must take the numerical deriviate of the signal before
> reorganization of the spectrum. Numerical deriviate of a signal with a
> sharp drop will produce some unwanted data. It's annoying!!!

Are you looking at a single snapshot in time, or are you processing a
continuous stream? I don't know enough to comment intelligently, but I
can say that there's an important difference between how those cases
must be handled.

Jerry
--
Engineering is the art of making what you want from things you can get.
ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ

Rex_chaos
10-10-2003, 03:08 AM
Jim Thomas <[email protected]> wrote in message news:<[email protected]>...
> Rex_chaos wrote:
>
> > I am handling a signal with a constant energy background.
> > However, I found that there is a oscillating wave ocuured at the tail
> > of the signal and affect the head due to the periodic boundary
> > condition. A hamming window is used to lower the effect, it does work,
> > however, the constant energy background is also damaged.
>
> What do you mean by "constant energy background"? Perhaps your signal
> has a DC component?
Yes. A non-zero DC component.
>
> > Besides applying a window, is there any way to reduce the side
> > effect and keep the background at the same time?
>
> The only other way I know of is to choose the size of the FFT such that
> it matches the period of your input signal. In other words, if the
> input signal has a period of 445 samples, use a 445 point FFT.
I alreadly take the the period of samples and point of FFT to 2^N

Fred Marshall
10-10-2003, 02:07 PM
[email protected] (Rex_chaos) wrote in message news:<[email protected]>...
> Jerry Avins <[email protected]> wrote in message news:<[email protected]>...
> > Rex_chaos wrote:
> >
> > > Hi,
> > > I am using fft in DSP. However, I found that the alising is very
> > > serious in my case. I am going to use a hamming window for smoothing.
> > > However, my signal has a constanst background(the base is not zero).
> > > The effect of hamming window will cut part of the background. Does
> > > anyone know how to design a window for smoothing and can also keep the
> > > background of signal constant?
> > >
> > > Thanks in advance.
> >
> > Are you looking at the right problem? The FFT won't cause aliasing, but
> > it will reveal it if the data were originally undersampled. In general,
> > windows (Hamm or any other) achieve reduced sidelobe width by allowing a
> > broadened main lobe. They also reduce component frequencies' calculated
> > amplitudes by a constant for all frequencies. This amounts to a gain
> > change.
> >
> > Jerry
>
>
> Thanks. I think I misuderstand the concept of alising. I am talking
> about the side effect caused by the periodic boundary condition of
> fft. I am handling a signal with a constant energy background.
> However, I found that there is a oscillating wave ocuured at the tail
> of the signal and affect the head due to the periodic boundary
> condition. A hamming window is used to lower the effect, it does work,
> however, the constant energy background is also damaged. Besides
> applying a window, is there any way to reduce the side effect and keep
> the background at the same time?
>
> Thanks in advance.

The best you can do is to low pass filter the data before further
processing.
So, you could use a FIR lowpass filter in the time domain or, you could
apply a FIR lowpass filter in the frequency domain (by multiplying). In
the
time domain this is equivalent to convolving with a sinc-shaped impulse
response which will spread the data a bit but that should be all.

I think this is what you want to do rather than windowing in time - you
really want to "window" in frequency (lowpass filter). Then any
"background" should be reasonably retained if I understand what you
mean.....

Fred

Jim Thomas
10-10-2003, 02:52 PM
Rex_chaos wrote:
> Jim Thomas <[email protected]> wrote
>>The only other way I know of is to choose the size of the FFT such that
>>it matches the period of your input signal. In other words, if the
>>input signal has a period of 445 samples, use a 445 point FFT.
>
> I alreadly take the the period of samples and point of FFT to 2^N

Perhaps I didn't make myself clear. When I mentioned the "period" of
the input signal, I meant the amount of time it takes for the signal to
repeat itself. A 1KHz sine wave repeats itself once every millisecond -
it has a period of 1 ms.

Fourier observed that any periodic signal can be represented by summing
up a series of weighted harmonically-related sinusoids. The Fourier
Transform gives you those weights.

The FT assumes that its input is periodic, and that you are feeding it
one period. If you feed it 256 samples, it assumes that the time-domain
signal repeats itself every 256 samples. If those 256 samples do NOT
hold an integer number of periods, you get a discontinuity. This
discontinuity shows up as smearing in the frequency domain.

To see this, take a 256-point FFT of some signal. Then copy your input
samples into a 512 sample array twice (that is, x[n] = x[n+256] for
n=0-255). Then take a 512-point FFT. The 512-point FFT will have 2
periods, and every other output of the FFT should be zero (or close to
it). The non-zero outputs should be very close to what you got with the
256-point FFT. Look at those 512 points in the time domain, and note
the discontinuity between samples 255 and 256.

Windowing tapers the signal down near the edges, so that when it
repeats, there is no discontinuity.

--
Jim Thomas Principal Applications Engineer Bittware, Inc
[email protected] http://www.bittware.com (703) 779-7770
Sometimes experience is the only teacher that works - Mike Rosing

Rex_chaos
10-15-2003, 05:44 PM
> The best you can do is to low pass filter the data before further
> processing.
> So, you could use a FIR lowpass filter in the time domain or, you could
> apply a FIR lowpass filter in the frequency domain (by multiplying). In
> the
> time domain this is equivalent to convolving with a sinc-shaped impulse
> response which will spread the data a bit but that should be all.
>
> I think this is what you want to do rather than windowing in time - you
> really want to "window" in frequency (lowpass filter). Then any
> "background" should be reasonably retained if I understand what you
> mean.....
>
> Fred

Thanks Fred. I have a problem again now. I am trying to convole my
signal with a sinc impulse. However, the signal I am handling is a
complex one. I wonder if it is still correct to use such filter?

Rex_chaos
10-15-2003, 06:05 PM
> Perhaps I didn't make myself clear. When I mentioned the "period" of
> the input signal, I meant the amount of time it takes for the signal to
> repeat itself. A 1KHz sine wave repeats itself once every millisecond -
> it has a period of 1 ms.
I am clear now. But it still a problem. What I am handling is a
dynamic signal that is hard to tell a definite period.

> The FT assumes that its input is periodic, and that you are feeding it
> one period. If you feed it 256 samples, it assumes that the time-domain
> signal repeats itself every 256 samples. If those 256 samples do NOT
> hold an integer number of periods, you get a discontinuity. This
> discontinuity shows up as smearing in the frequency domain.
The number of samples is large enough so that we can treat it as a
singal with an infinite-long period, right? In my case, the spectrum
of the input signal is
localized (most part of the spectrum is zero).

> To see this, take a 256-point FFT of some signal. Then copy your input
> samples into a 512 sample array twice (that is, x[n] = x[n+256] for
> n=0-255). Then take a 512-point FFT. The 512-point FFT will have 2
> periods, and every other output of the FFT should be zero (or close to
> it). The non-zero outputs should be very close to what you got with the
> 256-point FFT. Look at those 512 points in the time domain, and note
> the discontinuity between samples 255 and 256.

I don't understand. I try this example and find that 256-point fft of
sin wave yields
/\ /\
/ \ / \
___/ \/ \___

while 512-fft yields

/\ /\
/ \ / \
___/ \__/ \___

So what do you mean by discontinuity here?

Jim Thomas
10-16-2003, 03:17 PM
Jim Thomas wrote:
>>To see this, take a 256-point FFT of some signal. Then copy your input
>>samples into a 512 sample array twice (that is, x[n] = x[n+256] for
>>n=0-255). Then take a 512-point FFT. The 512-point FFT will have 2
>>periods, and every other output of the FFT should be zero (or close to
>>it). The non-zero outputs should be very close to what you got with the
>>256-point FFT. Look at those 512 points in the time domain, and note
>>the discontinuity between samples 255 and 256.
Rex_chaos wrote:
>
>
> I don't understand. I try this example and find that 256-point fft of
> sin wave yields
> /\ /\
> / \ / \
> ___/ \/ \___
>
> while 512-fft yields
>
> /\ /\
> / \ / \
> ___/ \__/ \___
>
> So what do you mean by discontinuity here?

I meant the discontinuity in the time domain. Suppose 256 samples of
your time-domain data looks like this:

_ _
/ \ /
/ \ /
\_/

Now repeat it to get 512 samples:

_ _ _ _
/ \ / | / \ /
/ \ / |/ \ /
\_/ \_/

There is a discontinuity where the two 256-sample chunks are spliced
together. A 256-point FFT "imagines" that the 256 points you give it
are exactly one period of a periodic waveform. Two periods look just
like the second illustration. The frequecny smearing you see on the FFT
of un-windowed data comes from these discontinuities.

In the second signal, the fundamental frequency (1/512th of the sample
rate) has an amplitude of 0, as do all the even harmonics. If you take
the spectrum of the 256-sample chunk and insert zeroes between each
freq-domain sample, you will get the same spectrum as if you had taken
the FT of the 512-sample chunk - but in the 512-sample case, you can
"see" the discontinuity in the time domain.

Windowing smoothes out the discontinuity by tapering the signal down to
zero at both ends.

--
Jim Thomas Principal Applications Engineer Bittware, Inc
[email protected] http://www.bittware.com (703) 779-7770
Time flies like an arrow. And fruit flies like bananas.