#🔒 Python XRD Data Matching

4 messages · Page 1 of 1 (latest)

dire socket
#

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)

frozen schoonerBOT
#

@dire socket

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

frozen schoonerBOT
#

@dire socket

Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.