Skip to content
Open
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
16 changes: 16 additions & 0 deletions lcls_tools/common/image/fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ class ImageProjectionFit(ImageFit):
Fit amplitude to noise threshold for the fit. If the amplitude of the fit is below this
threshold times the noise standard deviation and `validate_fit` is True,
the fit parameters will be set to NaN.
min_beam_size: PositiveFloat
Minimum beam size in pixels for the fit. If the beam size of the fit is below this threshold,
and 'validate_fit' is True, the fit parameters will be set to NaN.
beam_extent_n_stds : PositiveFloat
Number of standard deviations on either side to use for the beam extent. If the beam
extent is outside the image and `validate_fit` is True, the fit parameters will be set to NaN.
Expand All @@ -94,6 +97,9 @@ class ImageProjectionFit(ImageFit):
signal_to_noise_threshold: PositiveFloat = Field(
2.0, description="Fit amplitude to noise threshold for the fit"
)
min_beam_size: PositiveFloat = Field(
1.0, description="Minimum beam size in pixels to accept for validation"
)
beam_extent_n_stds: PositiveFloat = Field(
2.0,
description="Number of standard deviations on either side to use for the beam extent",
Expand Down Expand Up @@ -164,3 +170,13 @@ def _validate_parameters(
warnings.warn(
f"Projection in {dim} was off the screen, fit cannot be trusted"
)

# if the beam size is smaller than the specified minimum number of pixels, fits cannot be trusted
if self.min_beam_size is not None:
if parameters["sigma"] < self.min_beam_size:
for name in parameters.keys():
parameters[name] = np.nan

warnings.warn(
f"Projection in {dim} had too small a beam size, fit cannot be trusted"
)
Loading