Calculate percentile of numpy stack and return the index of the chosen pixel.

            numpy percentile function is used with one of the following interpolations {'linear', 'lower', 'higher',
            'midpoint', 'nearest'}

def _numpy_index_by_percentile(self, data, percentile):
        """ Calculate percentile of numpy stack and return the index of the chosen pixel.

            numpy percentile function is used with one of the following interpolations {'linear', 'lower', 'higher',
            'midpoint', 'nearest'}
        """
        data_perc_low = np.nanpercentile(data, percentile, axis=0, interpolation=self.interpolation)

        indices = np.empty(data_perc_low.shape, dtype=np.uint8)
        indices[:] = np.nan

        abs_diff = np.where(np.isnan(data_perc_low), np.inf, abs(data - data_perc_low))

        indices = np.where(np.isnan(data_perc_low), self.max_index, np.nanargmin(abs_diff, axis=0))

        return indices