No video

How to do Spectral analysis or FFT of Signal in Python??

  Рет қаралды 45,559

Dr. Sachin Sharma

Dr. Sachin Sharma

Күн бұрын

Пікірлер: 72
@baghdadiabdellatif1581
@baghdadiabdellatif1581 9 ай бұрын
Thank you Great work 👌👏👍💯
@donnymac575
@donnymac575 Жыл бұрын
This is a very useful script for doing FFT using SciPy and as far as I can tell it works well for sine wave signals. For DC it's another story. It does not appear to do DC correctly. To check for yourself, put in a sine wave where x = 1 * np.sin(2 * np.pi * f * t) + 2. The + 2 on the end is the DC component. It will plot correctly at 0 Hz however the amplitude will be 4 instead of 2.
@baghdadiabdellatif1581
@baghdadiabdellatif1581 9 ай бұрын
Which one beside scipy can do accurate DC&AC analyze?
@smilebig3884
@smilebig3884 4 жыл бұрын
For the new viewers in the 28th line use int(n/2) than n/2 . Otherwise it will give float error
@sachinsharmajcbro
@sachinsharmajcbro 4 жыл бұрын
Thanks
@ashutoshkarna2133
@ashutoshkarna2133 4 жыл бұрын
It would have been nicer if you could also explain at each step what you are doing and why, and this could be a great tutorial.
@ronfredericksbiophysicslab9984
@ronfredericksbiophysicslab9984 5 жыл бұрын
I like your presentation style, topic here. Your web site looks great also. I do see a few errors in your video during the first 6 minute segment: line 23 has title('...') instead of plt.title('...') for testing purposes you probably need to add a plt.show() to get the actual plot to show up as well PS: I love the video and presentation.
@sachinsharmajcbro
@sachinsharmajcbro 5 жыл бұрын
Hi, Thank you for your comment....yes, I think that error was auto corrected by 'spyder'...as for plt.show(), I think that is not mendatory to use...
@iamAK47
@iamAK47 4 жыл бұрын
Nice video,could you do an extended version where you read data from a CSV file, instead of creating a sine wave.it would be really helpfull
@sachinsharmajcbro
@sachinsharmajcbro 4 жыл бұрын
Thanks for the idea!
@AA-wl8tp
@AA-wl8tp 3 жыл бұрын
Yeah, that would be the cherry on top! Thank you
@BarbaraAboagye
@BarbaraAboagye 4 жыл бұрын
Very useful. Thanks
@sachinsharmajcbro
@sachinsharmajcbro 4 жыл бұрын
Glad it was helpful!
@gokulmukil6617
@gokulmukil6617 2 жыл бұрын
do you know how to find frequency spectrum for upsampling and down sampling
@ayanokoji1010
@ayanokoji1010 2 жыл бұрын
hello, I didn't understand why you used an absolute value with the fat. Can you explain me please 🙏🏽
@AryoZare
@AryoZare 3 жыл бұрын
MAGNIFICENT
@suchox
@suchox 5 жыл бұрын
excelent video!
@Lucas-wc3jo
@Lucas-wc3jo Жыл бұрын
i love indians!
@sgmed539
@sgmed539 4 жыл бұрын
hello, thanks for the video, how can we analyze an unknown sinusoidal signal with the fft to extract its frequency
@sachinsharmajcbro
@sachinsharmajcbro 4 жыл бұрын
We need to know its sampling frequency. Then we can do that.
@sgmed539
@sgmed539 4 жыл бұрын
@@sachinsharmajcbro thanks
@philiperiskallaleal6010
@philiperiskallaleal6010 4 жыл бұрын
@@sachinsharmajcbro dear Sachin, one can always know a sampling frequency of a synthesized signal. Nevertheless, in the case of a sampled data, that is not the case. For example, for sampled data, let's assume that the data is a time-series of weekly average surface temperature of a given city, with length N, N being a positive interfer (I.e: 48), and a constant "dt" between two samples of 1 month. What would be that sample frequency: a) 1 (units: 1/month); b) N (units: number of samples)? I thank you for your time, Sincerely,
@philiperiskallaleal6010
@philiperiskallaleal6010 4 жыл бұрын
Dear Sachin, thank you for awesome video. I was wondering how one could adapt the frequency of the analysis for other time series. For example, assuming that I had a time-series that each sample is in fact a monthly average of a given data. Could I apply your code the same way, just altering the Hertz to 1/month in the plots legend?
@sachinsharmajcbro
@sachinsharmajcbro 4 жыл бұрын
yes, conceptually, it should work
@binodregmi923
@binodregmi923 3 жыл бұрын
I like your presentation.It's very good but I see and feel little bit confused in line (28)th i.e. fr=(Fs/2)*np.linspace(0,1,n/2).It shows Name error: name 'np' is not defined. and type error: Object of type "class float" cannot be safely interpreted as an integer. How can solve it? Give suggestions.
@sachinsharmajcbro
@sachinsharmajcbro 3 жыл бұрын
you should type: import numpy as np
@MilanKarakas
@MilanKarakas 5 жыл бұрын
I am trying my first steps in Python, but stack on first part of the program generating frequency. Got error message: " File "D:/000_anaconda/Python_tests/first.py", line 17, in t = np.arange(0,1,1/Fs) ZeroDivisionError: division by zero" Can you help me please? What is wrong?
@MilanKarakas
@MilanKarakas 5 жыл бұрын
Okay, found error - installed another Anaconda, this time with Python 3.7 . Version 2.7 does not works. Thanks anyway.
@artmusic6937
@artmusic6937 4 жыл бұрын
what is in Fs?
@santoshkatuwal1776
@santoshkatuwal1776 4 жыл бұрын
Thankyou so much !!
@sachinsharmajcbro
@sachinsharmajcbro 4 жыл бұрын
You're welcome!
@wilswils1094
@wilswils1094 4 жыл бұрын
Thank you so much bro §!
@sachinsharmajcbro
@sachinsharmajcbro 4 жыл бұрын
You're welcome!
@radiffff
@radiffff 3 жыл бұрын
Let's say I have an audio signal and I got its FFT and graphed it. It contains multiple peaks with different amplitudes. How can I get the distinct peaks of such signal, let's say the top three or four?
@sachinsharmajcbro
@sachinsharmajcbro 3 жыл бұрын
There are several ways of doing this. You can use thresholding and then use 'findpeaks' function in MATLAB.
@radiffff
@radiffff 3 жыл бұрын
@@sachinsharmajcbro Thanks, you are right, MATLAB is perfect for what I need but I was trying to do it in Python.
@sachinsharmajcbro
@sachinsharmajcbro 3 жыл бұрын
same can be done in python as well. Just do more extensive search.
@BTECE_Rajshreek
@BTECE_Rajshreek 3 жыл бұрын
If we want spectrum of signal in -pi to pi interval what should be the code??
@sachinsharmajcbro
@sachinsharmajcbro 3 жыл бұрын
Please send your requirement at: info@jcbrolabs.org
@baban2097
@baban2097 4 жыл бұрын
Hi Can you add some more code for FFT to PSD curve
@Mortifer_I
@Mortifer_I 4 жыл бұрын
Is there a time efficent way to convert it back again?
@anasslmoh7455
@anasslmoh7455 4 жыл бұрын
Yes of course it's the ifft, inverse fast Fourier transform
@lindagunshefski6104
@lindagunshefski6104 4 жыл бұрын
I suggest using a different logo, the schwasticka is offensive.
@sachinsharmajcbro
@sachinsharmajcbro 4 жыл бұрын
Dear Linda, Instead of changing the logo, I think you need to broaden your knowledge about other parts of the world. The logo has Indian symbol swastika, which is used everywhere in India for centuries. This swastika represents, prosperity and well being for all. Please do some search about the same on google. Regards
@volkovolko
@volkovolko 4 жыл бұрын
@@sachinsharmajcbro yes but it's confusing so you migh change it
@TypicallyThomas
@TypicallyThomas Жыл бұрын
@@sachinsharmajcbro People are gonna keep commenting on this till you remove it. Unless you enjoy telling each commenter to Google it (which, trust me, 99% aren't going to) might be just a lot easier to not put it in
@terjeoseberg990
@terjeoseberg990 Жыл бұрын
@@volkovolko, Yes. Absolutely. It’s confusing to the uneducated and the ignore ant.
@terjeoseberg990
@terjeoseberg990 Жыл бұрын
@@TypicallyThomas, Or, people can stop being ignore ant more ons.
@VOGTLANDOUTDOORS
@VOGTLANDOUTDOORS 4 жыл бұрын
You made a useful video - of this there is no doubt. But I would respectfully note that people seeking your video in fact AREN'T "masters of FFT" , but rather more likely NEW to FFT even as they are ALSO NEW to implementing FFT in PYTHON CODE. YOU made NUMEROUS assumptions about the familiaroty of your audience with FFT - almost TRIVIALIZING the key concepts when it would have been far more useful if you had EXPLAINED them rather GLOSS OVER them. In so doung you come off as merely someone "regurgitated" theory that was (clearly) BEATEN into your head as a STUDENT (without actually taking time to actually UNDERSTAND IT), so that now as a TEACHER of it, you can now only "regurgitate" those beatings in an effort to appear knowledgeable. IF instead you had understood your audience, and actually EXPLAINED these key concepts rsrher than trivialize & gloss over them, you would have come a ross as truly understanding what you're discussing. Instead you simpky come off as full of yourself...but NOT truly understanding the concepts you're treating - only MEMORIZING them. This is typical for "experts" from some cultures, and is indicative of the memorization-is-equivalent-to-understanding philosophy... but sadly this ISN'T avalid conept. Memorizing ISN'T understanding; if it WERE, then PARROTS would actually BE college professors ;-) I think you have it in you to make truly GREAT videos. You simpky have to CHALLENGE yourself to UNDERSTAND the kind of audience that would go SEEKING this kind of video... then STOP TALKING OVER THEIR HEADS on the key concepts intrinsic to your video, and instead demonstrate true mastery of your topic by EXLKAING these key topics rather than "regurgitate" defi itiokns your own professors (clearly) best into you. You are a product of your educational system...but you CAN be MORE than that... Thank you nonetheless for at keast regurgitating someone else's python code; this WAS what I was seeking; luckily I can read the explanation elsewherw from someone who understands it SO well they can actually EXPLAIN it, and not regurgitate some old professor's lectur notes... KEEP TRYING - I BELIEVE IN YOU!
@sachinsharmajcbro
@sachinsharmajcbro 4 жыл бұрын
Dear, you are right in your words. But our objective here is not to teach the basic concepts to students. For that we have separate channel. Our main objective here is to give a quick & small tutorial about the underlined topic.
@DarcyMiyamoto
@DarcyMiyamoto Жыл бұрын
You sound rude and condescending. Probably not limited to sounding, I have a feeling you are. Be more respectful even if you find an issue with what someone is doing and if you’re going to be condescending, use proper grammar. I also don’t care if English is not your first language. Don’t use it to be rude
@user-cc8kb
@user-cc8kb 4 жыл бұрын
Why is there a big fat swastika in the logo? Don't tell me it's an ancient sun symbol...
@sachinsharmajcbro
@sachinsharmajcbro 4 жыл бұрын
I don't know, what you want to hear! but do not worry, It is not nazi symbol. It is Indian symbol representing prosperity and well being for all. It is used widely in India at all auspious occations. You can search about it on google for more information
@user-cc8kb
@user-cc8kb 4 жыл бұрын
@@sachinsharmajcbro ok. irritating.
@mathematiknet
@mathematiknet 4 жыл бұрын
@user28 Why don't you read wikipedia before you talk bullshit: en.wikipedia.org/wiki/Swastika
@volkovolko
@volkovolko 4 жыл бұрын
@@mathematiknet It's confusing so change it
@a1nelson
@a1nelson 3 жыл бұрын
@@sachinsharmajcbro I am aware of the significant history and current interpretation of this symbol within India, as just one location the symbol has been important for at least the last 8,000 years. However, in a global internet, we must all try to be aware of how our messages and symbols may be interpreted in a different light in other parts of the world. A red swastika, in that particular style is deeply offensive in some cultures - not a mere annoyance. Simply reversing the rotation of the swastika, rounding the edges or applying any of many alternative styles would go a long way to preserving the meaning for Indians, while being respectful of others.
@eligioeduardo5437
@eligioeduardo5437 3 жыл бұрын
Does anyone know why the Nazi swastika? :(
@sachinsharmajcbro
@sachinsharmajcbro 3 жыл бұрын
Dear, this symbol is not Nazi swastika, It is an Indian symbol which represents prosperity and well being for all. Please do some google search about the same in order to know more about it.
@eligioeduardo5437
@eligioeduardo5437 3 жыл бұрын
Dear,@@sachinsharmajcbro . Oh thank you very much! Sorry for the mistake.
How to Record Sound and Do spectral analysis in Python??
18:17
Dr. Sachin Sharma
Рет қаралды 5 М.
Plotting the Fourier Transform in Python (DFT/FFT)
10:46
Signal Processing with Paul
Рет қаралды 19 М.
WILL IT BURST?
00:31
Natan por Aí
Рет қаралды 29 МЛН
Please Help Barry Choose His Real Son
00:23
Garri Creative
Рет қаралды 23 МЛН
Time and frequency domains
9:43
Mike X Cohen
Рет қаралды 95 М.
FFT in excel for spectral analysis
11:33
Mike Holden
Рет қаралды 124 М.
Denoising Data with FFT [Python]
10:03
Steve Brunton
Рет қаралды 172 М.
Spectral Analysis in Python (Introduction)
42:02
Mr. P Solver
Рет қаралды 24 М.
Basic Sound Processing in Python | SciPy 2015 | Allen Downey
18:59
Extract Musical Notes from Audio in Python with FFT
10:26
Jeff Heaton
Рет қаралды 23 М.