def get_xtalk(filename, int_limits, thrs_1=None):
    if thrs_1 is not None:
        dark, peak, sub = get_spectra(filename, int_limits, thrs_1)
    else:
        peak = peaks(filename, int_limits)
        temp_hist = histogram(peak, bins=2048)
        cutoff = 2027 - getFitData(temp_hist[0][::-1], 3)[4]
        thrs = temp_hist[1][cutoff] / 180
        dark = darks(filename, thrs)
        mx = max(max(dark), max(peak))
        mn = min(min(dark), min(peak))

        dark_hist = histogram(dark, bins=2048, range=(mn, mx))
        peak_hist = histogram(peak, bins=2048, range=(mn, mx))
        sub = peak_hist[0] - dark_hist[0]

    guess = get_guess(sub)
    cutoff = get_cutoff(sub, get_cutoff(sub, guess))
    nm = get_n_mean(sub, cutoff)

    pg0 = 1 - exp(- nm)
    pg1_p = 1 - exp(- nm) - nm * exp(- nm)
    cutoff_2 = get_cutoff(sub, get_cutoff(sub, get_guess(sub, n=3, m=33)))
    print cutoff_2
    pg1 = sum(sub[:cutoff_2]) / float(sum(sub))
    xtalk = (pg1 - pg1_p) / pg0
    print xtalk
    return xtalk, sub
Beispiel #2
0
def get_xtalk(filename, int_limits, thrs_1=None):
    if thrs_1 is not None:
        dark, peak, sub = get_spectra(filename, int_limits, thrs_1)
    else:
        peak = peaks(filename, int_limits)
        temp_hist = histogram(peak, bins=2048)
        cutoff = 2027 - getFitData(temp_hist[0][::-1], 3)[4]
        thrs = temp_hist[1][cutoff] / 180
        dark = darks(filename, thrs)
        mx = max(max(dark), max(peak))
        mn = min(min(dark), min(peak))

        dark_hist = histogram(dark, bins=2048, range=(mn, mx))
        peak_hist = histogram(peak, bins=2048, range=(mn, mx))
        sub = peak_hist[0] - dark_hist[0]

    guess = get_guess(sub)
    cutoff = get_cutoff(sub, get_cutoff(sub, guess))
    nm = get_n_mean(sub, cutoff)

    pg0 = 1 - exp(-nm)
    pg1_p = 1 - exp(-nm) - nm * exp(-nm)
    cutoff_2 = get_cutoff(sub, get_cutoff(sub, get_guess(sub, n=3, m=33)))
    print cutoff_2
    pg1 = sum(sub[:cutoff_2]) / float(sum(sub))
    xtalk = (pg1 - pg1_p) / pg0
    print xtalk
    return xtalk, sub
Beispiel #3
0
def xtalk_single_spec(hist):
    nm = get_n_mean(hist, get_cutoff(hist, get_guess(hist)))
    pg1_p = 1 - exp(-nm) - nm * exp(-nm)
    pg0 = 1 - exp(-nm)
    cutoff = get_cutoff(hist, get_cutoff(hist, get_guess(hist, n=3, m=33)))
    pg1 = sum(hist[:cutoff]) / float(sum(hist))
    xtalk = (pg1 - pg1_p) / pg0
    print xtalk
    return xtalk
def xtalk_single_spec(hist):
    nm = get_n_mean(hist, get_cutoff(hist, get_guess(hist)))
    pg1_p = 1 - exp(- nm) - nm * exp(- nm)
    pg0 = 1 - exp(- nm)
    cutoff = get_cutoff(hist, get_cutoff(hist, get_guess(hist, n=3, m=33)))
    pg1 = sum(hist[:cutoff]) / float(sum(hist))
    xtalk = (pg1 - pg1_p) / pg0
    print xtalk
    return xtalk
