Skip to content

Commit 26c0cf7

Browse files
committed
continue
1 parent b62baf4 commit 26c0cf7

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

pyxtal/XRD_indexer.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,6 @@ def get_cell_from_multi_hkls(spg, hkls, two_thetas, long_thetas=None, wave_lengt
423423
if len(cells) == 0: return None
424424
cells = np.unique(cells, axis=0)#; print(cells) # remove duplicates
425425

426-
# Try all possible hkls for this peak - vectorized version
427426
# get the maximum h from assuming the cell[-1] is (h00)
428427
d_100s = get_d_hkl_from_cell(spg, cells, 1, 0, 0)
429428
d_010s = get_d_hkl_from_cell(spg, cells, 0, 1, 0)
@@ -441,16 +440,15 @@ def get_cell_from_multi_hkls(spg, hkls, two_thetas, long_thetas=None, wave_lengt
441440
l_max=l_maxs[i],
442441
level=level))
443442
expected_thetas = calc_two_theta_from_cell(spg, test_hkls, cell, wave_length)
444-
445-
# Now try to index all other peaks using this 'a'
446-
matched_peaks = [] # (index, hkl, obs_theta, error)
447-
448443
# Filter out None values
449444
valid_mask = expected_thetas != None
450445
valid_thetas = expected_thetas[valid_mask]
451446
valid_hkls = test_hkls[valid_mask]
447+
# Now try to index all other peaks using this 'a'
448+
452449
if len(valid_thetas) > 0:
453450
valid_thetas = np.array(valid_thetas, dtype=float)
451+
matched_peaks = [] # (index, hkl, obs_theta, error)
454452

455453
for peak_idx, obs_theta in enumerate(long_thetas):
456454
best_match = None
@@ -463,7 +461,8 @@ def get_cell_from_multi_hkls(spg, hkls, two_thetas, long_thetas=None, wave_lengt
463461
valid_indices = np.where(within_tolerance)[0]
464462
best_idx = valid_indices[min_idx]
465463
best_error = errors[best_idx]
466-
best_match = (peak_idx, tuple(valid_hkls[best_idx]), obs_theta, best_error)
464+
#best_match = (peak_idx, tuple(valid_hkls[best_idx]), obs_theta, best_error)
465+
best_match = (peak_idx, obs_theta, best_error)
467466

468467
#print(cell, peak_idx, best_match)
469468
if best_match is not None: matched_peaks.append(best_match)
@@ -472,7 +471,7 @@ def get_cell_from_multi_hkls(spg, hkls, two_thetas, long_thetas=None, wave_lengt
472471
n_matched = len(matched_peaks)
473472
if n_matched >= min_matched_peaks:
474473
coverage = n_matched / len(long_thetas)
475-
avg_error = np.mean([match[3] for match in matched_peaks])
474+
avg_error = np.mean([match[2] for match in matched_peaks])
476475
consistency_score = 1.0 / (1.0 + avg_error) # lower error = higher score
477476
total_score = coverage * consistency_score
478477

@@ -524,9 +523,9 @@ def get_cell_from_multi_hkls(spg, hkls, two_thetas, long_thetas=None, wave_lengt
524523
hkls_t = np.tile(guess, (int(len(thetas)/len(guess)), 1))
525524

526525
result = get_cell_from_multi_hkls(spg, hkls_t, thetas, long_thetas, use_seed=False)
527-
if result is not None and result['score'] > 0.95:
526+
if result is not None and result['score'] > 0.98:
528527
d2 = np.sum(guess**2)
529-
print("Guess:", guess.flatten(), d2, "->", result['cell'], thetas[0], "Score:", result['score'])
528+
print("Guess:", guess.flatten(), d2, "->", result['cell'], thetas[:len(guess)], "Score:", result['score'])
530529
if result['score'] > 0.992:
531530
cell1 = np.sort(np.array(result['cell']))
532531
diff = np.sum((cell1 - cell_ref)**2)

0 commit comments

Comments
 (0)