Skip to content

Commit

Permalink
Override n_keep if n_best exceeds it
Browse files Browse the repository at this point in the history
  • Loading branch information
viljarjf committed Nov 19, 2024
1 parent 2dd9d50 commit adae5ef
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pyxem/signals/polar_diffraction2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
_mixed_matching_lib_to_polar,
_get_integrated_polar_templates,
_norm_rows,
_get_max_n,
)

from pyxem.utils._background_subtraction import (
Expand Down Expand Up @@ -346,6 +347,10 @@ def get_orientation(
Notes
-----
If :code:`n_best` exceeds :code:`n_keep` or :code:`frac_keep * N` for :code:`N` simulations,
then full correlation is performed on :code:`n_best` simulations instead. This ensures the
output contains :code:`n_best` simulations.
A gamma correction is often applied to the diffraction patterns. A good value
to start with is the square root (gamma=0.5) of the diffraction patterns to
increase the intensity of the low intensity reflections and decrease the
Expand Down Expand Up @@ -377,6 +382,11 @@ def get_orientation(
)
if normalize_templates:
intensities_templates = _norm_rows(intensities_templates)

max_n = _get_max_n(N=r_templates.shape[0], n_keep=n_keep, frac_keep=frac_keep)
if max_n < n_best:
# n_keep takes precedence over frac_keep, so this ensures we get n_best simulations in the result
n_keep = n_best
orientation = self.map(
_mixed_matching_lib_to_polar,
integrated_templates=integrated_templates,
Expand Down

0 comments on commit adae5ef

Please sign in to comment.