# Questions tagged [scipy]

The tag has no usage guidance.

194 questions
Filter by
Sorted by
Tagged with
710 views

### Scipy Butterworth highpass filter results in distortion and bloated output

Trying to use Scipy Butterworth filter to filter frequencies below 54 Hz from audio files. Audio files are stored as WAVs. Sample rate is 44100. When I try using this filter the result is distorted (...
• 103
918 views

### Scipy fourier transform zero frequency spike (from DC offset) - de-meaning and hanning window have no effect

I am trying to plot the FFT of essentially a random signal that has a non-zero mean shown below. The FFT of the signal is peaked over the zero frequency which usually indicates a DC offset. Although ...
1 vote
2k views

### How to practically correct for group delay imposed by a digital filter (Python)

I'm using Python to filter a signal using a Butterworth filter (scipy.signal.butter) and subsequently passing this through a forward-backward filter with cascaded second order sections (scipy.signal....
• 13
1 vote
461 views

### Ripple in a SciPy Butterworth SOS Filter

I have a script using SciPy for checking the RMS of various Butterworth Bandpass Filters of varying orders. I would expect the RMS values to increase and decrease linearly and consistently as you get ...
• 113
1 vote
1k views

### CWT at low scales: PyWavelets vs Scipy

Low scales are arguably the most challenging to implement due to limitations in discretized representations. Detailed comparison here; the principal difference is in how the two handle wavelets at ...
• 8,815
106 views

### How to calculate PSD if i have power vs freq spectrum?

i have a signal something like this how to calculate PSD? i have freq from 191000200 to 196500000 time gap or delta t = 1 or 2 sec, (what i mean is [tn] - [tn-1]) i will be computing in python any ...
• 1
2k views

### Are IIR filters (and specifically Butterworth filter) causal?

I am new to signal processing. I am learning now about filtering and I am trying to implement high pass filter (HPF),and later band-pass filter (BPF). I implement the filters in ...
• 398
441 views

### Filtering a square signal with a median filtering to preserve the edges

If needed, you can find my first post for this problem here. I am trying to clean the following signal: As proposed in the comment, I tried to use this post proposing 2 methods: median filtering and ...
• 191
1 vote
711 views

### How do I set window length and shift length for computing STFT on Scipy?

Does nperseg=32, noverlap=16 mean the window length is 32mS with a shift of 16mS? Refer here for more details
552 views

### Showing specific values in an STFT plot

I have a short term fourier transform plot that I plot using matplotlib's pcolormesh() function: If I zoom in the plot, I see this: Now, I want the plot to just ...
1k views

### Complex Samples (IQ) - Baseband Filtering

We are currently analyzing a large set of IQ samples in a desktop application and we are interested in implementing many different bandpass filters dynamically. We realized, that working with scipy ...
53 views

### Are there any tools for generating fixed point filter implementations?

It's very easy to make a filter in Scipy or many other tools, but implementing this filter in fixed point in C or VHDL/Verilog is always a chore. I mean, in theory it's just a matter of adequately ...
• 248
903 views

### Difference between freqz vs freqresp in scipy?

I'm always confused that scipy has scipy.signal.freqz, but also scipy.signal.lti.freqresp / ...
• 543
1 vote
1k 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 ...
• 35
159 views

### Why is there a difference in the spectrum of an audio file between Sonic Visualizer and my Python script?

I am working on a script which is creating a spectrum analysis from an audio file using SciPy and NumPy. Before I started, I analyzed the file using Sonic Visualizer, which got me the following result:...
• 101
108 views

### Lowpass Butterworth filter equation

I am using a 5th order lowpass Butterworth filter with a varying cutoff frequency, $f_c$, to smoothen some data coming from a spectrometer. An example of a spectrum, plotted with the filtered data, ...
• 1
213 views

### How to Save FFT output for fast read-in?

For a project, I'm reading in hundreds of short (4 sec) wavefiles and giving them to scipy fft for the frequency information for further processing/experimenting in various ways. Problem is, I want to ...
1 vote
2k views

### Why is the number of frequencies decomposed in scipy.signal.stft() equal to the hop size?

I asked this over on StackOverflow first but figured you fine people might know more about signal processing (duh). I'm trying to calculate the spectrogram of an audio file in python. There's a nice ...
• 113
948 views

### Decimating Non-Uniform large time-series data

I'm working with accelerometer data that is sampled at a non-uniform rate. There are major gaps in the data. Below is a scatter plot of the data I can also give a sense of the frquencies at which ...
• 21
1 vote
39 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 ...
• 11
453 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 ...
• 41
10k 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. ...
• 1,079
1 vote
237 views

### Is there a way to get output in second order sections (SOS) format from Scipy's signal.firwin

I am using Scipy's signal.firwin to implement a lowpass filter. Using the rule of thumb formula(s) to estimate the order of the filter, I am getting a very high number. I looked into this question, ...
• 69
2k views

### Demodulation of FSK signal

What kind of FSK signal is this and what demodulation technique can I use to demodulate it. Why is the phase of the 1's changing like that and how does that effect how it needs to be demodulated. I ...
• 275
2k 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 ...
5k 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 ...
• 175
1 vote
791 views

### How to implement Matlab welch in python with the same result?

I want to implement Matlab pwelch function in python. The Matlab code is shown blew: [PSD,f] = pwelch(data,length(data),[],[],2000); which data is a row vector ...
1 vote
190 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 ...
• 11
132 views

### Can't seem to get welch function in scipy work correctly

I'm trying to learn DSP through using Python's scipy package. I have measure some 200Hz signal from a machine. Now I want to inspect the spectral density of the signal. Here's the signal plotted out: ...
• 161
3k views

### Python Hilbert does not seem to calculate the envelope

I am following the example from: https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.hilbert.html And although I can replicate their example, it does not work with my data. This is the ...
• 119
317 views

### Bandpass filter with very high sampling rate

Consider a bandpass filter with Low Cut 17Hz, High Cut 22 Hz, Fs = 45000 Hz and Order = 6. When I pass a mixture of multiple sinusoidal waves through this filter (with a sine wave of frequency 20 Hz), ...
169 views

### Negative Exponential Filter SciPy

I'm trying to transform a time series with a recursive filter to model a feedback. I was able to do a simple filter like : ...
2k views

### How to convert a spectrogram back to a signal [duplicate]

I'm converting a signal to a spectrogram, manipulating that (nonlinear stuff), and then want to use the modified audio signal. I can make it so the segments are not overlapping, but am unsure how to ...
• 199
1 vote
156 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 ...
1k views

### Delay in Savitzky-Golay filtering

I am applying a Savitzky-Golay filter to a signal, using the scipy function. I need to calculate the lag of the filtered signal, and how much is it behind the original signal. Could someone shed ...
152 views

### Scipy Deconvolve help

I was playing with the deconvolve method in scipy and I can't seem to get it working properly (I am still really new to DSP/deconvolution). I convolved a gaussian with a fwhm of 2.0e-9 with a ...
567 views

### Filtering out different narrow-band frequencies at once

I have asked a closely related question on SO at https://stackoverflow.com/questions/55168460/python-implementation-for-filtering-out-multiple-distinct-narrow-band-frequencie but I am still unclear ...
• 141
1 vote
4k 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 ...
• 11
472 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 ...
88 views

### Scipy Welch's gives different first element

I've re-implemented Welch's method and want to compare it to scipy.signal.welch. However, the first two and last elements of the resulting array are different. My ...
• 101
1k 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, ...
• 165
1 vote
3k views

### How to calculate the PSD from the complex calculated STFT?

I have calculated the STFT with scipy python library: ...
• 113
158 views

### How to know the time of my window to calculate the STFT with python knowing only the length?

I am trying to implement a work presented in an IEEE paper where they have mentioned that the STFT was performed on the signal measurements to obtain a spectrogram with no overlap window of 3 min : I ...
213 views

### how to detrend a carrier phase with butterworth filter?

I am new with detrending techniques, I have a carrier phase measurements and I want to detrend it by 6th order butterworth digital filter. After creating the digital filter I get its numerator (...
• 113
14k 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 ...
• 201
5k 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, ...
• 83
1k 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 ...
• 123
1 vote
6k 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 ...
• 113