Exemple #1
0
def t_over_r(date):

    import gen_reader as gr
    import numpy as np

    T = gr.wf_reader('/home/chris/anaconda/data/' + str(date) + '/lv/T.txt',
                     header=False)
    R = gr.wf_reader('/home/chris/anaconda/data/' + str(date) + '/lv/R.txt',
                     header=False)

    return np.mean(T[:, 1]) / np.mean(R[:, 1])
Exemple #2
0
def lv_power_read(lvnum, **kwargs):

    T_R = kwargs.get('T_R', 1.)
    op_flat = kwargs.get('op_flat', True)

    import matplotlib.pyplot as plt
    import numpy as np
    import gen_reader as gr
    import glob

    lvnum = str(lvnum).zfill(4)
    f = len(
        glob.glob('/home/james/anaconda3/data/' + str(date) + '/lv/' + lvnum +
                  '_*_laser_temp.txt'))

    if op_flat == True:
        flat_T = .89
    if op_flat == False:
        flat_T = 1.

    pows = []
    for i in range(f):
        frnum = str(i + 1).zfill(4)
        lv_matrix = gr.wf_reader('/home/james/anaconda3/data/' + str(date) +
                                 '/lv/' + lvnum + '_' + frnum +
                                 '_laser_temp.txt',
                                 header=False)
        pts = len(lv_matrix[:, 1])
        pows.append(lv_matrix[:, 1] * T_R * flat_T)

    return pows
Exemple #3
0
def trig_check(trignum, **kwargs):

    ret_full = kwargs.get('return_full', False)

    import numpy as np
    import matplotlib.pyplot as plt
    import gen_reader as gr

    trigdat = gr.wf_reader('/home/james/anaconda3/data/' + str(date) +
                           '/lv/trig_' + str(trignum) + '.txt')

    # Calculate dt and find the accelerometer level during trigger window
    dt, acc_sig = [], []
    for i in range(np.shape(trigdat)[0]):
        if i > 0:
            dt.append(trigdat[i, 0] - trigdat[i - 1, 0])
        if trigdat[i, 2] == 1:
            acc_sig_1.append(trigdat[i, 1])

    acc_sig_ave = np.mean(acc_sig)
    dt_ave = np.mean(dt)

    plt.figure('trig')
    plt.clf()
    plt.plot(acc_sig, 'b')
    plt.title(
        str(date) + ' run' + str(trignum) +
        ' Trigger Signal while Laser Shutter Open')

    if ret_full == True:
        return dt, acc_sig
    return dt_ave, acc_sig_ave
Exemple #4
0
def lv_avpow(lvnum, **kwargs):

    T_R = kwargs.get('T_R', 1.)
    op_flat = kwargs.get('op_flat', True)

    import matplotlib.pyplot as plt
    import numpy as np
    import gen_reader as gr
    import glob

    lvnum = str(lvnum).zfill(4)
    f = len(
        glob.glob('/home/james/anaconda3/data/' + str(date) + '/lv/' + lvnum +
                  '_*_laser_temp.txt'))

    if op_flat == True:
        flat_T = .89
    if op_flat == False:
        flat_T = 1.

    avpow = np.zeros(f)
    for i in range(f):
        frnum = str(i + 1).zfill(4)
        lv_matrix = gr.wf_reader('/home/james/anaconda3/data/' + str(date) +
                                 '/lv/' + lvnum + '_' + frnum +
                                 '_laser_temp.txt',
                                 header=False)
        avpow[i] = np.mean(lv_matrix[:, -1]) * T_R * flat_T

    return avpow
Exemple #5
0
def lv_avpow_cont(lvnum, **kwargs):

    T_R = kwargs.get('T_R', 1.)
    op_flat = kwargs.get('op_flat', True)

    import matplotlib.pyplot as plt
    import numpy as np
    import gen_reader as gr
    import glob

    lvnum = str(lvnum).zfill(4)
    f = len(
        glob.glob('/home/james/anaconda3/data/' + str(date) + '/lv/' + lvnum +
                  '_*_laser_temp.txt'))

    if op_flat == True:
        flat_T = .89
    if op_flat == False:
        flat_T = 1.

    powave = np.zeros(f)
    for i in range(f):
        frnum = str(i + 1).zfill(4)
        lv_matrix = gr.wf_reader('/home/james/anaconda3/data/' + str(date) +
                                 '/lv/' + lvnum + '_' + frnum +
                                 '_laser_temp.txt',
                                 header=False)
        power = []
        for j in lv_matrix[:, 1]:
            if j * T_R * op_flat >= 1E-6:
                power.append(j * T_R * op_flat)
        powave[i] = np.mean(power)

    return powave
