Skip to content

Commit d655283

Browse files
committed
Make safe and other options of sigma_clip_ng available in legacy
1 parent a3ae414 commit d655283

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

pyFAI/azimuthalIntegrator.py

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2899,21 +2899,21 @@ def medfilt1d(self, data, npt_rad=1024, npt_azim=512,
28992899
return result
29002900

29012901
def sigma_clip_legacy(self, data, npt_rad=1024, npt_azim=512,
2902-
correctSolidAngle=True, polarization_factor=None,
2903-
radial_range=None, azimuth_range=None,
2904-
dark=None, flat=None,
2905-
method="splitpixel", unit=units.Q,
2906-
thres=3, max_iter=5, dummy=None, delta_dummy=None,
2907-
mask=None, normalization_factor=1.0, metadata=None):
2902+
correctSolidAngle=True, polarization_factor=None,
2903+
radial_range=None, azimuth_range=None,
2904+
dark=None, flat=None,
2905+
method=("full", "histogram", "cython"), unit=units.Q,
2906+
thres=3, max_iter=5, dummy=None, delta_dummy=None,
2907+
mask=None, normalization_factor=1.0, metadata=None,
2908+
safe=True, **kwargs):
29082909
"""Perform first a 2D integration and then an iterative sigma-clipping
29092910
filter along each row. See the doc of scipy.stats.sigmaclip for the
29102911
options `thres` and `max_iter`.
29112912
29122913
:param data: input image as numpy array
2913-
:param npt_rad: number of radial points
2914+
:param npt_rad: number of radial points (alias: npt)
29142915
:param npt_azim: number of azimuthal points
2915-
:param bool correctSolidAngle: correct for solid angle of each pixel
2916-
if True
2916+
:param bool correctSolidAngle: correct for solid angle of each pixel when set
29172917
:param float polarization_factor: polarization factor between -1 (vertical)
29182918
and +1 (horizontal).
29192919
@@ -2928,17 +2928,22 @@ def sigma_clip_legacy(self, data, npt_rad=1024, npt_azim=512,
29282928
:param ndarray flat: flat field image
29292929
:param unit: unit to be used for integration
29302930
:param method: pathway for integration and sort
2931-
:param thres: cut-off for n*sigma: discard any values with `|I-<I>|/sigma > thres`.
2931+
:param thres: cut-off for n*sigma: discard any values with `|I-<I>| > thres`.
29322932
The threshold can be a 2-tuple with sigma_low and sigma_high.
29332933
:param max_iter: maximum number of iterations
29342934
:param mask: masked out pixels array
29352935
:param float normalization_factor: Value of a normalization monitor
29362936
:param metadata: any other metadata,
29372937
:type metadata: JSON serializable dict
2938+
:param safe: unset to save some checks on sparse matrix shape/content.
29382939
:return: Integrate1D-like result
29392940
29402941
Nota: The initial 2D-integration requires pixel splitting
29412942
"""
2943+
#compatibility layer with sigma_clip_ng
2944+
if "npt" in kwargs:
2945+
npt_rad = kwargs["npt"]
2946+
29422947
# We use NaN as dummies
29432948
if dummy is None:
29442949
dummy = numpy.NaN
@@ -2966,7 +2971,7 @@ def sigma_clip_legacy(self, data, npt_rad=1024, npt_azim=512,
29662971
dummy=dummy, delta_dummy=delta_dummy,
29672972
correctSolidAngle=correctSolidAngle,
29682973
polarization_factor=polarization_factor,
2969-
normalization_factor=normalization_factor)
2974+
normalization_factor=normalization_factor,safe=safe)
29702975
image = res2d.intensity
29712976
if (method.impl_lower == "opencl"):
29722977
if (method.algo_lower == "csr") and \
@@ -3079,7 +3084,7 @@ def sigma_clip_ng(self, data,
30793084
30803085
Keep only pixels with intensty:
30813086
3082-
``|I - <I>| < thres * std(I)``
3087+
``|I - <I>| < thres * σ(I)``
30833088
30843089
This enforces a symmetric, bell-shaped distibution (i.e. gaussian-like) and is very good at extracting
30853090
background or amorphous isotropic scattering out of Bragg peaks.

0 commit comments

Comments
 (0)