src/pys5p/s5p_msm.py
def nanpercentile(self, vperc, data_sel=None, axis=0, keepdims=False):
        """
        Returns percentile(s) of the data in the S5Pmsm

        Parameters
        ----------
        vperc       :  list
           range to normalize luminance data between percentiles min and max of
           array data.
        data_sel  :  numpy slice
           A numpy slice generated for example numpy.s_. Can be used to skip
           the first and/or last frame
        axis      : int, optional
           Axis or axes along which the medians are computed. Default is 0.
        keepdims  : bool, optional
           If this is set to True, the axes which are reduced are left in the
           result as dimensions with size one. With this option, the result
           will broadcast correctly against the original arr.

        Returns
        -------
        S5Pmsm object with the original data replaced by the percentiles along
        one of the axis, see below. The coordinates are adjusted, accordingly.

        You should atleast supply one percentile and atmost three.
         vperc is instance 'int' or len(vperc) == 1:
             'value' is replaced by its (nan-)percentile vperc
             'error' is unchanged
         len(vperc) == 2:
             'vperc' is sorted
             'value' is replaced by its (nan-)median
             'error' is replaced by percentile('value', (vperc[0], vperc[1]))
         len(vperc) == 3:
             'vperc' is sorted
             'value' is replaced by percentile('value', vperc[1])
             'error' is replaced by percentile('value', (vperc[0], vperc[2]))
        """
        if isinstance(axis, int):
            axis = (axis,)

        if isinstance(vperc, int):
            vperc = (vperc,)
        else:
            if len(vperc) == 2:
                vperc += (50,)
            # make sure that the values are sorted
            vperc = tuple(sorted(vperc))

        if len(vperc) != 1 and len(vperc) != 3:
            raise TypeError('dimension vperc must be 1 or 3')

        if data_sel is None:
            if self.value.size <= 1 or self.value.ndim <= max(axis):
                return self
            perc = np.nanpercentile(self.value, vperc,
                                    axis=axis, keepdims=keepdims)
        else:
            if self.value[data_sel].size <= 1 \
               or self.value[data_sel].ndim <= max(axis):
                return self
            perc = np.nanpercentile(self.value[data_sel], vperc,
                                    axis=axis, keepdims=keepdims)
        if len(vperc) == 3:
            self.value = perc[1, ...]
            self.error = [perc[0, ...], perc[2, ...]]
        else:
            self.value = perc[0, ...]

        # adjust the coordinates
        if keepdims:
            key = self.coords._fields[axis]
            if self.coords[axis][0] == 0:
                dims = [0]
            else:
                dims = np.median(self.coords[axis], keepdims=keepdims)
            self.coords = self.coords._replace(**{key: dims})
        else:
            keys = []
            dims = []
            for ii in range(self.value.ndim+len(axis)):
                if ii not in axis:
                    keys.append(self.coords._fields[ii])
                    dims.append(self.coords[ii][:])
            coords_namedtuple = namedtuple('Coords', keys)
            self.coords = coords_namedtuple._make(dims)

        return self

        Returns percentile(s) of the data in the S5Pmsm

        Parameters
        ----------
        vperc       :  list
           range to normalize luminance data between percentiles min and max of
           array data.
        data_sel  :  numpy slice
           A numpy slice generated for example numpy.s_. Can be used to skip
           the first and/or last frame
        axis      : int, optional
           Axis or axes along which the medians are computed. Default is 0.
        keepdims  : bool, optional
           If this is set to True, the axes which are reduced are left in the
           result as dimensions with size one. With this option, the result
           will broadcast correctly against the original arr.

        Returns
        -------
        S5Pmsm object with the original data replaced by the percentiles along
        one of the axis, see below. The coordinates are adjusted, accordingly.

        You should atleast supply one percentile and atmost three.
         vperc is instance 'int' or len(vperc) == 1:
             'value' is replaced by its (nan-)percentile vperc
             'error' is unchanged
         len(vperc) == 2:
             'vperc' is sorted
             'value' is replaced by its (nan-)median
             'error' is replaced by percentile('value', (vperc[0], vperc[1]))
         len(vperc) == 3:
             'vperc' is sorted
             'value' is replaced by percentile('value', vperc[1])
             'error' is replaced by percentile('value', (vperc[0], vperc[2]))
        
Returns percentile(s) of the data in the S5Pmsm
Parameters

vperc       :  list
range to normalize luminance data between percentiles min and max of
array data.

Returns

S5Pmsm object with the original data replaced by the percentiles along
one of the axis, see below. The coordinates are adjusted, accordingly.

