Skip to content

Commit

Permalink
fixing upsampling limits
Browse files Browse the repository at this point in the history
  • Loading branch information
gvarnavi committed Dec 20, 2023
1 parent f8848c9 commit 8a561a3
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions py4DSTEM/process/phase/iterative_parallax.py
Original file line number Diff line number Diff line change
Expand Up @@ -1281,22 +1281,33 @@ def subpixel_alignment(
xy_shifts = self._xy_shifts
BF_size = np.array(self._stack_BF_unshifted.shape[-2:])

BF_sampling = 1 / asnumpy(self._kr).max()
BF_sampling = 1 / asnumpy(self._kr).max() / 2
DF_sampling = 1 / (
self._reciprocal_sampling[0] * self._region_of_interest_shape[0] / 2
self._reciprocal_sampling[0] * self._region_of_interest_shape[0]
)

self._BF_upsample_limit = self._scan_sampling[0] / BF_sampling
self._DF_upsample_limit = self._scan_sampling[0] / DF_sampling

if self._DF_upsample_limit < 1:
warnings.warn(
(
f"Dark-field upsampling limit of {self._DF_upsampling_limit:.2f} "
"is less than 1, implying a scan step-size smaller than Nyquist. "
"setting to 1."
),
UserWarning,
)
self._DF_upsample_limit = 1

if kde_upsample_factor is None:
if self._BF_upsample_limit * 3 / 2 > self._DF_upsample_limit:
kde_upsample_factor = self._DF_upsample_limit

warnings.warn(
(
f"Upsampling factor set to {kde_upsample_factor:.2f} (the "
f"dark-field upsampling limit)."
"dark-field upsampling limit)."
),
UserWarning,
)
Expand All @@ -1312,7 +1323,7 @@ def subpixel_alignment(
UserWarning,
)
else:
kde_upsample_factor = self._DF_upsample_limit * 2 / 3
kde_upsample_factor = np.maximum(self._DF_upsample_limit * 2 / 3, 1)

warnings.warn(
(
Expand Down

0 comments on commit 8a561a3

Please sign in to comment.