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.
The resample_poly function assumes "values beyond the boundary of the signal to be zero."
The decimate function can only downsample signals by some integer factors, not to  specific number of samples.
The upfirdn function requires FIR filter coefficients as inputs, which I am not sure how to get.


I have a signal that's NOT periodic and the values beyound the boundary of the signal are NOT zeros, and I want to downsample the singal from 611 samples to 100 samples.

Is there a simple way to do that in Python?

Thanks.

EDIT: The reason why I need to downsample signals to a fixed number of samples is that I have signals with different length, and I want to use those signals to train a 1D CNN for classification/regression tasks, which requires inputs of fixed size; I prefer not to use RNN/LSTM, although those models can accept inputs with various sizes.
I am doing something similar to your application with 1D CNN. I think scipy.resample_poly is the most versatile function since it allows both upsampling, downsampling, or a combination of both. 

Also your comment about "values beyond the boundary of the signal to be zero" can be solved by using the option "line" in padtype, as shown in the function documentation, in order to eliminate spurious effects at the head/tail of the signal. 

In general if the integer number of resampling factor is still an issue to you (but it shouldn't as you can play with the length of the signal) you can play with a combination of moving average followed by interpolation on the grid.