All Types of Fourier Transforms in PYTHON
Вставка
- Опубліковано 4 жов 2024
- Check out my course on UDEMY: learn the skills you need for coding in STEM:
www.udemy.com/...
In this video I delve into the libraries of sympy and scipy to take a look at Fourier analysis in python. I look specifically at 1. Fourier Transforms, 2. Fourier Series, and 3. The Discrete Fourier Transform. Some of these transforms involve integrals that can be evaluated analytically (i.e. integrals can be solved symbolically using sympy) while other transforms involve integrals don't have analytic solutions: numerical solutions can be obtained for such integrals using scipy.
Fourier Transforms show up in fields such as quantum mechanics when one wishes to convert a wavefunction in a position basis to a momentum basis. If the analytical form of the wavefunction is known, this transition is seamless using scipy or sympy. Fourier series can often show up in the study of partial differential equations. Finally, the discrete Fourier transform is a useful tool in data analysis to obtain a spectral density estimator for a given time series, for example.
Link to code
github.com/luk...
Discord Server
/ discord
2:46 1 .Fourier Transforms (Function Domain Unbounded)
8:35 2. Fourier Series (Function Domain Bounded)
15:05 3. Discrete Fourier Transform (Function Discretely Measured)
One of the best channels on youtube right now, congrats great content dude.
Man! Where the hell have you been hiding from my recommendation list all this time? I have been looking for someone that would do EXACTLY your content for like ages! Thank you for all the time and effort to remove the fog from my eyes!
Thank you. Have shared this video in our college Discord because our professor doesn't really explain things that well.
I wish I found out about this channel two years ago! It is not late though. Great work boss!
Thanks for this video, I was struggling with my assignment, almost give up but here found a way to solve it! Very appreciated bro!
Not sure if the persistent integration issues with the upper integral limit `T' has to do with the many improvements to SymPy 1.11.1.
However, after lengthy consideration, here is the code that actually returns `x_FT` quickly and correctly without kernel crashes:
x_FT = sp.integrate(1/T * x*sp.exp(-2*sp.pi *sp.I *fn*t), (t, 0, sp.oo)).simplify() 🤓 Love your lectures. 😍
He he he, love this channel even more! Some contents from this video were really helpful (been looking for these explanations from months, but found it here). Your channel is one of the reasons why I love scientific computing in python...Thanks a looooot
I have Fourier transform this sem, thank you for understanding my heart 😉💜
I'm gonna comment again after watching and doing it....
Nov 2022 : to correct exception when reading image 24:49
im_array = io.imread('flower.png')
img = color.rgb2gray(color.rgba2rgb(im_array))
That rap is sick, man, keep on it.
You are unbelievable programmer.
@24:29 nyquist frequency: 1/(2*dt), I thought is was supposed to be (1/2)*dt ?
Thank you for these detail and very helpful videos
Are you planning on making a video about ipywidgets? After watching most of them I'm seriously considering getting [sympy + ipywidgets + numpy + numba + jupyter] as a free Mathematica-like environment.
Also, please, keep posting videos! They are very good and in time you will be in the 1M+ subs range!
highly underrated!!
Definitely liking this for the rap in the beginning.
Hi Mr Solver, thanks for your great effort to put this boring theory into interesting and visual python coding.
I tried out your codes everthing works except #2 Fourier Series (continuous time, discrete frequency). Your suggested solution is much appreciated
After messing around with things a little bit I have found that the following works:
a = smp.symbols('a', real = False)
x_FT = smp.integrate((1/T) * x *smp.exp(-a*t), (t,0,T)).subs([(a, 2*smp.pi*smp.I*fn)]).simplify()
This makes a symbolic answer that looks different than the video, but reproduces the same numeric results, so it should be fine! :^)
@@reapicus557 Thank you, your solution works!
It'd be awesome if you could cover Gabor analysis or other time-frequency analysis methods.
I subscribed before the singing, happy I subscribed. LOL awesome vid
try solving mit intigration bee problem in python
my thanks for this video, you saved me and my exam too! lol
How about fractional fourier transform? Can you explain it?
u bait me with the memes... and now im in image Fourier, pretty cool
Hey Thankyou so much. Its too helpful. Stay blessed!
Awesome lecture ever. Hello sir, can you make a tutorial on Fourier series of a triangular waveform?🙏🙏
Plz share inverse fourrier transform system video too
nice video! I ran into two problems:
1) I can not seem to load an image that is located in another folder. How can I tell the program to search for it?
2) When I do add it to the folder python expects it to be, i get the following error:
''ValueError: the input array must have size 3 along `channel_axis`, got (571, 564, 4)''
How can you resolve this problem?
it is imposible to flow now if you do not have the version of your module (pip freeze) :(
Another amazing video
If anyone is having trouble getting a symbolic result in the Part 2 section without a kernel crash, then try adding the following 'a' symbol:
a = smp.symbols('a', real = False)
x_FT = smp.integrate((1/T) * x *smp.exp(-a*t), (t,0,T)).subs([(a, 2*smp.pi*smp.I*fn)]).simplify()
This gave me something that looks different from the video's symbolic form, but it reproduces the numeric plot, so I'm happy with it!
Hey, Discovered your channel and have been hooked since. Just a small request. Would you mind zooming in just a little bit. The text is hard to read even at the highest res of 1080p.
Thanks.
Great work 👌👏👍
Very nice videos! Thank you so much.
DFT formulas are a bit messed up. Useful vid :)
3 weeks too late for me, but thank you for this vid
hi, thank you so much for your informative videos, is it possible to do a video for solving the image MTF using py, thanks alot
Great work as always! Have you ever checked Steve Brunton's channel? He has some nice videos on this topic and many other data-driven techniques. Highly recommended
Great content.
Great Lecture!
Although as the frequency goes up, the sampling rate ought to be sufficiently INCREASED for good analog audio to be retrieved from a file with data recorded at, let's say 320bps,
so as to avoid aliasing as alluded to in cell 39. Should it not?
Yes, he probably meant to say that "dt" should be small enough (and not sampling rate), which inversely means that sampling rate should be high enough. Just an honest mistake on his part.
@@Zorzek Speaking of honest mistakes, I took the liberty to re-write one of the formulas in 2.Fourier Series (`Continuous time, Discrete Frequency`):
$$\displaystyle\color{blue}{\hat x(f_n) = \frac{1}{T}\int_0^T x(t)e^{-2\pi i (f_n)(t)} dt}$$
because this is what we are actually doing in the code that expresses it.
Thank you!
I keep getting the following error:
"x_FT_integrand_real = lambda t: np.real(x(t, k)*np.exp(-2.0*np.pi*1j*f*t))
TypeError: 'Mul' object is not callable"
Why is this occurring, and how to get around it?
Great video, honesty could listen for few hours about 2D transformation. Is not that easy to find good sources about this topic.
What is the editero you are using?
D ear Mr. P Solver, can you tell us how to make spectral derivative in Python?
Thank you.
Great video
Great and hansome!
ur a true god
Hi, I have a discrete voltage and current signal in time domain, what will be the formula to calculate the power using both voltage and current waveform in FFT method, it will be sum of the Individual powers in frequency domain or if you can put some insights or share your mail I can send you a email stating the exact problem. Thanks for the video.
I want to fourier transform position wavefuntion to momentum for infinite square well and plot it. I am following this video where you transformed time to frequency. But in my case p (momentum) equals (iota)*(planck constant)*(partial by partial x). I am not sure hoew to define this. If you have sample of position to momentum fourier transform o anything to help, kindly tell me. Regards
How can study Fe(Phen) using monte carlo simulation in python program-ising model 2D .. please
Make video on epicycle
And converting any image to epicycle drawing
Please simulate random walk probably by python 🙏🙏🙏🙏
hey its great can you please help me in the code for how to fourier transform a signal which i have already plotted in python itself
Great video thanks
5:58 If I use smp.exp instead of np.exp in def x, then the quad will fail.
WOW. Nice Video!! 💙
thank you very much !
Awesome, 👍👍
which software is this..?
This is where repp'n and math collide
Where is dtft?
Noise
permission to learn sir
Hello..I am a PhD student in physics from Iraq..I hope you can help me find codes in the Python program to study the Fe(II)particle (ising model 2D)to determine the spin crossover of the electrons and find the energy..with many thanks to you.
❤️❤️❤️❤️❤️
Video quality is worst.. Can't see what's types
What about amplitude and phase? And what about an entire spectrum of frequencies, instead of a basic ass sin function? This is so generic and superficial might as well just read the instructions on the np sp manuals SMH
I don't know what kind of magic you used to get a symbolic answer for:
x_FT = sp.integrate(1/T * x*sp.exp(-2*sp.pi *sp.I *fn*t), (t, 0, T)).simplify()
because the Kernel in Jupyter simply dies. 😓
Here are the errors that were eventually generated in PyCharm using an alternate installation of Python:
File "C:\Users
b_se\AppData\Local\Programs\Python\Python38\lib\site-packages\sympy\integrals\integrals.py", line 1084, in _eval_integral
h = heurisch_wrapper(g, x, hints=[])
File "C:\Users
b_se\AppData\Local\Programs\Python\Python38\lib\site-packages\sympy\integrals\heurisch.py", line 158, in heurisch_wrapper
slns += solve([d], dict=True, exclude=(x,))
File "C:\Users
b_se\AppData\Local\Programs\Python\Python38\lib\site-packages\sympy\solvers\solvers.py", line 1114, in solve
solution = _solve_system(f, symbols, **flags)
Doesn't look much like a simplification to me. Which ever way, one always gets this:
$\frac{1 - e^{- T k - 2 i \pi n}}{T k + 2 i \pi n}$