示例#1
0
def main():
    data = np.load("raw_peaks_img.npy")
    gain_map = np.load("gain2.npy") == 2.
    mask = mask_utils.mask_small_regions(gain_map)
    new_data = correct_panels(data, gain_map, mask)

    plt.figure()
    plt.imshow(new_data[0], vmin=-10, vmax=50, cmap='gnuplot')
    plt.show()
示例#2
0
def main2():
    import psana
    ds = psana.DataSource("exp=cxid9114:run=62")
    events = ds.events()

    det = psana.Detector('CxiDs2.0:Cspad.0')
    dark = det.pedestals(62)
    gain_map = det.gain_mask(62) == 1
    mask = mask_utils.mask_small_regions(gain_map)
    mask2 = np.load("mask/details_mask.npy")
    mask *= mask2
    start = 0

    all_ylow = []
    all_yhigh = []
    for i in range(1200):
        if i < 1000:
            continue
        ev = events.next()
        if ev is None:
            continue
        if i < start:
            continue
        raw = det.raw(ev)
        if raw is None:
            continue
        data = raw - dark
        # new_data = correct_panels( data, gain_map, mask, plot=True)

        xlow, ylow, xhigh, yhigh, new_data = get_gain_dists(
            data, gain_map, mask)
        all_ylow.append(ylow)
        all_yhigh.append(yhigh)

        #plt.figure()
        #plt.imshow( new_data[0],  vmin=-10,vmax=50,cmap='gnuplot')
        #plt.show()
        print i
    np.savez("all_shot_hists",
             ylow=all_ylow,
             yhigh=all_yhigh,
             xlow=xlow,
             xhigh=xhigh)
示例#3
0
def main3():
    import psana
    ds = psana.DataSource("exp=cxid9114:run=62")
    events = ds.events()

    det = psana.Detector('CxiDs2.0:Cspad.0')
    dark = det.pedestals(62)
    gain_map = det.gain_mask(62) == 1
    plt.imshow(gain_map[0])
    plt.show()
    mask = mask_utils.mask_small_regions(gain_map)
    mask2 = np.load("details_mask.npy")
    mask *= mask2
    start = 0
    for i in range(100):
        ev = events.next()
        if ev is None:
            continue
        if i < start:
            continue
        data = det.calib(ev, cmpars=(5, 0, 0, 0, 0))
        #data = det.calib(ev, cmpars=(1,25,25,100,1))
        if data is None:
            continue
        plt.imshow(gain_map[0])
        plt.show()
        xlow, ylow, xhigh, yhigh, new_data = get_gain_dists(
            data, gain_map, mask)

        low_g0, low_g1, fit_low = fit_utils.fit_low_gain_dist(xlow,
                                                              ylow,
                                                              plot=1)
        high_g0, high_g1, fit_high = fit_utils.fit_high_gain_dist(xhigh,
                                                                  yhigh,
                                                                  plot=1)

        plt.figure()
        plt.imshow(data[0], vmin=-10, vmax=50, cmap='gnuplot')
        plt.show()