Downsampling signal from 100.21 Hz to 8 Hz (non-integer decimation factor)

痴心易碎 提交于 2021-02-09 09:36:32

问题


I have found the following method to downsample a signal in python. I would like to use this method with a sample_rate of 100.21 but I think currently it only works for integer powers of two. Is there a possibility to downsample my signal with frequency 100.21 Hz to 8 Hz?

def interpolateDataTo8Hz(data,sample_rate,startTime):
    # Downsample
    idx_range = range(0,len(data))
    data = data.iloc[idx_range[0::int(sample_rate)/8]]

    # Set the index to be 8Hz
    data.index = pd.DatetimeIndex(start=startTime,periods = len(data),freq='125L')

    # Interpolate all empty values
    data = interpolateEmptyValues(data)
    return data

def interpolateEmptyValues(data):
    cols = data.columns.values
    for c in cols:
        data[c] = data[c].interpolate()

    return data

来源:https://stackoverflow.com/questions/50301330/downsampling-signal-from-100-21-hz-to-8-hz-non-integer-decimation-factor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!