How about this answer here? In the accepted answer the procedure is described in detail along with an explanation on how to interpret the final result.
Edit:
The main idea is to try and catch the period of the signal by performing a convolution of the function with itself, as the convolution features peaks at each multiple of the period (see also this page).
The accepted answer is taking the data, rounding them (though it is not necessary), subtracting the mean value in order to avoid a peak of the Fourier transform and then apply the self convolution. Then one needs to adjust the plot in order to clearly see periodicity.
import numpy as np
import scipy.signal
from matplotlib import pyplot as plt
L = np.array([2.762, 2.762, 1.508, 2.758, 2.765, 2.765, 2.761, 1.507, 2.757, 2.757, 2.764, 2.764, 1.512, 2.76, 2.766, 2.766, 2.763, 1.51, 2.759, 2.759, 2.765, 2.765, 1.514, 2.761, 2.758, 2.758, 2.764, 1.513, 2.76, 2.76, 2.757, 2.757, 1.508, 2.763, 2.759, 2.759, 2.766, 1.517, 4.012])
L = np.round(L, 1)
# Remove DC component
L -= np.mean(L)
# Window signal
#L *= scipy.signal.windows.hann(len(L))
fft = np.fft.rfft(L, norm="ortho")
def abs2(x):
return x.real**2 + x.imag**2
selfconvol=np.fft.irfft(abs2(fft), norm="ortho")
selfconvol=selfconvol/selfconvol[0]
# This figure does not look right as its size is not a multiple of the period
plt.figure()
plt.plot(selfconvol)
plt.savefig('first.jpg')
plt.show()
# let's get a max, assuming a least 4 periods...
multipleofperiod=np.argmax(selfconvol[1:len(L)//4])
Ltrunk=L[0:(len(L)//multipleofperiod)*multipleofperiod]
fft = np.fft.rfft(Ltrunk, norm="ortho")
selfconvol=np.fft.irfft(abs2(fft), norm="ortho")
selfconvol=selfconvol/selfconvol[0]
plt.figure()
plt.plot(selfconvol)
plt.savefig('second.jpg')
plt.show()
(Code copied and pasted from the answer linked -- I have tried and look after all the issues with my version of Python, 3.10.8)