ktk.TimeSeries.get_sample_rate

ktk.TimeSeries.get_sample_rate#

TimeSeries.get_sample_rate()[source]#

Get the sample rate in samples/s.

Returns:

The sample rate in samples per second. If time is empty or has only one data, or if sample rate is variable, or if time is not monotonously increasing, a value of np.nan is returned.

Return type:

float

Warning

This feature, which has been introduced in version 0.9, is still experimental and may change in the future. In particular, the value returned if the sample rate is not constant: it is np.nan in all cases for now, but it could change in the future based on discussions and particular use cases.

Example

>>> ts = ktk.TimeSeries(time=np.arange(100)/10)  # 100 samples at 10 Hz
>>> ts.get_sample_rate()
10.0