Skip to content

Commit 144406a

Browse files
committed
Merge branch 'diffraction' into HEAD
2 parents 2151c18 + a7d3d28 commit 144406a

File tree

9 files changed

+1041
-271
lines changed

9 files changed

+1041
-271
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
this is a test --
2+
13

24
> :warning: **py4DSTEM version 0.14 update** :warning: Warning: this is a major update and we expect some workflows to break. You can still install previous versions of py4DSTEM [as discussed here](#legacyinstall)
35

py4DSTEM/process/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,6 @@
1919
except (ImportError, ModuleNotFoundError) as exc:
2020
if not is_package_lite:
2121
raise exc
22+
23+
from py4DSTEM.process.utils import Cluster
24+

py4DSTEM/process/diffraction/crystal.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def __init__(
9797
# [a a a 90 90 90]
9898
# [a b c 90 90 90]
9999
# [a b c alpha beta gamma]
100-
cell = np.asarray(cell, dtype="float_")
100+
cell = np.array(cell, dtype="float")
101101
if np.size(cell) == 1:
102102
self.cell = np.hstack([cell, cell, cell, 90, 90, 90])
103103
elif np.size(cell) == 3:
@@ -653,7 +653,7 @@ def calculate_structure_factors(
653653
# Calculate single atom scattering factors
654654
# Note this can be sped up a lot, but we may want to generalize to allow non-1.0 occupancy in the future.
655655
f_all = np.zeros(
656-
(np.size(self.g_vec_leng, 0), self.positions.shape[0]), dtype="float_"
656+
(np.size(self.g_vec_leng, 0), self.positions.shape[0]), dtype="float"
657657
)
658658
for a0 in range(self.positions.shape[0]):
659659
atom_sf = single_atom_scatter([self.numbers[a0]], [1], self.g_vec_leng, "A")

py4DSTEM/process/diffraction/crystal_phase.py

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ def quantify_single_pattern(
102102
plot_correlation_radius=False,
103103
scale_markers_experiment=40,
104104
scale_markers_calculated=200,
105+
max_marker_size = 400,
105106
crystal_inds_plot=None,
106107
phase_colors=None,
107108
figsize=(10, 7),
@@ -615,16 +616,23 @@ def quantify_single_pattern(
615616
qy0,
616617
qx0,
617618
# s = scale_markers_experiment * intensity0,
618-
s=scale_markers_experiment
619-
* bragg_peaks.data["intensity"][np.logical_not(keep)],
619+
s=np.minimum(
620+
scale_markers_experiment
621+
* bragg_peaks.data["intensity"][np.logical_not(keep)],
622+
max_marker_size,
623+
),
620624
marker="o",
621625
facecolor=[0.7, 0.7, 0.7],
622626
)
623627
ax.scatter(
624628
qy,
625629
qx,
626630
# s = scale_markers_experiment * intensity,
627-
s=scale_markers_experiment * bragg_peaks.data["intensity"][keep],
631+
s=np.minimum(
632+
scale_markers_experiment
633+
* bragg_peaks.data["intensity"][keep],
634+
max_marker_size,
635+
),
628636
marker="o",
629637
facecolor=[0.7, 0.7, 0.7],
630638
)
@@ -799,6 +807,7 @@ def quantify_phase(
799807
strain_max=0.02,
800808
include_false_positives=True,
801809
weight_false_positives=1.0,
810+
weight_unmatched_peaks=1.0,
802811
progress_bar=True,
803812
):
804813
"""
@@ -899,6 +908,7 @@ def quantify_phase(
899908
strain_max=strain_max,
900909
include_false_positives=include_false_positives,
901910
weight_false_positives=weight_false_positives,
911+
weight_unmatched_peaks=weight_unmatched_peaks,
902912
plot_result=False,
903913
verbose=False,
904914
returnfig=False,
@@ -1220,6 +1230,7 @@ def plot_dominant_phase(
12201230
self,
12211231
use_correlation_scores=False,
12221232
reliability_range=(0.0, 1.0),
1233+
normalize_exp_intensity = True,
12231234
sigma=0.0,
12241235
phase_colors=None,
12251236
ticks=True,
@@ -1302,6 +1313,12 @@ def plot_dominant_phase(
13021313
sigma=sigma,
13031314
mode="nearest",
13041315
)
1316+
self.phase_sig = phase_sig
1317+
1318+
# # normalize the signal by the intensity of each experimental pattern
1319+
# if normalize_exp_intensity:
1320+
# phase_sig /= self.int_total[None,:,:]
1321+
13051322

13061323
# find highest correlation score for each crystal and match index
13071324
for a0 in range(self.num_crystals):
@@ -1327,6 +1344,12 @@ def plot_dominant_phase(
13271344

13281345
# Estimate the reliability
13291346
phase_rel = phase_corr - phase_corr_2nd
1347+
1348+
# normalize the reliability by the intensity of each experimental pattern
1349+
if normalize_exp_intensity:
1350+
phase_rel /= self.int_total
1351+
1352+
13301353
phase_scale = np.clip(
13311354
(phase_rel - reliability_range[0])
13321355
/ (reliability_range[1] - reliability_range[0]),
@@ -1351,6 +1374,8 @@ def plot_dominant_phase(
13511374
sub = phase_map == a0
13521375
for a1 in range(3):
13531376
self.phase_rgb[:, :, a1][sub] = phase_colors[a0, a1] * phase_scale[sub]
1377+
1378+
self.phase_scale = phase_scale
13541379
# normalize
13551380
# self.phase_rgb = np.clip(
13561381
# (self.phase_rgb - rel_range[0]) / (rel_range[1] - rel_range[0]),

0 commit comments

Comments
 (0)