Interpolation with Python is very easy and can be done directly using interpolate in scipy
import numpy as np x1 = (1, 4096, 1024) x_new = (1, 4096, 4096) from scipy import interpolate tck = (x1, data) y_bspline = (x_new, tck)
Where y_bspline is the 4096 data interpolated from 1024
However, there doesn't seem to be a function for downsampling in scipy, hmmm... Is it because it's too simple, but it seems to be done with a loop, but if you think of the vector as a time series, it's also very easy to sample at different frequencies using the date_range module in pandas, and a lot of operations on files are done using pandas.
import pandas as pd index = pd.date_range('1/1/2000', periods=4096, freq='T') # This start time is arbitrarily specified and freq is its frequency data = pd.read_table(filename, names=['feat']) = index data_obj = ('4T', label='right') # The first one is the sampling frequency, label indicates the left and right opening and closing intervals data_new = data_new.asfreq()[0:]
Because it returns an object
So to get the value in it you can get it via data_new.asfreq()[0:]
More methods are detailed in
This Python interpolation and downsampling of data above is all I have to share with you.