# Questions tagged [scipy]

The tag has no usage guidance.

85 questions
Filter by
Sorted by
Tagged with
10k views

### Why is Scipy implementation of Hilbert() function different from Matlab implementation of the function?

I am trying to fit Hilbert envelop to a high frequency ultrasonic signal of frequency 250 KHZ and sampling rate 12000000. Raw signal looks like below: . I used hilbert() function from scipy.signal ...
27k views

### Calculating values of frequency bins in Python

I have to use FFT to determine the period of waves inside a signal. After applying FFT on a window of 10000 point from a signal, I get something like this: What I don't understand is that FFT is ...
315 views

### Morphing between two FFTs

I'm a musician and I'm making a script that takes a wave file and snaps each of its frequencies from the fourier transforms to the nearest musical harmonic. Thanks to help from another question I ...
1k views

### How to generate random samples of Gaussian distribution directly in the frequency domain?

One can easily draw (pseudo-)random samples from a normal (Gaussian) distribution by using, say, NumPy: ...
2k views

### Scipy resample, “fourier method” explanation

I am seeking explanation of what "Fourier method" is that is described for resampling in documentation of resample() method. I want to downsample an array. I know what decimation is and how it works, ...
3k views

### Python butter filter: choosing between analog and digital filter types

I have a system that performs wireless sampling of data about every 7.5ms (133Hz). Due to it being wireless, I get occasional data drop out. I want to construct a LP butter filter with cut-off ...
187 views

### Checking Parseval's Theorem for Gaussian Signal by Using Scipy

I'm trying to check Parseval's theorm for Gaussian signal. It's well known that fourier transform of $\exp(-t^2)$ is $\sqrt{\pi}\exp(-\pi^2 k^2)$. So I implement it by using quad and simps. I think ...
475 views

### What Are The Semantics Of Wav-File Sample Values?

