Exemplo n.º 1
0
def clustersort(time, value, deadradius):
    """
    Given a series of filtered events, remove all points which are close to a
    point with higher value, unless the latter has already been removed by an
    even higher one.
    
    Parameters
    ----------
    time, value : array (nevents, npoints)
        The filter output.
    deadradius : scalar
        The temporal distance to consider points as close.
    
    Return
    ------
    time, value : array (N,)
        N <= nevents * npoints. The value array is sorted, with the time
        array matching the correct points in the value array. All events are
        merged together.
    """
    indices1, length = clusterargsort.clusterargsort(value, time, deadradius)
    indices0 = np.repeat(np.arange(len(value)), np.diff(length))

    value = value[indices0, indices1]
    time = time[indices0, indices1]

    idx = np.argsort(value)
    return time[idx], value[idx]
Exemplo n.º 2
0
    def _merge_candidates(self):
        """
        Take the output of filters, apply the dead radius, merge events,
        sort by filter output value, mark candidates considered true signal.
        """
        # dictionaries layout: filter name -> (photon series -> 1D array)
        self.times = collections.defaultdict(dict)
        self.values = collections.defaultdict(dict)
        self.signal = collections.defaultdict(dict)

        for k, fhits in self.filtd.items():
            for fname in fhits.dtype.names:

                time = fhits[fname]['time']
                value = fhits[fname]['value']

                indices1, length = clusterargsort.clusterargsort(
                    value, time, self.deadradius)
                indices0 = np.repeat(np.arange(len(value)), np.diff(length))

                value = value[indices0, indices1]
                time = time[indices0, indices1]

                timedelta = np.abs(time - self.s1loc)
                minindices = argmin_sliced(timedelta, length)
                signal = np.zeros(len(time), bool)
                signal[minindices] = True
                # this will count signals even in dcr, just don't use them

                idx = np.argsort(value)

                self.times[fname][k] = time[idx]
                self.values[fname][k] = value[idx]
                self.signal[fname][k] = signal[idx]