You should atleast supply one percentile and atmost three.
Returns percentile ( s ) of the data in the S5Pmsm Parameters vperc : list range to normalize luminance data between percentiles min and max of array data . Returns S5Pmsm object with the original data replaced by the percentiles along one of the axis see below . The coordinates are adjusted accordingly . You should atleast supply one percentile and atmost three .
def nanpercentile(self, vperc, data_sel=None, axis=0, keepdims=False):
        if isinstance(axis, int):
            axis = (axis,)
        if isinstance(vperc, int):
            vperc = (vperc,)
        else:
            if len(vperc) == 2:
                vperc += (50,)
            vperc = tuple(sorted(vperc))
        if len(vperc) != 1 and len(vperc) != 3:
            raise TypeError('dimension vperc must be 1 or 3')
        if data_sel is None:
            if self.value.size <= 1 or self.value.ndim <= max(axis):
                return self
            perc = np.nanpercentile(self.value, vperc,
                                    axis=axis, keepdims=keepdims)
        else:
            if self.value[data_sel].size <= 1 \
               or self.value[data_sel].ndim <= max(axis):
                return self
            perc = np.nanpercentile(self.value[data_sel], vperc,
                                    axis=axis, keepdims=keepdims)
        if len(vperc) == 3:
            self.value = perc[1, ...]
            self.error = [perc[0, ...], perc[2, ...]]
        else:
            self.value = perc[0, ...]
        if keepdims:
            key = self.coords._fields[axis]
            if self.coords[axis][0] == 0:
                dims = [0]
            else:
                dims = np.median(self.coords[axis], keepdims=keepdims)
            self.coords = self.coords._replace(**{key: dims})
        else:
            keys = []
            dims = []
            for ii in range(self.value.ndim+len(axis)):
                if ii not in axis:
                    keys.append(self.coords._fields[ii])
                    dims.append(self.coords[ii][:])
            coords_namedtuple = namedtuple('Coords', keys)
            self.coords = coords_namedtuple._make(dims)
        return self
def nanpercentile ( self , vperc , data_sel = None , axis = 0 , keepdims = False ) : if isinstance ( axis , int ) : axis = ( axis , ) if isinstance ( vperc , int ) : vperc = ( vperc , ) else : if len ( vperc ) == 2 : vperc += ( 50 , ) vperc = tuple ( sorted ( vperc ) ) if len ( vperc ) != 1 and len ( vperc ) != 3 : raise TypeError ( 'dimension vperc must be 1 or 3' ) if data_sel is None : if self . value . size <= 1 or self . value . ndim <= max ( axis ) : return self perc = np . nanpercentile ( self . value , vperc , axis = axis , keepdims = keepdims ) else : if self . value [ data_sel ] . size <= 1 or self . value [ data_sel ] . ndim <= max ( axis ) : return self perc = np . nanpercentile ( self . value [ data_sel ] , vperc , axis = axis , keepdims = keepdims ) if len ( vperc ) == 3 : self . value = perc [ 1 , ... ] self . error = [ perc [ 0 , ... ] , perc [ 2 , ... ] ] else : self . value = perc [ 0 , ... ] if keepdims : key = self . coords . _fields [ axis ] if self . coords [ axis ] [ 0 ] == 0 : dims = [ 0 ] else : dims = np . median ( self . coords [ axis ] , keepdims = keepdims ) self . coords = self . coords . _replace ( ** { key : dims } ) else : keys = [ ] dims = [ ] for ii in range ( self . value . ndim + len ( axis ) ) : if ii not in axis : keys . append ( self . coords . _fields [ ii ] ) dims . append ( self . coords [ ii ] [ : ] ) coords_namedtuple = namedtuple ( 'Coords' , keys ) self . coords = coords_namedtuple . _make ( dims ) return self
Returns percentile(s) of the data in the S5Pmsm
Parameters
Returns percentile ( s ) of the data in the S5Pmsm Parameters
"""
        Returns percentile(s) of the data in the S5Pmsm

        Parameters
        ----------
        vperc       :  list
           range to normalize luminance data between percentiles min and max of
           array data.
        data_sel  :  numpy slice
           A numpy slice generated for example numpy.s_. Can be used to skip
           the first and/or last frame
        axis      : int, optional
           Axis or axes along which the medians are computed. Default is 0.
        keepdims  : bool, optional
           If this is set to True, the axes which are reduced are left in the
           result as dimensions with size one. With this option, the result
           will broadcast correctly against the original arr.

        Returns
        -------
        S5Pmsm object with the original data replaced by the percentiles along
        one of the axis, see below. The coordinates are adjusted, accordingly.

        You should atleast supply one percentile and atmost three.
         vperc is instance 'int' or len(vperc) == 1:
             'value' is replaced by its (nan-)percentile vperc
             'error' is unchanged
         len(vperc) == 2:
             'vperc' is sorted
             'value' is replaced by its (nan-)median
             'error' is replaced by percentile('value', (vperc[0], vperc[1]))
         len(vperc) == 3:
             'vperc' is sorted
             'value' is replaced by percentile('value', vperc[1])
             'error' is replaced by percentile('value', (vperc[0], vperc[2]))
        """ # make sure that the values are sorted # adjust the coordinates
self
vperc
data_sel
axis
keepdims