Re: Wanting to take a FFT transform of a irregularly spaced sample
Micha F <[email protected]> Wed, 13 Apr 2022 18:42:44 +0300
| Newsgroups | gmane.comp.python.scientific.user |
|---|---|
| Message-ID | <[email protected]> |
--===============4850587109366619109== Content-Type: multipart/alternative; boundary=Apple-Mail-55A49D98-071F-43AC-8325-3979A1AF20C9 Content-Transfer-Encoding: 7bit --Apple-Mail-55A49D98-071F-43AC-8325-3979A1AF20C9 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable It is not the most accurate option, but the easiest would be to take the dft= (discrete Fourier transform, function is called fft as it chooses the fast v= ersion of it can) after linear or quadratic interpolation of your data to a u= niform grid.=20 There are ways to compute the Fourier series on a non-uniformed sampled time= series (mostly, the response to a specific frequency) but you need to be ca= reful with the results.=20 Treat it as noisy data though, as the interpolation will introduce some nois= e into the spectrum (it is possible to analyze what kind of noise with some w= ork if it is important, depends what information you hope to get from the ou= tput) > On Apr 12, 2022, at 10:34, ashwin .D <[email protected]> wrote: >=20 > =EF=BB=BF > Hi Robert, > Thanks for your prompt response. I am going to try both.= Regarding this answer that you recommended - https://stackoverflow.com/ques= tions/34428886/discrete-fourier-transformation-from-a-list-of-x-y-points/344= 32195#34432195 >=20 > what would be my angular frequencies from this API - https://docs.scipy.or= g/doc/scipy/reference/generated/scipy.signal.lombscargle.html ?=20 >=20 > The x and y arguments are straightforward and are available to me from the= CSV file. What about the third one ?=20 >=20 >=20 >=20 >> On Tue, Apr 12, 2022 at 9:48 AM Robert Kern <[email protected]> wrote= : >>> On Mon, Apr 11, 2022 at 11:38 PM ashwin .D <[email protected]> wrote: >>=20 >>> Hello, >>> I have looked at both these answers from SO - https://stacko= verflow.com/questions/34428886/discrete-fourier-transformation-from-a-list-o= f-x-y-points/34432195#34432195 and https://stackoverflow.com/questions/25735= 153/plotting-a-fast-fourier-transform-in-python/25735436#25735436 >>>=20 >>> My question is somewhat similar. I have data from a CSV file that has me= asurements of a mean sea level pressure. The data is available every 5 minut= es. That means 8928 sample points over a month. But during a hurricane event= there was a power failure and only 8867 data points are available. I am sho= rt by 61 points to get a uniformly spaced sample. I am wanting to take an FF= T of the data in order to check for periodicity, waves and frequencies there= of. What are my best options ?=20 >> =20 >> The first SO answer is reliable (the second is mostly useless for the kin= d of gap you are talking about); the Lomb-Scargle periodogram is a very reas= onable way to do the task. To answer those questions, you will likely want a= periodogram, not the more fundamental Fourier transform. But if you do want= a full complex-valued Fourier transform for whatever reason, `nfft` should d= o the job: >>=20 >> https://github.com/jakevdp/nfft/ >>=20 >> --=20 >> Robert Kern >> _______________________________________________ >> SciPy-User mailing list -- [email protected] >> To unsubscribe send an email to [email protected] >> https://mail.python.org/mailman3/lists/scipy-user.python.org/ >> Member address: [email protected] > _______________________________________________ > SciPy-User mailing list -- [email protected] > To unsubscribe send an email to [email protected] > https://mail.python.org/mailman3/lists/scipy-user.python.org/ > Member address: [email protected] --Apple-Mail-55A49D98-071F-43AC-8325-3979A1AF20C9 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable <html><head><meta http-equiv=3D"content-type" content=3D"text/html; charset=3D= utf-8"></head><body dir=3D"auto"><div dir=3D"ltr"></div><div dir=3D"ltr">It i= s not the most accurate option, but the easiest would be to take the dft (di= screte Fourier transform, function is called fft as it chooses the fast vers= ion of it can) after linear or quadratic interpolation of your data to a uni= form grid. </div><div dir=3D"ltr"><br></div><div dir=3D"ltr">There are w= ays to compute the Fourier series on a non-uniformed sampled time series (mo= stly, the response to a specific frequency) but you need to be careful with t= he results. </div><div dir=3D"ltr"><br></div><div dir=3D"ltr">Treat it a= s noisy data though, as the interpolation will introduce some noise into the= spectrum (it is possible to analyze what kind of noise with some work if it= is important, depends what information you hope to get from the output)</di= v><div dir=3D"ltr"><br><blockquote type=3D"cite">On Apr 12, 2022, at 10:34, a= shwin .D <[email protected]> wrote:<br><br></blockquote></div><blockq= uote type=3D"cite"><div dir=3D"ltr">=EF=BB=BF<div dir=3D"ltr">Hi Robert,<div= > Thanks for y= our prompt response. I am going to try both. Regarding this answer that you r= ecommended - <a href=3D"https://stackoverflow.com/questions/34428886/di= screte-fourier-transformation-from-a-list-of-x-y-points/34432195#34432195">h= ttps://stackoverflow.com/questions/34428886/discrete-fourier-transformation-= from-a-list-of-x-y-points/34432195#34432195</a></div><div><br></div><div>wha= t would be my angular frequencies from this API - <a href=3D"https://do= cs.scipy.org/doc/scipy/reference/generated/scipy.signal.lombscargle.html">ht= tps://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.lombscargle.= html</a> ? </div><div><br></div><div>The x and y arguments are straight= forward and are available to me from the CSV file. What about the third one ?= </div><div><br></div><div><br></div></div><br><div class=3D"gmail_quot= e"><div dir=3D"ltr" class=3D"gmail_attr">On Tue, Apr 12, 2022 at 9:48 AM Rob= ert Kern <<a href=3D"mailto:[email protected]">[email protected]<= /a>> wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0p= x 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><di= v dir=3D"ltr"><div dir=3D"ltr">On Mon, Apr 11, 2022 at 11:38 PM ashwin .D &l= t;<a href=3D"mailto:[email protected]" target=3D"_blank">[email protected]= </a>> wrote:<br></div><div class=3D"gmail_quote"><blockquote class=3D"gma= il_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,20= 4,204);padding-left:1ex"><div dir=3D"ltr">Hello,<div> &n= bsp; I have looked at both these answers from SO - <a hre= f=3D"https://stackoverflow.com/questions/34428886/discrete-fourier-transform= ation-from-a-list-of-x-y-points/34432195#34432195" target=3D"_blank">https:/= /stackoverflow.com/questions/34428886/discrete-fourier-transformation-from-a= -list-of-x-y-points/34432195#34432195</a> and <a href=3D"https://stacko= verflow.com/questions/25735153/plotting-a-fast-fourier-transform-in-python/2= 5735436#25735436" target=3D"_blank">https://stackoverflow.com/questions/2573= 5153/plotting-a-fast-fourier-transform-in-python/25735436#25735436</a></div>= <div><br></div><div>My question is somewhat similar. I have data from a CSV f= ile that has measurements of a mean sea level pressure. The data is availabl= e every 5 minutes. That means 8928 sample points over a month. But during a h= urricane event there was a power failure and only 8867 data points are a= vailable. I am short by 61 points to get a uniformly spaced sample. I a= m wanting to take an FFT of the data in order to check for periodicity, wave= s and frequencies there of. What are my best options ? </div></div></bl= ockquote><div> <br></div></div><div>The first SO answer is reliable (th= e second is mostly useless for the kind of gap you are talking abo= ut); the Lomb-Scargle periodogram is a very reasonable way to do the task. T= o answer those questions, you will likely want a periodogram, not the more f= undamental Fourier transform. But if you do want a full complex-valued Fouri= er transform for whatever reason, `nfft` should do the job:</div><div><br></= div><div> <a href=3D"https://github.com/jakevdp/nfft/" target=3D"_blan= k">https://github.com/jakevdp/nfft/</a><br></div><div><br></div>-- <br><div d= ir=3D"ltr">Robert Kern</div></div> _______________________________________________<br> SciPy-User mailing list -- <a href=3D"mailto:[email protected]" target=3D= "_blank">[email protected]</a><br> To unsubscribe send an email to <a href=3D"mailto:[email protected]= g" target=3D"_blank">[email protected]</a><br> <a href=3D"https://mail.python.org/mailman3/lists/scipy-user.python.org/" re= l=3D"noreferrer" target=3D"_blank">https://mail.python.org/mailman3/lists/sc= ipy-user.python.org/</a><br> Member address: <a href=3D"mailto:[email protected]" target=3D"_blank">wina= [email protected]</a><br> </blockquote></div> <span>_______________________________________________</span><br><span>SciPy-= User mailing list -- [email protected]</span><br><span>To unsubscribe se= nd an email to [email protected]</span><br><span>https://mail.pyth= on.org/mailman3/lists/scipy-user.python.org/</span><br><span>Member address:= [email protected]</span><br></div></blockquote></body></html>= --Apple-Mail-55A49D98-071F-43AC-8325-3979A1AF20C9-- --===============4850587109366619109== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ SciPy-User mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/scipy-user.python.org/ Member address: [email protected] --===============4850587109366619109==--