Questions tagged [scipy]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
1 answer
38 views

Welch method implementation not smooth

I have been trying to recreate the welch method implemented in scipy.signal by hand but my results don't look close enough in my opinion. How come the scipy.signal.welch method is displaying much ...
2 votes
1 answer
2k views

Help on audio filter with FFT on python

I need to take a .wav audio file that's noisy and filter out some noise. I have to do it using Fourier Transform. After some days researching and experimenting, I finally made a working function, the ...
2 votes
2 answers
386 views

Is there an a method to fit a wave created from two wave?

I need to get the frequency and amplitude for a wave that consists of multiple function. for example, if I have a sine curve (created from two sine waves), How can I extract the parameters for this ...
1 vote
1 answer
80 views

reproduce Scipy's stft

I failed to reproduce Scipy's stft. When I have tried to remove all the possible modifications and go the minimal example, I converge to the following: ...
0 votes
1 answer
72 views

Numerical issues in scipy's Savitzky Golay filter coefficients for large polynomial order

Consider the design of a Savitzky-Golay filter of window length 101 and (high) polynomial order 20. Using scipy version 1.10.1, the filter coefficients can be obtained in python as: ...
0 votes
2 answers
727 views

(Python - Scipy - Wave files) Can a float signal be written with values higher than 1?

While developing an application, I noticed strange behaviour while using scipy.io.wavfile to write audio files. The documentation says that floating-point data is written within a range between -1 and ...
1 vote
2 answers
162 views

How to construct a bandpass filter with minimal loss in amplitude/power near the lower and upper frequency limit in Python?

I am analyzing functional MRI data with a sampling rate of 1 second (1 Hz). The frequency band that I am interested in is 0.01-0.2 Hz. Regarding measurements, I am interested in computing (1) the ...
4 votes
2 answers
517 views

Why doesn't the convolution of the impulse response match the system's output?

If you define an LTI system sys in scipy, you may conveniently feed an input x to it to get ...
3 votes
3 answers
3k views

Difference between librosa.stft and scipy.signal.stft

I read the source code of librosa.stft and sicpy.signal.stft, and notice that the calculation results of STFT in these two libraries are quite different: In scipy.signal.stft, the stft result is ...
1 vote
1 answer
98 views

scipy/signal/_filter_design.py:1746: BadCoefficients: Badly conditioned filter coefficients

...
1 vote
2 answers
1k views

Rolling average in pandas using a Gaussian window

I want to estimate the rolling average of a time series B using a Gaussian window. The equation to do this would correspond to $$\tilde{B_{s}}(t_{n}) = \frac{1}{A_{s}} \sum_{t_{m}= t_{n}-3s}^{t_{n}+3s}...
1 vote
1 answer
793 views

How to generate a first order Gauss-Markov process in Python

I would like to synthesize a first order Gauss-Markov process from a white Gaussian noise. I know from signal processing theory that it could be realized using a noise shaping filter designed properly ...
5 votes
2 answers
653 views

Why is implementing a digital LPF with low cutoff frequency but high sampling frequency infeasible?

I am new to signal processing and I want to implement an LPF using SciPy. In order to do so, I used the following python code from: here The code itself looks like: ...
3 votes
2 answers
918 views

Why does scipy introduce its own convention for H(z) coefficients?

Conventionally, the definition of the system function for a IIR digital system is: $$H(z)=\frac{b_{0}+b_{1}z^{-1}+b_{2}z^{-2}+\cdots}{1-a_{1}z^{-1}-a_{2}z^{-2}-\cdots}$$ where coefficients are the ...
1 vote
2 answers
607 views

Scipy and Matlab Spectrogram not matching

