Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

> :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)

> :warning: **Phase retrieval refactor version 0.14.9** :warning: Warning: The phase-retrieval modules in py4DSTEM (DPC, parallax, and ptychography) underwent a major refactor in version 0.14.9 and as such older tutorial notebooks will not work as expected. Notably, class names have been pruned to remove the trailing "Reconstruction" (`DPCReconstruction` -> `DPC` etc.), and regularization functions have dropped the `_iter` suffix (and are instead specified as boolean flags). See the [updated tutorials](https://github.com/py4dstem/py4DSTEM_tutorials) for more information.
Expand Down
2 changes: 2 additions & 0 deletions py4DSTEM/process/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@
except (ImportError, ModuleNotFoundError) as exc:
if not is_package_lite:
raise exc

from py4DSTEM.process.utils import Cluster
4 changes: 2 additions & 2 deletions py4DSTEM/process/diffraction/crystal.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def __init__(
# [a a a 90 90 90]
# [a b c 90 90 90]
# [a b c alpha beta gamma]
cell = np.asarray(cell, dtype="float_")
cell = np.array(cell, dtype="float")
if np.size(cell) == 1:
self.cell = np.hstack([cell, cell, cell, 90, 90, 90])
elif np.size(cell) == 3:
Expand Down Expand Up @@ -653,7 +653,7 @@ def calculate_structure_factors(
# Calculate single atom scattering factors
# Note this can be sped up a lot, but we may want to generalize to allow non-1.0 occupancy in the future.
f_all = np.zeros(
(np.size(self.g_vec_leng, 0), self.positions.shape[0]), dtype="float_"
(np.size(self.g_vec_leng, 0), self.positions.shape[0]), dtype="float"
)
for a0 in range(self.positions.shape[0]):
atom_sf = single_atom_scatter([self.numbers[a0]], [1], self.g_vec_leng, "A")
Expand Down
28 changes: 25 additions & 3 deletions py4DSTEM/process/diffraction/crystal_phase.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ def quantify_single_pattern(
plot_correlation_radius=False,
scale_markers_experiment=40,
scale_markers_calculated=200,
max_marker_size=400,
crystal_inds_plot=None,
phase_colors=None,
figsize=(10, 7),
Expand Down Expand Up @@ -615,16 +616,22 @@ def quantify_single_pattern(
qy0,
qx0,
# s = scale_markers_experiment * intensity0,
s=scale_markers_experiment
* bragg_peaks.data["intensity"][np.logical_not(keep)],
s=np.minimum(
scale_markers_experiment
* bragg_peaks.data["intensity"][np.logical_not(keep)],
max_marker_size,
),
marker="o",
facecolor=[0.7, 0.7, 0.7],
)
ax.scatter(
qy,
qx,
# s = scale_markers_experiment * intensity,
s=scale_markers_experiment * bragg_peaks.data["intensity"][keep],
s=np.minimum(
scale_markers_experiment * bragg_peaks.data["intensity"][keep],
max_marker_size,
),
marker="o",
facecolor=[0.7, 0.7, 0.7],
)
Expand Down Expand Up @@ -799,6 +806,7 @@ def quantify_phase(
strain_max=0.02,
include_false_positives=True,
weight_false_positives=1.0,
weight_unmatched_peaks=1.0,
progress_bar=True,
):
"""
Expand Down Expand Up @@ -899,6 +907,7 @@ def quantify_phase(
strain_max=strain_max,
include_false_positives=include_false_positives,
weight_false_positives=weight_false_positives,
weight_unmatched_peaks=weight_unmatched_peaks,
plot_result=False,
verbose=False,
returnfig=False,
Expand Down Expand Up @@ -1220,6 +1229,7 @@ def plot_dominant_phase(
self,
use_correlation_scores=False,
reliability_range=(0.0, 1.0),
normalize_exp_intensity=True,
sigma=0.0,
phase_colors=None,
ticks=True,
Expand Down Expand Up @@ -1302,6 +1312,11 @@ def plot_dominant_phase(
sigma=sigma,
mode="nearest",
)
self.phase_sig = phase_sig

# # normalize the signal by the intensity of each experimental pattern
# if normalize_exp_intensity:
# phase_sig /= self.int_total[None,:,:]

# find highest correlation score for each crystal and match index
for a0 in range(self.num_crystals):
Expand All @@ -1327,6 +1342,11 @@ def plot_dominant_phase(

# Estimate the reliability
phase_rel = phase_corr - phase_corr_2nd

# normalize the reliability by the intensity of each experimental pattern
if normalize_exp_intensity:
phase_rel /= self.int_total

phase_scale = np.clip(
(phase_rel - reliability_range[0])
/ (reliability_range[1] - reliability_range[0]),
Expand All @@ -1351,6 +1371,8 @@ def plot_dominant_phase(
sub = phase_map == a0
for a1 in range(3):
self.phase_rgb[:, :, a1][sub] = phase_colors[a0, a1] * phase_scale[sub]

self.phase_scale = phase_scale
# normalize
# self.phase_rgb = np.clip(
# (self.phase_rgb - rel_range[0]) / (rel_range[1] - rel_range[0]),
Expand Down
Loading
Loading