The title is the question. To make this concrete, assume I have a standard 16-bit single channel wav file, with (although it doesn't matter) a 16000 Hz sampling rate. Each sample magnitude will be a ...
824 views

### Do DCT results contain phase spectrum?

I've been working much with numpy.fft lately where just like the documentation says: When the input a is a time-domain signal and ...
3k views

### Butterworth band pass filter

I am trying to build a Butterworth bandpass filter. My intent is to have a pass band between $250\textrm{ Hz}$ and $1000\textrm{ Hz}$. However the plot doesn't look right, as can be seen from the ...
612 views

### Decreasing Sample Rate in DFT (FFT) for Audio Analysis

I'm working with audio data analysis through FFT algorithm. My example audio is a sine wave at 440 Hz and 44100 Hz sampling rate. FFT methods in programming, like ...
1k views

### Python different autocorrelation with FFT and non-FFT

Im trying to calculate the autocorrelation of soundwaves when I noticed that I get different results with scipys FFT based and with numpys methods. The 4 functions Im using: ...
3k views

### How to compute the power bands of an eeg signal using python?

so I have an eeg signal (edf format) that has 25 channels and 248832 entries, sampling frequency of 512Hz. I have to compute the frequency bands: – Delta: 0.1-4Hz – Theta: 4-8Hz – Alpha: 8-12Hz – ...
2k views

### How to implement bandpass filter on complex valued signal?

I am using Scipy to implement bandpass filter but it assumes that positive normalized frequency is passed but I & Q samples range from [Fc-Fs/2,Fc+Fs/2] where Fs is sampling frequency & Fc is ...
148 views

### How to discard coefficients in the frequency domain without losing too much quality?

I was reading a text that shows that one can throw away 66% of the coefficients and gets an image that is still acceptable. I tried to replicate it using python (last example) and selectively ...
8k views

### Downsampling and upsampling of a signal in Python

If I want to downsample a signal in Python, is it better to use method resample from SciPy Signal Processing module or method decimate from the same module? What is the difference between these two ...
395 views

### Why does a higher sampling frequency mess up my bandpass filter?

I was designing a bandpass filter in python using some of the scipy.signal modules. I am plotting the frequency response of my filter to verify that my desired frequency is in the passband. However, ...
95 views

### Why is my signal attenuated after applying a HighPass-filter?

I am new to DSP, but I've been attempting apply a butterworth high-pass filter on a 1D array (Values peeking at 300~) to eliminate any noise, yet when applying a high pass filter, I'm ending up with ...
2k views

### Amplitude of frequency bin in FFT doesn't match time-domain amplitude

I have a sinusoidal current that I am sampling at about 357k SPS. The current signal is about 3A pk-pk @ 750hz (top figure). I am wondering why when I take the fft using numpy/scipy's fft function, ...
2k views

### Why does python's scipy.signal.dimpulse introduce delay in impulse response?

Consider a simple linear, time invariant system of the form: $y_k = cy_{k-1} + (1-c)x_k$ The impulse response of this system can be computed by either dimpulse or by applying lfilter to a vector ...
246 views

### consecutive filtered blocks with filtfilt

I'm doing basic signal processing in Python. I'm filtering consecutive blocks of a signal with scipy's filtfilt (to get zero phase). I would like to concatenate several blocks after filtering, however,...
512 views

### discrete digital filtering in python

I am not from DSP background and also not sure if I am posting this in right community. I have basic understanding of resistors, capacitors and filters. My requirement is as follows- The supply ...
94 views

### How to know when a sound in a given frequency starts and ends?

I need to detect two sounds (913 Hz and 1370 Hz), knowing the time in which each starts and ends. At this time, I am using a band pass filter (butter), and this is the result: Here is the first time ...
528 views

### real refractive index from Kramers Kronig relation

I have a measurement of the complex part of the refractive index $k$ (where the refractive index is $m = n + i\,k$) measured at a nonlinear grid of wavelengths or frequencies that span several orders ...
254 views

### Scipy.signal.dimpulse(system): how to translate a StateSpace to a “system”? [closed]

The command scipy.signal.dimpulse(system, x0=None, t=None, n=None) does not seem to accept a scipy StateSpace as an input to its ...
188 views

### Alternative to scipy maximum_filter to find peaks?

I'm using scipy maximum_filter together with binary_erosion to find peaks in my spectrum. I just wondering if there are any ...
998 views

### downsample signal to a specific number of samples in Python

The Python Scipy library provides several functions to downsample signals, but they all have limitations: The resample function is based on Fourier method, which means it assumes periodic signals. ...
30k views

### Convert RGB Image to Grayscale and Display It (Python + Matplotlib) [closed]

I just started learning image processing and I was trying to read a RGB image then convert it to grayscale. I was hoping for something like this: However, what I get was: I tried using both scipy ...
242 views

### Issue with the time vector returned by $\tt signal.spectrogram$ function

I'm puzzled by some very simple concept with building up a spectrogram. Here is a toy example of the issue: ...
3k views

### How to filter out those outliers

I'm struggling to filter some data from an accelerometer. I need to do it in python (and not just on the device collecting the data) to fix the data I have, so that I can build some classification ...
49 views

### Hilbert transform with scipy.signal

I'm coding with python and I just started to use the Hilbert transform from scipy.signal. Consequently, to check the result I got I tried to verify a property of ...
760 views

### How to Apply Gaussian Filter to Raw Audio Files in Python?

I am recording raw files in python to later break them into phonemes, but the noise in the surrounding environment is hampering the result. So, there is a need to apply a filter to the recorded raw ...
135 views

### Help generating coefficients for basic FIR LPF

I'm trying to generate coefficients for a FIR low pass filter to be used in an FPGA. I'm using python (scipy.signal) to attempt to do this, but am having trouble getting coefficients in a usable form....
2k views

### How to design bandpass filter in python when centre frequency is greater than sampling frequency?

I implemented basic bandpass filter using Scipy resource. But how to implement the same when signal is centred at non-zero centre frequency with centre frequency > sampling frequency. I trying to ...
5k views

### How to normalize output of $\tt scipy.signal.correlate$

I have 2 different signals and I'm trying to cross-correlate then using Python 2.7 and scipy.signal.correlate. How do I normalize my results (such that the max ...
194 views

### SciPy Lfilter issue

For one of my DSP projects, I decided to use python to perform signal processing. While I am new to python, I understand that it is a very powerful and versatile language. For my processing, I opted ...
6k views

### Write a 440 Hz Sine Wave to .wav-File using Python and SciPy [closed]

This is my first post on DSP.SE! I'm a student in Computer Sciences and am just getting started with Signals and Systems, thus getting in touch with discrete signals and analyzing them. I wanted to ...
915 views

### Trying to implement MATLAB $\tt pwelch$ in Python

I'm implementing an existing MATLAB script in Python and noticing some differences in the behaviour of MATLAB's pwelch function compared to ...
279 views

### problem with decimate in scipy 0.18

I use scipy.signal.decimate to downsample a large spectroscopic data-set. This has worked superbly so far. ...
270 views

### Need of $\tt abs()$ method when plotting a power spectral density for a given dataset

I am a newbie in signal processing and would like to know the significance of using the abs() function and squaring the values received as an output of ...
71 views

### $n\textrm{ Hz}$ waveform sampled at $m\textrm{ Hz}$ per second

Here is an example of plotting a square wave given in SciPy Documentation A $5\textrm{ Hz}$ waveform sampled at $500\textrm{ Hz}$ for 1 second: ...
5k views

### Is there a function in python which returns the Amplitude/Sound Pressure Level of a sound file(like .wav) file?

I found a function called scipy.io.wavefile.read() which returns the sampling rate and an array. But in the documentation, it is not specified that whether the ...
33 views

### SciPy - Distinguish between two group of periodic samples [closed]

First of all, I'm sorry for my bad English writing, plus, I'm new to DSP. Background We have got motion data of 20 cows. 10 cows are healthy and 10 cows are slightly lame. Lameness is an abnormal ...
56 views

### Why are low frequency peaks not sharp in scipy fft?

I am using numpy/scipy to plot graphs of sine waves. frequencies at 15 Hz or higher give nice, sharp peaks, but at lower frequencies, the peaks are smeared and the actual peak frequency can't be seen ...
42 views

### How to pad a array representing music to pad the stft of this array?

I have an array named samples of size (2, 1321967) representing an audio file. When I pass it to scipy stft with ...
911 views

### Third octave bandpass filter with python

I am very new to signal processing and coding which is why my questions might be really basic. I have a signal of the acoustic pressure p'(t) and I would like to use a third octave bandpass filter in ...
230 views

### Understanding why spectral flatness cannot be computed

I have a real signal recorded 512Hz for 1s. After resampling the signal at 256Hz, I would like to compute its spectral flatness. To do so, I start by taking its discrete Fourier transform with ...
2k views

### How to design an interpolated notch filter in Python to filter powerline harmonics

I have a a time domain data set that records the magnetic field vs time, which must be processed to reveal an embedded signal. This data also contains power line harmonics (i.e. multiples of 60 Hz) ...