Exemple #1
0
def find_potential_peaks(data_smooth, left_width, right_width, threshold):

    ## 2) function the refine the boundary searching:
    ## S is 2D list contains the [left, right] edge of each Peaks.
    def accurate_S_boundary(S, data_smooth, threshold_left, threshold_right):
        for i in range(len(S)):  ## len(S) is number of Peaks.
            boundary = S[i]
            num = boundary[0]  ## Left edge.
            while (num > 0) and (data_smooth[num] > threshold_left):
                num -= 1
            S[i][0] = num
            num = boundary[1]  ## Right edge.
            while (num < len(data_smooth)) and (data_smooth[num] >
                                                threshold_right):
                num += 1
            S[i][1] = num
        return S

    ## 1) roughly find the edge for each peak.
    S = []
    #clib=ctypes.cdll.LoadLibrary("/home/nilab/Processor/SanDP/sandp/findPoWa/findPoWa.so")
    clib = ctypes.cdll.LoadLibrary(full_path("findPoWa/findPoWa.so"))
    data_c = (ctypes.c_double * len(data_smooth))()
    for i in range(len(data_smooth)):
        data_c[i] = ctypes.c_double(data_smooth[i])
    func = clib.findPotentialWave
    func.restype = ctypes.c_char_p
    S1 = func(ctypes.byref(data_c), ctypes.c_int(len(data_c)),
              ctypes.c_int(left_width), ctypes.c_int(right_width),
              ctypes.c_double(threshold))
    s_tmp = S1.split(";")
    if len(
            s_tmp
    ) > 50:  ## if more than 50 peaks find, means the event is very noisy!
        s_tmp = s_tmp[:50]
    else:
        s_tmp = s_tmp
    del s_tmp[-1]

    for i in s_tmp:
        tmp = i.split(",")
        try:
            tmp[0] = int(float(tmp[0]))
            tmp[1] = int(float(tmp[1]))
            S.append(
                tmp
            )  ## S is 2D list contains the [left, right] edge of each Peaks.
        except ValueError:
            pass
    ## First:  using 1) to roughly fiind all peaks.
    ## Second: call the func to re-fine the left/right edge.
    return accurate_S_boundary(S, data_smooth, threshold / 2., threshold * 2.)
Exemple #2
0
def smooth(origindata, meanNum=100, cover_num=5):
    #clib=ctypes.cdll.LoadLibrary("/home/nilab/Processor/SanDP/sandp/smooth/smooth.so")
    clib = ctypes.cdll.LoadLibrary(full_path("smooth/smooth.so"))
    data_smooth = (ctypes.c_double * len(origindata))()
    for i in range(len(origindata)):
        data_smooth[i] = ctypes.c_double(origindata[i])
    clib.smooth(ctypes.byref(data_smooth), ctypes.c_int(meanNum),
                ctypes.c_int(len(data_smooth)), ctypes.c_int(cover_num))

    for i in range(cover_num):
        data_smooth[i] = 0
        data_smooth[i - 1] = 0

    return data_smooth
Exemple #3
0
from peakrefine import peak_width
from peakrefine import accurate_peaks
from peakrefine import accurate_S1
from peakrefine import accurate_S2

from peakproperty import Entropy
from peakproperty import Uniformity
from peakproperty import integral
from peakproperty import sort_area

from configparser import ConfigParser
from sandp import full_path

cfg = ConfigParser()
# cfg.read('/home/nilab/Processor/SanDP/sandp/config/sandix.ini')
cfg.read(full_path('config/sandix.ini'))

s1width_lower_limit = int(cfg['peaks']['s1width_lower_limit'])
s1width_upper_limit = int(cfg['peaks']['s1width_upper_limit'])
s2width_lower_limit = int(cfg['peaks']['s2width_lower_limit'])
s2width_upper_limit = int(cfg['peaks']['s2width_upper_limit'])

nsamps = int(cfg['peaks']['nsamps'])
nsamp_base = int(cfg['peaks']['nsamp_base'])
s1_thre_base = int(cfg['peaks']['s1_thre_base'])
s2_thre_base = int(cfg['peaks']['s2_thre_base'])
trigger_position = int(cfg['peaks']['trigger_position'])

PMTgain = [
    float(cfg['gains']['ch0_gain']),
    float(cfg['gains']['ch1_gain']),