I am trying to write a coincidence analysis code comparing two text files in python.The code I have written is as follows:
datafile1 = np.loadtxt('some_file_1.txt')
datafile2 = np.loadtxt('some_file_2.txt')
SNR1 = datafile1[:,0]
peak1 = datafile1[:,1]
m11 = datafile1[:,2]
m12 = datafile1[:,3]
SNR2 = datafile2[:,0]
peak2 = datafile2[:,1]
m21 = datafile2[:,2]
m22 = datafile2[:,3]
f = open('out_file.txt', 'w')
F = datafile[:,1].astype(int)
for i in F:
for j in range(i-40,i+41):
if (m11[j] == m21[i] and m12[j] == m22[i]):
f.write(SNR1[j] + " " + peak1[j] + " " + m11[j])
f.write("\n")
f.close()
The code should take a value from "peak2", then compare it to all the values of "peak1". If the value of "peak1" is equal to or within a difference of +/- 40 from "peak2" and if the value of "m11" is equal to "m21" and if "m12" is equal to "m22", it should write the values of "peak1", "m11" and "m12" in a text file. The error I get is that "index 477358 is out of bounds for axis 0 with size 10000 ". I realize the error is regarding the indices, but I cannot figure out how to correct it in a way that works.