Beispiel #1
0
def peak_detect(accum, sigma, neighbors):
    """ Returns a dictionary with the fields:
    
        accum
        accum_cleared
        accum_smooth 
        accum_smooth_max = (x, y)
        centroid
    """
    # smooth a little bit
    accum_smooth = gaussian_filter(accum, sigma=sigma)
    val, accum_smooth_max = md_argmax(accum_smooth)
    if val == 0:
        return None
    # now take a weighted mean around val
    accum_cleared, nevents, mi, mj = \
        centroid_estimate2(accum, center=accum_smooth_max, neighbors=neighbors)
    
    res = {}
    res['accum'] = accum
    res['accum_cleared'] = accum_cleared
    res['accum_smooth'] = accum_smooth
    res['accum_smooth_max'] = accum_smooth_max
    res['centroid'] = (mi, mj)
    res['centroid_nevents'] = nevents
    res['quality'] = nevents  # overall quality estimate
    return res
Beispiel #2
0
def peak_detect(accum, sigma, neighbors):
    """ Returns a dictionary with the fields:
    
        accum
        accum_cleared
        accum_smooth 
        accum_smooth_max = (x, y)
        centroid
    """
    # smooth a little bit
    accum_smooth = gaussian_filter(accum, sigma=sigma)
    val, accum_smooth_max = md_argmax(accum_smooth)
    if val == 0:
        return None
    # now take a weighted mean around val
    accum_cleared, nevents, mi, mj = \
        centroid_estimate2(accum, center=accum_smooth_max, neighbors=neighbors)

    res = {}
    res['accum'] = accum
    res['accum_cleared'] = accum_cleared
    res['accum_smooth'] = accum_smooth
    res['accum_smooth_max'] = accum_smooth_max
    res['centroid'] = (mi, mj)
    res['centroid_nevents'] = nevents
    res['quality'] = nevents  # overall quality estimate
    return res
Beispiel #3
0
def peak_detect_multiple(accum, min_distance, centroid_area,
                         npeaks, frequency, timestamp,
                         min_nevents=0.000001):
    """ 
        Returns a set of peaks, at least min_distance from each other.
    
        Returns a dictionary with the fields:
    
        accum
        accum_cleared
        accum_smooth 
        accum_smooth_max = (x, y)

        hypotheses = list of hypotheses
        centroid
    """
    # For each peak
    hp = []
    for i in range(npeaks):
        # find the current peak
        val, accum_smooth_max = md_argmax(accum)
        if val <= min_nevents:
            continue
        
        # now take a weighted mean around val
        _, nevents, mi, mj = \
            centroid_estimate2(accum, center=accum_smooth_max,
                               neighbors=centroid_area)

        h = create_track_observation(frequency=frequency,
                                     timestamp=timestamp,
                                     coords=(mi, mj),
                                     quality=nevents,
                                     peak=i, npeaks=npeaks)        
        hp.append(h)
        
        m_before = np.max(accum)
        # print(accum[mi, mj])
        accum = remove_occupied(accum, occupied=[(mi, mj)],
                                distance=min_distance)
        # print(accum[mi, mj])
        assert accum[mi, mj] == 0
        
        m_after = np.max(accum)
        # print('%s >= %s' % (m_before, m_after))
        
        # XXX: something is still not right (should be ">")
        assert m_before >= m_after
        
        # Note: because of centroid stuff, it is not guaranteed
        # check_minimum_distance(hp, min_distance)
        
    # check_minimum_distance(hp, min_distance)
    
    for h in hp:
        h['npeaks'] = len(hp)
        
    return hp
Beispiel #4
0
def aer_stats_events_meat(log):
#    events = collect_all(aer_load_log_generic(log))
    events = aer_raw_events_from_file_all(log)
    hist = aer_histogram(events)
    _, coords = md_argmax(hist)

    r = Report('index')    
    with r.subsection('sub') as sub:
        report_for_one(sub, events, coords)
    return r
Beispiel #5
0
Datei: meat.py Projekt: kpykc/rcl
def aer_stats_events_meat(log):
    #    events = collect_all(aer_load_log_generic(log))
    events = aer_raw_events_from_file_all(log)
    hist = aer_histogram(events)
    _, coords = md_argmax(hist)

    r = Report('index')
    with r.subsection('sub') as sub:
        report_for_one(sub, events, coords)
    return r