I wanted to decompose the following signal, a numpy array:
I’m currently using the seasonal_decompose function from statsmodels.tsa.seasonal:
https://www.statsmodels.org/dev/generated/statsmodels.tsa.seasonal.seasonal_decompose.html
My code:
myPeriod = 60
decompose_result_mult = seasonal_decompose(mySignal,
model="additive",period=myPeriod)
trend = decompose_result_mult.trend
seasonal = decompose_result_mult.seasonal
residual = decompose_result_mult.resid
moyen=trend
tempo=residual+seasonal
And what I get when I plot the moyen (orange) and tempo (green) variables:
The default value used for the trend is the mean value of the signal, and the tempo variable can then be negative. Is it possible to achieve the same thing but by taking the “minimal value” instead of the “mean value” of the function? Which would lead to the tempo variable being only positive. To illustrate what I mean it would be to use something like the following red line as the “trend” data, and get the corresponding tempo data:
How can I achieve this (I did not find how to change the way seasonal_decompose works nor how to achieve this with other functions)?