avoid casting of numpy arrays since it will behave strangely in certain archs
# cython: language_level=3
# cython: profile=True
-# Time-stamp: <2020-12-02 15:49:58 Tao Liu>
+# Time-stamp: <2020-12-03 17:16:24 Tao Liu>
"""Module Description: functions to find maxima minima or smooth the
signal tracks.
@@ -33,13 +33,17 @@ cpdef np.ndarray[int32_t, ndim=1] maxima(np.ndarray[float32_t, ndim=1] signal,
cdef:
np.ndarray[int32_t, ndim=1] m
np.ndarray[float64_t, ndim=1] smoothed
- np.ndarray[float32_t, ndim=1] sign, diff
+ np.ndarray[float64_t, ndim=1] sign, diff
window_size = window_size//2*2+1 # to make an odd number
smoothed = savitzky_golay_order2_deriv1(signal, window_size).round(16)
- sign = np.sign( smoothed.astype("float32") )
+ #print(f"\n{smoothed}")
+ sign = np.sign( smoothed )
+ #print(f"\n{sign}")
diff = np.diff( sign )
- m = np.where( diff <= -1)[0].astype('int32')
+ #print(f"\n{diff}")
+ m = np.where( diff <= -1)[0].astype("int32")
+ #print(f"\n{m}")
return m
cdef np.ndarray[int32_t, ndim=1] internal_minima( np.ndarray[float32_t, ndim=1] signal,
