Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import tkinter as tk
- from tkinter import filedialog
- import pandas as pd
- import, numpy as np
- from scipy.spatial.distance import pdist, squareform
- root = tk.Tk()
- root.withdraw()
- file_path = filedialog.askopenfilename()
- data = pd.read_excel(file_path)
- data = np.array(data, dtype=np.float)
- npoints, cols = data.shape
- pwdistance = np.zeros((npoints, npoints))
- pwresidual = np.zeros((npoints, npoints))
- for i in range(npoints):
- for j in range(npoints):
- pwdistance[i][j] = np.sqrt((data[:,0][i]-data[:,0][j])**2 + (data[:,1][i]-data[:,1][j])**2)
- pwresidual[i][j] = (data[:,2][i]-data[:,2][j])**2
- pwdistance = squareform(pdist(data[:,:2]))
- col2 = data[:,2]
- pwresidual = np.subtract.outer(col2, col2) ** 2
- pwresidual = (col2[:,np.newaxis] - col2[np.newaxis,:]) ** 2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement