重新啮合锯齿状的测试数据 [英] Remesh jagged test data

查看:50
本文介绍了重新啮合锯齿状的测试数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

背景

我有4组有刷直流电动机的数据全部是从同一实验中收集的:

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

  1. 扭矩与速度(T与w)
  2. 转矩与效率(T与n)
  3. 转矩与输入功率(T与引脚)
  4. 转矩与输出功率(T与Pout)

但是,每个数据集都有:

However, each data set has:

  • 第一个和最后一个数据对的x值略有不同(每个数据集之间的T_0和T_N不匹配)
  • 每个数据点之间的间距不同(所有集合的dT都不相同)
  • 不同大小("T vs w"比"T vs Pin"具有更多的数据对)

问题

这些差异使我无法在数据集之间进行处理.例如,我不能将单个实验的T数组用于所有计算,也无法将在不同T处测得的Pout与计算出的Pout(T * w)进行比较.

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?

尝试的解决方案

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.

假设

使用scipy的内置插值库为每个数据集生成线性插值函数,并使用相同的开始&停止索引和时间步长.

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.

更新/解决方案

解决这个问题使我很快意识到scipy的interp1d函数对我来说是最好的解决方案,特别是因为我所有的数据点都是线性的.我解决了如下问题:

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. 遍历每个数据集以找到共享域(最小T_N,最大T_0)
  2. 再次循环(第二循环必要),并为每个数据集创建interp1d函数
  3. 使用每个插值评估相同的均匀间隔域
  4. 将结果保存到文本文件
  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

如您所说,

推荐答案

一种替代方法是为每个数据集计算分段线性插值函数.我将在同一大类中包含二次和三次样条.相反,您可能可以使用Curvefit将合理的函数拟合到每个数据集.然后,您可以选择max(T-0)作为所有拟合函数的起点,并且同样选择min(T-N)作为所有拟合函数的终点.

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.

这篇关于重新啮合锯齿状的测试数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