Exemple #6
0
def lv_time_cont(lvnum):

    import matplotlib.pyplot as plt
    import numpy as np
    import gen_reader as gr
    import glob

    lvnum = str(lvnum).zfill(4)
    f = len(
        glob.glob('/home/james/anaconda3/data/' + str(date) + '/lv/' + lvnum +
                  '_*_laser_temp.txt'))

    ontime = np.zeros((f, ))
    for i in range(f):
        frnum = str(i + 1).zfill(4)
        lv_matrix = gr.wf_reader('/home/james/anaconda3/data/' + str(date) +
                                 '/lv/' + lvnum + '_' + frnum +
                                 '_laser_temp.txt',
                                 header=False)
        for j in lv_matrix[:, -1]:
            if j >= 1e-7:
                ontime[i] += 1
        ontime[i] = ontime[i] * ut.avediff(lv_matrix[:, 0])

    return ontime
Exemple #7
0
def lv_temp_cont(lvnum, **kwargs):

    import matplotlib.pyplot as plt
    import numpy as np
    import gen_reader as gr
    import glob

    lvnum = str(lvnum).zfill(4)
    f = len(
        glob.glob('/home/james/anaconda3/data/' + str(date) + '/lv/' + lvnum +
                  '_*_laser_temp.txt'))

    temp = np.zeros(f)
    for i in range(f):
        frnum = str(i + 1).zfill(4)
        lv_matrix = gr.wf_reader('/home/james/anaconda3/data/' + str(date) +
                                 '/lv/' + lvnum + '_' + frnum +
                                 '_laser_temp.txt',
                                 header=False)
        temp[i] = np.mean(lv_matrix[:, 1])

    return temp
Exemple #8
0
def trig_check2(trignum, **kwargs):

    savepath = kwargs.get('savepath', False)

    import numpy as np
    import matplotlib.pyplot as plt
    import gen_reader as gr
    import utility as ut

    trigdat = gr.wf_reader('/home/james/anaconda3/data/' + str(date) +
                           '/lv/trig_' + str(trignum) + '.txt')

    # Calculate dt and find the accelerometer level during trigger window
    acc_sig, acc_sig_1 = [], []
    j = 0
    for i in range(np.shape(trigdat)[0]):
        if trigdat[i, 2] == 0:
            j = 0
        if trigdat[i, 2] == 1:
            if j == 0:
                acc_sig.append(np.mean(acc_sig_1))
            acc_sig_1.append(trigdat[i, 1])
            j += 1

    plt.figure('trig2')
    plt.clf()
    plt.plot(acc_sig[1:], 'bo', markersize=3)
    plt.title(
        str(date) + ' run' + str(trignum) +
        ' Average Trigger Signal while Laser Shutter Open')
    plt.xlabel('Trigger Number')
    plt.ylabel('Accelerometer Signal (V)')
    if savepath != False:
        ut.create_dir(savepath)
        plt.savefig(savepath + 'trig_' + str(trignum) + '_acc_sig.png')

    return acc_sig[1:]
Exemple #9
0
def lv_energy_bad(lvnum, **kwargs):

    T_R = kwargs.get('T_R', 1.)
    op_flat = kwargs.get('op_flat', True)

    import matplotlib.pyplot as plt
    import numpy as np
    import gen_reader as gr
    import glob

    lvnum = str(lvnum).zfill(4)
    f = len(
        glob.glob('/home/chris/anaconda/data/' + str(date) + '/lv/' + lvnum +
                  '_*_laser_temp.txt'))

    if op_flat == True:
        flat_T = .89
    if op_flat == False:
        flat_T = 1.

    powsum = np.zeros(f)
    for i in range(f):
        frnum = str(i + 1).zfill(4)
        lv_matrix = gr.wf_reader('/home/chris/anaconda/data/' + str(date) +
                                 '/lv/' + lvnum + '_' + frnum +
                                 '_laser_temp.txt',
                                 header=False)
        powsum[i] = np.sum(lv_matrix[:, 2]) * T_R * flat_T

    dt = []
    for i in range(np.shape(lv_matrix)[0] - 1):
        dt.append(lv_matrix[i + 1, 0] - lv_matrix[i, 0])
    dt = np.mean(dt)

    energy = dt * powsum

    return energy