From 5f61cf8d379b584771714920ac9f2a75aa93add1 Mon Sep 17 00:00:00 2001 From: Jerome Kieffer Date: Mon, 18 Nov 2024 11:22:22 +0100 Subject: [PATCH] Use same API as cython --- src/pyFAI/engines/CSR_engine.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/pyFAI/engines/CSR_engine.py b/src/pyFAI/engines/CSR_engine.py index 178f8903c..4a79814dd 100644 --- a/src/pyFAI/engines/CSR_engine.py +++ b/src/pyFAI/engines/CSR_engine.py @@ -26,7 +26,7 @@ __contact__ = "Jerome.Kieffer@ESRF.eu" __license__ = "MIT" __copyright__ = "European Synchrotron Radiation Facility, Grenoble, France" -__date__ = "14/11/2024" +__date__ = "18/11/2024" __status__ = "development" from collections.abc import Iterable @@ -395,7 +395,9 @@ def medfilt(self, data, dark=None, dummy=None, delta_dummy=None, variance=None, dark_variance=None, flat=None, solidangle=None, polarization=None, absorption=None, safe=True, error_model=None, - normalization_factor=1.0, quantile=0.5 + normalization_factor=1.0, + quant_min=0.5, + quant_max=0.5, ): """ Perform a median-filter/quantile mean in azimuthal space. @@ -425,17 +427,12 @@ def medfilt(self, data, dark=None, dummy=None, delta_dummy=None, :param safe: Unused in this implementation :param error_model: Enum or str, "azimuthal" or "poisson" :param normalization_factor: divide raw signal by this value - :param quantile: which percentile/100 use for cutting out quantil. - can be a 2-tuple to specify a region to average out. - By default, takes the median + :param quant_min: start percentile/100 to use. Use 0.5 for the median (default). 0<=quant_min<=1 + :param quant_max: stop percentile/100 to use. Use 0.5 for the median (default). 0<=quant_max<=1 + :return: namedtuple with "position intensity error signal variance normalization count" """ - if isinstance(quantile, Iterable): - q_start = min(quantile) - q_stop = max(quantile) - else: - q_stop = q_start = quantile indptr = self._csr.indptr indices = self._csr.indices @@ -484,7 +481,7 @@ def medfilt(self, data, dark=None, dummy=None, delta_dummy=None, upper = numpy.cumsum(tmp["norm"]) last = upper[-1] lower = numpy.concatenate(([0],upper[:-1])) - mask = numpy.logical_and(upper>=q_start*last, lower<=q_stop*last) + mask = numpy.logical_and(upper>=quant_min*last, lower<=quant_max*last) tmp = tmp[mask] cnt[i] = tmp.size signal[i] = tmp["sig"].sum(dtype=numpy.float64)