resampling

Resampling irregularly spaced data to a regular grid in Python

半世苍凉 提交于 2019-11-27 03:01:47
I need to resample 2D-data to a regular grid. This is what my code looks like: import matplotlib.mlab as ml import numpy as np y = np.zeros((512,115)) x = np.zeros((512,115)) # Just random data for this test: data = np.random.randn(512,115) # filling the grid coordinates: for i in range(512): y[i,:]=np.arange(380,380+4*115,4) for i in range(115): x[:,i] = np.linspace(-8,8,512) y[:,i] -= np.linspace(-0.1,0.2,512) # Defining the regular grid y_i = np.arange(380,380+4*115,4) x_i = np.linspace(-8,8,512) resampled_data = ml.griddata(x,y,data,x_i,y_i) (512,115) is the shape of the 2D data, and I

Percentiles of Live Data Capture

你离开我真会死。 提交于 2019-11-26 18:55:13
问题 I am looking for an algorithm that determines percentiles for live data capture. For example, consider the development of a server application. The server might have response times as follows: 17 ms 33 ms 52 ms 60 ms 55 ms etc. It is useful to report the 90th percentile response time, 80th percentile response time, etc. The naive algorithm is to insert each response time into a list. When statistics are requested, sort the list and get the values at the proper positions. Memory usages scales

How do you do bicubic (or other non-linear) interpolation of re-sampled audio data?

☆樱花仙子☆ 提交于 2019-11-26 15:26:55
问题 I'm writing some code that plays back WAV files at different speeds, so that the wave is either slower and lower-pitched, or faster and higher-pitched. I'm currently using simple linear interpolation, like so: int newlength = (int)Math.Round(rawdata.Length * lengthMultiplier); float[] output = new float[newlength]; for (int i = 0; i < newlength; i++) { float realPos = i / lengthMultiplier; int iLow = (int)realPos; int iHigh = iLow + 1; float remainder = realPos - (float)iLow; float lowval = 0