Questions tagged [scipy]
The scipy tag has no usage guidance.
193
questions
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 ...
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:
...
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 ...
1
vote
1
answer
98
views
3
votes
2
answers
919
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 ...
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:
...
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 ...
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 (<...
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 ...
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 ...
2
votes
2
answers
692
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 ...
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 ...
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
94
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 ...
0
votes
2
answers
525
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 ...
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, ...
1
vote
1
answer
794
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 ...
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
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}...
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 ...
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
411
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 ...
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 ...
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 ...
0
votes
2
answers
729
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 ...
0
votes
1
answer
336
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
vote
0
answers
517
views
Spectrogram of x,y,z data from accelerometer
Using scipy.signal.spectrogram for creating spectrogram and matplotlib's pcolormesh for plotting.
I'm working on a project where I'm using a spectrogram to visualize the frequencies of the ...
0
votes
1
answer
206
views
How to determine multiple Periodicities present in Timeseries data?
My objective is to detect all kinds of seasonalities and their time periods that are present in a timeseries waveform.
I'm currently using the following dataset:
https://www.kaggle.com/rakannimer/air-...
0
votes
0
answers
28
views
How can to obtain the transfer function of a bandpass digital filter? [duplicate]
I've been asked to: create a bandpass filter amplifier in python, determine the transfer function, graph the bode diagram, and print the highcut frequency, lowcut frequency, the bode constant and the ...
0
votes
1
answer
199
views
Fast Fourier transformation of discrete linear line function in Python using scipy.fft [closed]
Consider a time series dataset generated by a linear function
$$y = a \cdot n, \; n=0,1,...,N$$
According to this reference (entry 308 in the table for one-dimensional functions), the analytical ...
0
votes
0
answers
19
views
Creating 60s strips from ecg signal recording ( .bat ) file and give it a label as per the datapoint present in it
I am working with https://physionet.org/content/mitdb/1.0.0/ dataset where we have 48 ecg signal files.
Each recording is 30 minutes long and I Want to create 60s strips and give it a label. ie based ...
1
vote
2
answers
181
views
Scipy tf2zpk doesn't return zeros
I have the following transfer function:
$$H(z) =\frac{\alpha z}{(z-(1-\alpha))}$$
I'd like to find zeros and poles of it by scipy.signal.tf2zpk:
...
0
votes
1
answer
1k
views
How to set the "widths" parameter for continuous wavelet transform using Morlet wavelets? (scipy.signal.cwt)
I'm trying to use scipy.signal.cwt() to do a time-frequency decomposition of neural data. However, I don't completely understand the "widths" parameter.
I ...
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 ...
1
vote
0
answers
149
views
0
votes
1
answer
320
views
Remez function equivalency between Matlab and Scipy
I've read the similar question Find the equivalent of this python remez specs in C++ remez or Matlab firpm, which describes a different problem.
In Matlab, I have following ...
2
votes
2
answers
1k
views
How to implement cascaded biquad transfer functions in Python/SciPy
I am trying to implement in python/Scipy the biquad filter with the following S-domain transfer function:
$$
H(s)=\frac{w_0^{2N-1}(s+w_z)}{[s^2+(w_0/Q)s+w_0^2]^N}
$$
My problem here is that because of ...
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 ...