I am trying to replicate a spectrogram from MATLAB in Python. I've read other posts but they either don't use complex data or the data doesn't match between languages. I've defined my FFT length (<...
1 vote
1 answer
203 views

Filtering with scipy sosfiltfilt generates flat edge artifact

I need to filter some array of data before differentiating it, I do this so I don't drown the signal in noise. It's also important that no delay is applied to the signal, that's why I decided to use a ...
0 votes
0 answers
90 views

Initial conditions of backward filter for forward-backward filtering on chunked real data in python

I have to apply a downsampling filter on a realtime data stream (signal) and I want to do it in python. The data is sampled at 16 kHz and loaded in a loop in chunks of 1 second. I have to downsample ...
2 votes
2 answers
690 views

Amplitude extraction using STFT

I'm trying to recover amplitude/magnitude from an audio stream. I'm using FFT to go from time domain to frequency. If I feed in a signal of known amplitude, the results I get from either windowing or ...
2 votes
2 answers
460 views

Why does changing the format of an audio file from int16 to float produce jitter?

I read an audio file (an instrumental music file that is mono and 16000) with wav.read (read function from scipy.io.wavfile.) This function gives me a data file in int16 format. When I change the type ...
4 votes
1 answer
385 views

Scipy filter analog vs. digital

It would be greatly appreciated if the usage of the python package scipy's filter (e.g. butter) analog=True argument could be explained. I don't understand what is meant by this (any signal being ...
0 votes
0 answers
158 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:...
1 vote
1 answer
135 views

using scipy.signal.sosfilt to filter a stereo signal with zi, zf

I'm stuck trying to filter a two-channel signal using sosfilt() with the zi initial state. I need to use the zi parameter so I can carry the filter state over ...
0 votes
1 answer
319 views

python how to demodulate iq fm signal that was moved to 0 frequency

I am struggling with implementing FM demodulation for IQ samples that has 0 center frequency from RTL-SDR ... I have found the following algorithm for FM demodulation, see FM demodulation: ...
0 votes
0 answers
15 views

Extract PVC feature from singal to train the ML model with PVC characteristics

I have ML model which is trained on Afib, Normal, Other - 3 class. Currently when I am testing the model with unseen database, sometimes it identify PVC singals as Afib class. For example - enter ...
1 vote
2 answers
138 views

Possible error when finding group/phase delay in scipy

After designing a "least square optimal" FIR filter I wanted to find the group/phase delay, defined as: $P(\omega) \triangleq - \frac{\Theta(\omega)}{\omega}$ (Depending on the literature ...
3 votes
4 answers
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. ...
2 votes
1 answer
206 views

find out ideal window size for coherence analysis - python

Is there a general formula I could use to calculate the ideal window for the window argument in the function ...
0 votes
1 answer
337 views

Signal Reconstruction Using Scipy.signal.cwt

Can someone explain to me how I can reconstruct a signal using the scipy.signal.morlet2? The codes in the link only allows one to do a fourier transform using the morlet wavelet, but there is no such ...
1 vote
0 answers
38 views

Convert MUSIC algorithm to EV

I write some code, but result looks very strange: ...
1 vote
0 answers
93 views

Prony method doesn't work

I have used the code from: https://github.com/quantumlib/OpenFermion/blob/v1.5.1/src/openfermion/linalg/wave_fitting.py#L41-L76 try using with my signal: ...
0 votes
1 answer
63 views

Why is DFT magnitude less than expected?

Code for signal: ...
2 votes
1 answer
225 views

scipy convolve and fftconvolve return different output [closed]

I'm writing an autocorrelation function using and I noticed a difference between fftconvolve and convolve that should use fft if it's faster. This is my function with convolve: ...
0 votes
1 answer
256 views

Vectorizing a biquad filter (python / numpy)

I'm having a lot of fun writing signal processing code in Python / numpy, and I'm resisting the urge to pre-optimize the code. But my biquad implementation is slower than I want. Here's the inner ...
1 vote
1 answer
9k 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 ...
0 votes
0 answers
298 views

Jerk detection in accelerometer data

I want to detect jerk from accelerator data i.e. values beyond 1.57 m/s^2, but due to the high frequency nature of the sensor (400 values per second), it gives multiple jerks instead of one. How can I ...
0 votes
2 answers
524 views

How to convert between 2d convolution and 2d cross-correlation?

I am using cross-correlation for the purposes of image stabilisation. The images which I'm processing can sometimes be rather large. The contents of the image are often repeating patterns. For these ...
7 votes
3 answers
1k 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 ...
1 vote
1 answer
435 views

detrend a signal with break point but without jumps

Yesterday I asked a question and got the answer to detrend my time series which I think is really better than applying a highpass filter. So I read the description of scipy.signal.detrend and there I ...
2 votes
1 answer
1k views

filtering EEG data with scipy.signal

I have EEG data recorded with a sampling rate of 256 Hz. Each recording contains 19 EEG channels. Other channels (like ECG data) are ignored. The recordings of 10 patients are 20 minutes long each, ...
3 votes
1 answer
378 views

How to get scipy remez to give matlab firpm answer?

If I run this in matlab: h = firpm(100,[0 0.1 0.2 1],[0 0 1 1]) and this in scipy: h = remez(100,[0, 0.05, 0.1, 0.5],[0, 1]) I ...
1 vote
1 answer
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 ...
1 vote
2 answers
407 views

Constraints on number of taps in a FIR filter vs. FFT length

I want to implement a FIR highpass filter for acoustic signals. I generate the FIR using Python's SciPy code: ...
0 votes
1 answer
410 views

Why does Python welch give me a different answer from MATLAB's pwelch?

I am trying to implement the following line of MATLAB code: [pxx, f] = pwelch(data,[],[],4096,F_S) in Python. Knowing that MATLAB using a Hamming window type that ...
3 votes
1 answer
572 views

How does SciPy's Welch function change the shape of the data?

I am working with some time series data with a shape of 8064. The data is actually the popular EEG data called DEAP. It basically is a 3D array of size (40, 40, 8064) and here is the link to the ...
0 votes
0 answers
83 views

Decimate a signal whose values are calculated, not stored

tl;dr I'm looking for something like Scipy's decimate function, but one that takes in a generator, rather than a Numpy array. I am turning on and off a light using ...
3 votes
2 answers
289 views

Getting error while performing upsampling of an audio signal processing using low pass filter in python

I want to perform upsampling of an audio signal introducing zeros between samples to create a longer signal with factor of N=2. The sampling rate is 44100Hz, time = 5sec. ...
0 votes
0 answers
129 views

Understanding FFT bins interpretability

I am familiar with the continuous Fourier transform yet the more I try to understand FFT, the more I'm confused. If we've got a discrete N sample signal, FFT is a faster way to calculate DFT. If ...
-1 votes
1 answer
223 views

Why use both a high pass and a low pass filter in a Butterworth implementation for noise reduction?

I am a new to audio processing . I want to develop an application that reduces audio noise using a Butterworth filter. I found some existing code doing this, but I still do not understand the use of ...
0 votes
1 answer
335 views

Simulation of Lock-In Amplification in Python makes no sense

I would like to simulate a basic lock-in amplification for post-processing some data. I wrote a basic Python script for this purpose but the output of the lock-in amplification does not seem to make ...
-1 votes
1 answer
274 views

scipy.signal.stft temporal resolution

Using the STFT function from scipy.signal has produced unexpected results for me. I am performing an STFT on 10 seconds of data, sampled at 25,000 Hz. I am using STFT settings of nperseg=256 and ...