Hi! I want to write an algorithm to match a measurement made with x-ray difractometer with a cod data base with 500k entries to get the phases of the material.
The problem is i find either too much or the wrong ones.
at first I look for mathching angles and then if the intensit of the angles matches. I can send the code if somebody has time
tresholds --> change
eps_angle = 1
eps_I = 20
coincides_angle = 6
coincides_I = 5
counter = 0
data database
db_df = np.array(db_df)
sizes
num_data = len(db_df)
search through data base with loop (by matrix calculation evtl. faster, but it is still feasible with loop)
for i in range(num_data):
# definitions
I_ref = db_df[i, 2]
theta_ref = db_df[i, 3]
len_ref = len(theta_ref)
len_I = len(I_ref)
I_exp = np.array(I_peak[:10])
theta_exp = np.array(tt_peak[:10])
len_exp = len(theta_exp)
# data missing, shorten vectors to same size
if len_ref > len_exp:
theta_ref = theta_ref[:len_exp]
if len_ref < len_exp:
theta_exp = theta_exp[:len_ref]
# call the function
matched1, matched2, matched_indices1, matched_indices2 = \
match_arrays_with_threshold_and_indices(theta_exp, theta_ref, eps_angle)
num_matches = len(matched1)
if(num_matches > coincides_angle):
# check how many intensities coincide
bool_intensity = abs(I_exp[matched_indices1] - I_ref[matched_indices2]) < eps_I
if(sum(bool_intensity) > coincides_I):
counter += 1
print(db_df[i,0])
#print(matched2)
#print(I_ref[matched_indices2])
print(db_df[i, 1])
print(counter)