02 – Análisis de Fourier
Transcripción
02 – Análisis de Fourier
02 – Análisis de Fourier Diego Andrés Alvarez Marín Profesor Asociado Universidad Nacional de Colombia Sede Manizales 1 Contenido Series de Fourier Transformada de Fourier Interpretación física Implementación en MATLAB Ventaneo Teorema del muestreo 2 Créditos Estas diapositivas están basadas en el excelente material presentado en www.blinkdagger.com y elaborado por Quan Quach. Gracias! 3 Sistema LTI (linear time invariant system) 4 Escalabilidad 5 Aditividad 6 Invarianza en el tiempo 7 Fidelidad sinusoidal Si la entrada a un sistema LTI es un sinusoide, la salida del mismo es otro sinusoide de la misma frecuencia y forma pero diferente amplitud y fase 8 Divide y conquista 9 http://www.dspguide.com/CH5.PDF 10 ● La lectura de un sensor es un voltaje que cambia en el tiempo y la cual se asocia a otro fenómeno físico. 11 Análisis de Fourier Aceleración del último piso de un edificio ante un terremoto. El espectro de Fourier permite ver cuales son las frecuencias de vibración del edificio. 12 http://research.opt.indiana.edu/Library/FourierBoo k/toc.html http://www.complextoreal.com/chapters/fft1.pdf 13 14 15 La transformada rápida de Fourier Fast Fourier Transform (FFT) El comando fft solo opera sobre los "y" no sobre los "t" 16 17 Usando el comando fft 18 19 The function outputs the correct frequency range and the transformed signal. It takes in as input the signal to be transformed, and the sampling rate. 20 As you can see, this plot is basically identical to what we would expect! We get peaks at both -4 Hz and +4 Hz, and the amplitude of the peaks are 1. 21 Como la señal y es real, el espectro es simétrico y solo necesito la mitad NOTA: usen esta función, no la de www.blinkdagger.com 22 23 The execution time of an FFT algorithm depends on the transform length. It is fastest when the transform length is a power of two, and almost as fast when the transform length has only small prime factors. It is typically slower for transform lengths that are prime or have large prime factors. Time differences, however, are reduced to insignificance by modern FFT algorithms such as those used in MATLAB. Adjusting the transform 24 length for efficiency is usually unnecessary in practice. Potencia de 2 http://www.complextoreal.com/chapters/fft1.pdf RECOMENDADO POR LOS LECTORES!!! http://www.dspguide.com/ch8.ht m 25 Uno obtendrá una única frecuencia en fo y la amplitud es correcta. 26 27 Zero padding (rellenado con ceros) Zero padding is básicamente concatenar al final del vector actual un vector de ceros antes de aplicar la FFT. Se hace por dos razones: 1. Los primeros algoritmos para calcular la FFT solo funcionaban con un 2^N de datos (este no es el caso con los algoritmos modernos). 2. Artificialmente mejora la resolución en el espectro de frecuencia. 28 A esta señal le haremos zero padding: 29 Se completa la señal con ceros hasta alcanzar 128, 256 y 512 puntos: 30 El comando fft de MATLAB hace zero-padding utilizando un segundo parámetro; el segundo argumento permite especificar cuantos puntos debe retornar el comando fft. Mire las líneas resaltadas en las siguientes funciones: 31 32 33 Ahora las funciones en acción: 34 35 Why Does My Output Look Like a Sinc? When we pad with zeros, we are effectively multiplying a rectangular box with the sinusoid in the time domain. In the frequency domain, this translates into convolving a sinc function with an impulse resulting in a sinc-like output! 36 As you can see, there are more sampled points as N gets larger, and it is easier to see the general shape of the spectrum. The larger your N is, the finer the sampling will be. If I keep on increasing the number of zeros, it will make my frequency spectrum more refined. So does this mean I can just zero-pad my signal and get a better FFT spectrum every time? Well, technically speaking, you get more frequency bins when you zero pad, so yes, you do get a higher resolution in the frequency domain. But the caveat is that there is no new information added when you zero-pad. When you increase the size of N, all you are really doing is interpolating the data to obtain more sample points. There is NO new information added when zero-padding is applied. The resolution has increased, but I repeat, THERE IS NO NEW INFORMATION ADDED! This might sound confusing and paradoxical, but it is a very important point. If you have the option to take more data, it is ALWAYS better to get more data than to zero pad. Zero-padding is NOT a substitute for taking more data! 37 38 39 In this example, we are going to use zero padding to help us distinguish between two peaks that would otherwise be difficult to distinguish. 40 41 Aquí el zero padding ayudó a distinguir los dos picos. Al hacerlo no se agregó más información. The information was always there, but it was “hidden” in a way. When we took the FFT of the signal without zero padding, the frequency bins were not fine enough to differentiate the two peaks. By the sampling theorem, as long as you sample a bandlimited signal under the Nyquist rate, you know everything you need to know to perfectly reconstruct the signal. Therefore, at that point, you’ve done the best you can do; you can zero-pad all you want to get more points at the output of your FFT, but you don’t get any new information, because you already have all the information there is on the continuous-time signal. Inherently, there is nothing wrong with zero-padding in itself. You just have to be careful in its application. Whenever I use the fft command, I tend to use an N that is 4 times larger than the amount of data points within my signal. Zero padding cannot hurt your FFT result. 42 Conclusion It is a common misconception that zero-padding adds more information. Zero padding adds NO NEW information. The perceived benefit of zero-padding is increased spectral resolution. You are getting better resolution, but the key is to realize that there is NO NEW information added from the zero-padding. Zero-padding is useful, but it should not be a substitute for taking larger data samples. If you had to choose between taking twice as much data, or to zero pad your data, the answer is to ALWAYS take more data. 43 Artículos recomendados: http://zone.ni.com/devzone/cda/tut/p/id/4880 http://www.ele.uri.edu/~hansenj/projects/ele436/fft .pdf http://cnx.org/content/m12032/latest / 44 Aliasing ● Ejemplos sonoros: – http://www.sic.rma.ac.be/~xne/el401/aliasing/ – http://allsignalprocessing.com/aliasing-of-signals-identity-theft-in-the-frequency-domain/ 45 Aliasing 46 Aliasing 47 Aliasing 48 Otros problemas de la DFT ● ● ● ● identificación de frecuencias cercanas con amplitudes similares identificación de frecuencia lejanas, una de gran amplitud y otra frecuencia de amplitud pequeña la frecuencia que se quiere identificar puede caer entre las FFT bins el spectral leakage causa "ruido" en el resto del espectro, el cual puede ocultar frecuencias de interés 49 Spectral leakage Leakage = indication of frequency content where is none 50 Spectral leakage Every time a window is applied to a signal (Window = none effectively applies a rectangular window to the signal), leakage occurs, that is, power from one spectral component leaks into the adjacent ones. Leakage from strong spectral components can result in hiding/masking of nearby weaker spectral components. Even strong spectral components can be affected by leakage. For example, two strong spectral components close to each other can appear as one due to leakage. 51 El spectral leakage se produce por: (o razones para usa una ventana) ● ● ● The beginning does not match the end of the data segment we are analyzing (esto no pasa con synchronous sampling) We virtually never have an integer number of periods of any cyclic information in the signal segment For aperiodic signals such as modulated signals the use of a window is highly recommended. The window will attenuate the signal at both ends of the signal segment processed to zero. This makes the signal apear periodic and reduces leakage. 52 Spectral leakage + windowing 53 Spectral leakage + windowing 54 Características espectrales deseables de una ventana Existe un trade-off entre ambas, por lo que debe escoger una u otra: ● ● Detection (amplitude accuracy): means detecting a desired signal in the presence of broadband noise (es decir que identifique con precisión la amplitud, y reduzca el leakage), especialmente cuando existen componentes frecuenciales de diferente amplitud. Frequency (or spectral) resolution: ability to distinguish spectral components of comparable strength that are close to each other... además que identifique dichas frecuencias con precisión. Se mejora usando segmentos de señal más largas (en caso que sea posible). 55 Windows Vale 0 en f=k*fs/N 56 Bin centered components A sine wave component of our signal is bin centered if it has an integer number of periods in the data segment being analyzed, which almost never happens without planning. We can develop a formula for testing if a sine wave signal component is bin centered as follows: Np = N*k/fs siendo Np un número entero fs/N = bin frequency spacing 57 For a bin centered signal, all windows yield the same peak amplitude reading and have excellent amplitude accuracy 58 For a bin noncentered signal, the Hann and Flat Top windows yield introduce less spectral leakage and have better amplitude accuracy than the uniform window. 59 In addition to causing amplitude accuracy errors, spectral leakage can obscure adjacent frequency peaks 60 61 62 Main lobe width Se mide a -3 dB y a -6 dB en FFT bins. Su ancho se relaciona con la frequency resolution: su habilidad para reconocer componentes de frecuencia muy cercanos (y frecuencias puntuales) aumenta a medida que el ancho del lóbulo disminuye. Sin embargo, a medida que el ancho del lóbulo disminuye, la energía de la ventana migra a los side lobes y por lo tanto aumenta el leakage y la imprecisión en el cálculo de la amplitud. 63 Peak side lobe level ● ● Se mide como la distancia al main lobe en dBs. A medida que aumenta dicha "distancia", el leakage disminuye (noise supression) y por lo tanto, se estima mejor la amplitud (increase of detection ability) de frecuencias débiles. 64 Side lobe roll-off rate ● ● Se mide en dB/octave o dB/decade Se desea que este número sea tan grande como sea posible. 65 Una buena ventana debe tener: ● small main lobe width ● large side lobe levels ● side lobes fall-off rapidly 66 67 68 Usar ventanas periódicas para DTF 69 Usar ventanas periódicas para DTF Window functions generated for digital filter design are symmetrical sequences, usually an odd length with a single maximum at the center. Windows for DFT/FFT usage, such as in spectral analysis, are often created by deleting the right-most coefficient of an oddlength, symmetrical window. Such truncated sequences are known as periodic. The deleted coefficient is effectively restored (by a virtual copy of the symmetrical left-most coefficient) when the truncated sequence is periodically extended. The advantage of this trick is that a 512 length window (for example) enjoys the slightly better performance metrics of a 513 length design. Such a window is generated by the MATLAB function hann(512,'periodic'), for instance. To generate it, the window length (N) is 513, and the 513th coefficient of the generated sequence is discarded. 70 Rectangular window ● ● It has the largest amount of spectral leakage. It is useful for analyzing transients that have a duration shorter than that of the window. Transients are signals that exist only for a short time duration. 71 Hanning window ● ● Es la ventana “por defecto”. Se usa en el 95% de los casos. It is useful for analyzing transients longer than the time duration of the window and for general-purpose applications. 72 73 Kaiser-Bessel window ● ● ● It is a flexible smoothing window whose shape you can modify by adjusting the beta input. Thus, depending on the application, you can change the shape of the window to control the amount of spectral leakage. It is useful for detecting two signals of almost the same frequency but with significantly different amplitudes. Choosing this window often reveals signals close to the noise floor. 74 Barlett (triangle) window 75 Flat top window ● ● ● ● It has the best amplitude accuracy of all the smoothing windows at ±0.02 dB for signals exactly between integral cycles = good detection. Because it has a wide main lobe, it has poor frequency resolution = emplea muchos frequency bins para identificarla. It is most useful in accurately measuring the amplitude of single frequency components with little nearby spectral energy in the signal. The flat top window is sinusoidal as well, but it actually crosses the zero line. This causes a much broader peak in the frequency domain, which is closer to the true 76 amplitude of the signal than with other windows. 77 Exponential window ● It is useful for analyzing transient response signals whose duration is longer than the length of the window. The exponential window damps the end of the signal, ensuring that the signal fully decays by the end of the sample block. You can apply the exponential window to signals that decay exponentially, such as the response of structures with light damping that are excited by an impact, such as the impact of a hammer. 78 Exact Blackman window ● It is useful for single tone measurement. The Exact Blackman window has a lower main lobe width and a lower maximum side lobe level than the Blackman window. However, the Blackman window has a higher side lobe roll-off rate than the Exact Blackman window. 79 Blackman window ● The Blackman window is useful for single tone measurement because it has a low maximum side lobe level and a high side lobe roll-off rate. 80 Blackman-Harris window ● ● The Blackman-Harris window is useful for single tone measurement. The Blackman-Harris window has a wider main lobe and a lower maximum side lobe level than the Exact Blackman window. It is similar to Hamming and Hann windows. The resulting spectrum has a wide peak, but good side lobe compression. There are two main types of this window. The 4-term Blackman-Harris is a good general-purpose window, having side lobe rejection in the high 90s dB and a moderately wide main lobe. The 7-term Blackman-Harris window function has all the dynamic range you should ever need, but it comes with a wide main lobe. 81 82 Blackman-Nuttall window ● The Blackman-Nuttall window is useful for single tone measurement. Among the Blackman, Exact Blackman, BlackmanHarris, and Blackman-Nuttall windows, the Blackman-Nuttall window has the widest main lobe and the lowest maximum side lobe level. 83 Gaussian window ● The Gaussian window is useful for timefrequency analysis because the Fourier transform and the derivative of a Gaussian window both are Gaussian functions. For example, a Short-Time Fourier Transform with a Gaussian window is the Gabor transform. 84 85 How to select a window ● ● ● ● ● ● ● Each window function has its own characteristics and suitability for different applications. To choose a window function, you must estimate the frequency content of the signal. If the signal contains strong interfering frequency components distant from the frequency of interest, choose a smoothing window with a high side lobe roll-off rate. If the signal contains strong interfering signals near the frequency of interest, choose a window function with a low maximum side lobe level. If the frequency of interest contains two or more signals very near to each other, spectral resolution is important. In this case, it is best to choose a smoothing window with a very narrow main lobe. If the amplitude accuracy of a single frequency component is more important than the exact location of the component in a given frequency bin, choose a window with a wide main lobe. If the signal spectrum is rather flat or broadband in frequency content, use the uniform window, or no window. In general, the Hanning (Hann) window is satisfactory in 95 percent of cases. It has good frequency resolution and reduced spectral leakage. If you do not know the nature of the signal but you want to apply a smoothing window, start with86the Hann window. How to select a window These are just a few of the possible window functions. There is no universal approach for selecting a window function. However, the table below can help you in your initial choice. Always compare the performance of different window functions to find the best one for the application. 87 When not to use a window = esto es ventana rectangular ● ● In impact modal testing, when analyzing transient signals such as an excitation signal from hammer blow (impulse excitation), where most of the energy is located at the beginning of the recording. Using a non-rectangular window would attenuate most of the energy and spread the frequency response unnecessarily. In modal analysis (study of the dynamic properties of structures under vibration excitation), when using an impulse, a shock response, a sine burst, a chirp burst, a noise burst, etc. Applying a window function in this case would just deteriorate the signal-tonoise ratio. 88 When not to use a window = esto es ventana rectangular ● ● When measuring a repetitive signal locked-in to the sampling frequency, for example measuring the vibration spectrum analysis during shaft alignment, fault diagnosis of bearings, engines, gearboxes etc. Since the signal is repetitive, all spectral energy is confined to multiples of the base repetition frequency. Por ejemplo esto pasa al hacer synchronous sampling. For periodic signals whose spectral components have comparable strengths and when the signal segment processed includes an exact integer multiple of periods. 89 When not to use a window = esto es ventana rectangular ● ● When measuring a signal whose frequencies are bin aligned, since in this case, no leakage will exist. When measuring a repetitive signal locked-in to the some fundamental base frequency. For example, in fault diagnosis of bearings, since in this case the signal is repetitive and all spectra will be confined to multiples of the base repetition frequency. 90