如何从2D数据中获取3D数据点

时间:2019-06-25 21:01:31

标签: python pandas 3d 2d data-analysis

我有两组互相垂直的2D数据。一组在x-y平面上,另一组在x-z平面上。换句话说,它们共享x轴。下面是我正在描述的粗略图。

Form of data

这些平面上的数据正在绘制每个点的强度,因此红色区域中的点的值为3,黄色区域中的点的值为2,依此类推。

我的目标是编写一个程序来关联这两个平面以创建3D表单。下面是我编写的代码。

mPoints1 = pd.DataFrame(columns = ['X','Y','Z','I'])
iPoints1 = pd.DataFrame(columns = ['X','Y','Z','I'])


#newV_transposed and newH_transposed.columns are the dataframes containing intensities for each value on the axis                  
for m in list(newV_transposed.columns.values): #This iterates through the x values of the x-y dataset
    for n in list(newH_transposed.columns.values): #This iterates through the x values of the x-z dataset
        if (m == n and 931.717<= m <=932.145): #check that we are looking at the intensity value associated with the same x in both sets of data
            ymatches = newV_transposed.loc[newV_transposed[m] == 3] #selecting all the rows that have an intensity of 3 in the x-y data set
            zmatches = newH_transposed.loc[newH_transposed[m] == 3] #selecting all the rows that have an intensity of 3 in the x-z data set
            ys = ymatches.index.values #storing all the y values of the rows
            zs = zmatches.index.values #storing all the z values of the rows
            for z in zs: #iterate through the z values found
                for y in ys: #iterate through the y values found
                    iPoints1 = iPoints1.append({'X': m, 'Y': y, 'Z': z, 'I': 3}, ignore_index=True)
                    # add a set of coordinates to the data frame iPoints one
                    # This nested loops ensures that I am layering a set of points along the z axis 

for m in list(newV_transposed.columns.values):
    for n in list(newH_transposed.columns.values):
        if (m == n and 931.717<= m <=932.145):       #and m == 932.505
            ymatches = newV_transposed.loc[newV_transposed[m] == 2]
            zmatches = newH_transposed.loc[newH_transposed[m] == 2]
            ys = ymatches.index.values
            zs = zmatches.index.values
            for z in zs:
                for y in ys:
                    mPoints1 = mPoints1.append({'X': m, 'Y': y, 'Z': z, 'I': 2}, ignore_index=True)

因此,我用红色绘制了存储在iPoints1中的坐标点,并用半透明的橙色绘制了mPoints1中的坐标点。下面是从不同角度观察到的我的结果的屏幕截图。

y-z perspective

这对我来说不太合适,因为橙色点似乎有所下降,这是我没想到的。我在导致下降的程序中做错了什么,我该如何解决?

x-y perspective

x-z perspective

感谢您的反馈,请告知我是否有其他信息可以帮助您。

0 个答案:

没有答案