Skip to content

Commit

Permalink
Remove "strict" keyword, always use the more permissive masking
Browse files Browse the repository at this point in the history
  • Loading branch information
ajjackson committed Aug 25, 2023
1 parent 3a50164 commit 9a846db
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions euphonic/spectra.py
Original file line number Diff line number Diff line change
Expand Up @@ -1614,8 +1614,7 @@ def from_dict(cls: Type[T], d: Dict[str, Any]) -> T:
def apply_kinematic_constraints(spectrum: Spectrum2D,
e_i: Quantity = None,
e_f: Quantity = None,
angle_range: Tuple[float] = (0, 180.),
strict: bool = True
angle_range: Tuple[float] = (0, 180.)
) -> Spectrum2D:
"""
Set events to NaN which violate energy/momentum limits:
Expand All @@ -1639,10 +1638,6 @@ def apply_kinematic_constraints(spectrum: Spectrum2D,
final energy of indirect-geometry spectrometer
angle_range
min and max scattering angles (2θ) of detector bank in degrees
strict
only include bins that lie entirely in accessible energy range at q-bin
centre; if False, include any bin that overlaps accessible energy range
at q-bin centre.
Returns
-------
Expand Down Expand Up @@ -1702,16 +1697,10 @@ def apply_kinematic_constraints(spectrum: Spectrum2D,

new_z_data = np.copy(spectrum.z_data.magnitude)

if strict:
mask = np.logical_or((spectrum.get_bin_centres(bin_ax='x')[:, np.newaxis]
< q_bounds[0][np.newaxis, :]),
(spectrum.get_bin_centres(bin_ax='x')[:, np.newaxis]
> q_bounds[1][np.newaxis, :]))
else:
mask = np.logical_or((spectrum.get_bin_edges(bin_ax='x')[1:, np.newaxis]
< q_bounds[0][np.newaxis, :]),
(spectrum.get_bin_edges(bin_ax='x')[:-1, np.newaxis]
> q_bounds[-1][np.newaxis, :]))
mask = np.logical_or((spectrum.get_bin_edges(bin_ax='x')[1:, np.newaxis]
< q_bounds[0][np.newaxis, :]),
(spectrum.get_bin_edges(bin_ax='x')[:-1, np.newaxis]
> q_bounds[-1][np.newaxis, :]))

new_z_data[mask] = float('nan')

Expand Down

0 comments on commit 9a846db

Please sign in to comment.