I have wrote the following code and am just having some last little issues that I could use some help with and once this is polished up, I figured this could be really useful to people doing data analysis on point proximity in the future.
The purpose of this code is to read in two separate lists of data as individual points and into a numpy array. From there the nested for loop is intended to take point one in file1 and compare its angular separation to each point in file2 then point 2 in file1 and compare it to each element in file2, so on and on.
The code had worked beautifully for all of my test files that have only around 100 elements in each. I am pretty sure the angular separation in spherical coordinates are written properly, and have converted the measurement to radians instead of degrees.
import numpy as np
import math as ma
filename1 = "C:\Users\Justin\Desktop\file1.data"
data1 = np.genfromtxt(filename1,
#print "data1", data1
filename2 = "C:\Users\Justin\Desktop\file2.data"
data2 = np.genfromtxt(filename2,
d = ma.acos(ma.sin(ma.radians(a))*ma.sin(ma.radians(b))
for coor1 in data1:
for coor2 in data2:
a = [coor1, coor1]
b = [coor2, coor2]
#print "a", a
#print "b", b
if d(a, b) < 0.0174533: # if true what happens
n += 1
print 'True', d(a,b)
if n == 0: # if false what happens
print 'False', d(a,b)
! Too much output to process
a = [coor1, coor1] b = [coor2, coor2]
After a little more research and getting some advice from colleagues about how to best test my code with different variables, I realized that the code I wrote is actually doing exactly what I want it to. And it seems (for now at least) everything is doing great. All I did was restrict my proximity search to a much smaller field since before it was returning 10,000 x 10,000 results while printing the distance, the coordinate points, and a T/F statement.
So when the search field is small enough, the code does exactly what I need it to, but as for why I was having the
too much output to process error I am not sure, but I will likely post another question on here trying to clarify that problem. Again, the above code is although perhaps brute force and basic in approach, it is a pretty efficient way of analyzing proximity of points across multiple tables in a for loop.