Questions tagged [scipy]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1 vote
1 answer
58 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: ...
Gideon Genadi Kogan's user avatar
0 votes
1 answer
62 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: ...
rhz's user avatar
  • 375
1 vote
2 answers
115 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 ...
Philipp's user avatar
  • 113
1 vote
1 answer
74 views

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

...
yahugh's user avatar
  • 11
3 votes
2 answers
886 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 ...
mins's user avatar
  • 433
5 votes
2 answers
596 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: ...
gvg's user avatar
  • 53
1 vote
1 answer
146 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 ...
Guille's user avatar
  • 29
0 votes
0 answers
64 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 ...
GWSurfer's user avatar
0 votes
2 answers
446 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 (<...
PrematureCorn's user avatar
4 votes
1 answer
347 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 ...
Joseph's user avatar
  • 223
1 vote
1 answer
99 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 ...
fearless_fool's user avatar
2 votes
2 answers
484 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 ...
dizzy's user avatar
  • 243
0 votes
1 answer
204 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: ...
Denis Kotov's user avatar
0 votes
0 answers
14 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 ...
techcrazy's user avatar
1 vote
2 answers
120 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 ...
Casper's user avatar
  • 13
2 votes
1 answer
155 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 ...
HappyPy's user avatar
  • 133
0 votes
1 answer
228 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 ...
VA157's user avatar
  • 3
1 vote
0 answers
37 views

Convert MUSIC algorithm to EV

I write some code, but result looks very strange: ...
Dmitry  Sokolov's user avatar
1 vote
0 answers
80 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: ...
Dmitry  Sokolov's user avatar
0 votes
1 answer
63 views

Why is DFT magnitude less than expected?

Code for signal: ...
Dmitry  Sokolov's user avatar
2 votes
1 answer
175 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: ...
Adam Katav's user avatar
0 votes
1 answer
212 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 ...
fearless_fool's user avatar
0 votes
2 answers
381 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 ...
I hate coding's user avatar
1 vote
1 answer
343 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 ...
Hubert Schölnast's user avatar
2 votes
1 answer
841 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, ...
Hubert Schölnast's user avatar
1 vote
1 answer
642 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 ...
eljamba's user avatar
  • 11
3 votes
1 answer
336 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 ...
Mastiff's user avatar
  • 141
1 vote
2 answers
995 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}...
Jokerp's user avatar
  • 169
0 votes
0 answers
253 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 ...
gladi8er's user avatar
1 vote
2 answers
326 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: ...
Triceratops's user avatar
0 votes
1 answer
337 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 ...
JoJo's user avatar
  • 3
3 votes
1 answer
463 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 ...
Saturn_4's user avatar
0 votes
0 answers
75 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 ...
Kevin's user avatar
  • 101
2 votes
2 answers
342 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 ...
Soheila Hesaraki's user avatar
0 votes
0 answers
119 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 ...
X HOxha's user avatar
0 votes
2 answers
633 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 ...
Alexandre Piccini's user avatar
0 votes
1 answer
270 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 ...
Mantabit's user avatar
  • 121
1 vote
0 answers
463 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 ...
Mathias's user avatar
  • 11
0 votes
1 answer
170 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-...
EnigmAI's user avatar
  • 11
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 ...
Marcia Cocozza's user avatar
0 votes
1 answer
153 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 ...
Jayyu's user avatar
  • 131
0 votes
0 answers
17 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 ...
user2129623's user avatar
1 vote
2 answers
154 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: ...
Curious's user avatar
  • 345
0 votes
1 answer
965 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 ...
neverreally's user avatar
1 vote
0 answers
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 ...
Isaac's user avatar
  • 11
1 vote
0 answers
121 views

`signal.periodogram` output has no frequency 0 hz point,how to solve this problem?

...
kittygirl's user avatar
  • 175
0 votes
1 answer
293 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 ...
Miguel de Sousa's user avatar
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 ...
papaya's user avatar
  • 43
4 votes
2 answers
462 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 ...
arash's user avatar
  • 83
1 vote
1 answer
1k views

Can someone explain why signal.freqz() generates a different phase in the frequency fresponse than scipy.signal.dfreqresp()?

I have been using scipy to analyze filter performance for a single-pole IIR filter, and I noticed a disagreement between the phase in the outputs of the freqz() function compared to the output of the ...
DrEsperanto's user avatar