Remesh jagged test data

喜欢而已 提交于 2020-01-22 03:00:13

问题


Background

I have 4 sets of data for a brushed DC motor all collected from the same experiment:

  1. torque vs speed (T vs w)
  2. torque vs efficiency (T vs n)
  3. torque vs input power (T vs Pin)
  4. torque vs output power (T vs Pout)

However, each data set has:

  • slightly different x values for the first and last data pairs (T_0 and T_N do not match between each data set)
  • different spacing between each data point (dT is not the same for all sets)
  • different sizes ("T vs w" has more data pairs than "T vs Pin")

Problem

These differences prevent me from processing between data sets. For example, I can't use the T array of a single experiment for all my calculations, and I can't compare the measured Pout to a calculated Pout (T*w) at different T's.

What's the best way of re-sampling my data to generate uniformly-sized and uniformly-spaced sets?


Attempted solution

For each data set:
    find domain shared with all sets (max x_0 and min x_N between all x)
    extract indices corresponding to shared domain 
    #(idx = np.where(np.logical_and(x>=xMin,x<=xMax)))
    if set x_0 != shared x_0:
        linearly interpolate for new y_0 based on old x & y, shared x_0, and shared y_0
    Piecewise linear interpolation (my own custom function) of M data points in the set

However, this still gives me inconsistent results because the "timestep" for each re-meshed data set is still different from data set to data set.


Hypothesis

Use scipy's built-in interpolation libraries to generate a linear interpolation function for each data set and simply populate a new data table with the same start & stop indices and timestep.


UPDATE/solution

Writing this question out helped me quickly realize that scipy's interp1d function was the best solution for me especially since all my data points are ~linear. I solved my problem as follows:

  1. Looped through each data set to find the shared domain (min T_N, max T_0)
  2. Loop again (2nd loop necessary) and create interp1d function for each data set
  3. Evaluate the same uniformly-spaced domain with each interpolant
  4. Save results to text file

回答1:


One alternative would be to calculate piecewise linear interpolation functions for each of the data sets, as you say. I would include quadratic and cubic splines within this same broad class. You might instead be able to fit reasonable functions to each of data sets using curvefit. Then, you could choose max(T-0) as the starting point for all of the fitted functions, and likewise choose min(T-N) as the ending point for all of the fitted functions.



来源:https://stackoverflow.com/questions/47523526/remesh-jagged-test-data

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