Beispiel #5
0
def xtalksspec_err(hist):
    nm, nmerr, spm = get_nmean_errors(hist, get_cutoff(hist, get_guess(hist)))
    pg1_p = 1 - exp(-nm) - nm * exp(-nm)
    pg1_perr = exp(-nm) * nm * nmerr
    pg0 = 1 - exp(-nm)
    pg0err = nmerr
    cutoff = get_cutoff(hist, get_cutoff(hist, get_guess(hist, n=3, m=33)))
    pg1 = sum(hist[:cutoff]) / float(sum(hist))
    pg1err = sqrt(sum(hist[:cutoff])) / float(sum(hist))
    xtalk = (pg1 - pg1_p) / pg0
    err = sqrt((1 / pg0 * pg1err)**2 + (1 / pg0 * pg1_perr)**2 +
               (xtalk / pg0 * pg0err)**2)
    print xtalk
    return xtalk, err
def xtalksspec_err(hist):
    nm, nmerr, spm = get_nmean_errors(hist, get_cutoff(hist, get_guess(hist)))
    pg1_p = 1 - exp(- nm) - nm * exp(- nm)
    pg1_perr = exp(- nm) * nm * nmerr
    pg0 = 1 - exp(- nm)
    pg0err = nmerr
    cutoff = get_cutoff(hist, get_cutoff(hist, get_guess(hist, n=3, m=33)))
    pg1 = sum(hist[:cutoff]) / float(sum(hist))
    pg1err = sqrt(sum(hist[:cutoff])) / float(sum(hist))
    xtalk = (pg1 - pg1_p) / pg0
    err = sqrt((1 / pg0 * pg1err)**2 + (1 / pg0 * pg1_perr)**2 +
               (xtalk / pg0 * pg0err)**2)
    print xtalk
    return xtalk, err
def find_threshold(filename, int_limits, nchannels=2):
    b, a = iirfilter(1, 0.05, btype='lowpass')
    my_dtype = return_dtype(nchannels)

    with open(filename, 'r') as f:
        gen = (fromstring(event, my_dtype)[0][5]
               for event in event_generator(f, nchannels))
        peaks = [min(event[int_limits[0]:int_limits[1]])for event
                 in (filtfilt(b, a, eventt) for eventt in gen)]
    hist = histogram(peaks, bins=2048)
    idx = get_cutoff(hist[0], get_guess(hist[0]))
    threshold = hist[1][idx]
    print threshold
    return threshold
Beispiel #8
0
def find_threshold(filename, int_limits, nchannels=2):
    b, a = iirfilter(1, 0.05, btype='lowpass')
    my_dtype = return_dtype(nchannels)

    with open(filename, 'r') as f:
        gen = (fromstring(event, my_dtype)[0][5]
               for event in event_generator(f, nchannels))
        peaks = [min(event[int_limits[0]:int_limits[1]])for event
                 in (filtfilt(b, a, eventt) for eventt in gen)]
    hist = histogram(peaks, bins=2048)
    idx = get_cutoff(hist[0], get_guess(hist[0]))
    threshold = hist[1][idx]
    print threshold
    return threshold
def get_line(intd, mind, n=None, **kwargs):
    int_hist = histogram(intd, bins=2048)
    if n is None:
        int_mn = get_n_mean(int_hist[0], get_cutoff(int_hist[0],
                            get_guess(int_hist[0])))
        n = decide_n(int_mn)
    temp = odr_gauss(n, int_hist[0][::-1])
    x1, x2 = coord_from_fit(int_hist, temp, **kwargs)
    min_hist = histogram(mind, bins=2048)
    temp = odr_gauss(n, min_hist[0][::-1])
    y1, y2 = coord_from_fit(min_hist, temp, **kwargs)

    a = (y1 - y2) / (x1 - x2)
    b = y1 - a*x1
    print 'b = ' + str(b)
    print 'a = ' + str(a)
    return a, b
def get_line(intd, mind, n=None, **kwargs):
    int_hist = histogram(intd, bins=2048)
    if n is None:
        int_mn = get_n_mean(int_hist[0],
                            get_cutoff(int_hist[0], get_guess(int_hist[0])))
        n = decide_n(int_mn)
    temp = odr_gauss(n, int_hist[0][::-1])
    x1, x2 = coord_from_fit(int_hist, temp, **kwargs)
    min_hist = histogram(mind, bins=2048)
    temp = odr_gauss(n, min_hist[0][::-1])
    y1, y2 = coord_from_fit(min_hist, temp, **kwargs)

    a = (y1 - y2) / (x1 - x2)
    b = y1 - a * x1
    print 'b = ' + str(b)
    print 'a = ' + str(a)
    return a, b