Пример #1
0
def setup(run_num, ent_num, pol):
    d = beacon_data_reader.Reader("/project2/avieregg/beacon/telem/root",
                                  run_num)
    times = d.t()
    d.setEntry(ent_num)

    #dd= bt.DataDirectory()
    #r=dd.run(run_num)
    #e = r.get_entry(ent_num)
    #times = r.get_entry(ent_num).times()

    if (pol == 1):  #Hpol
        ADC0 = np.asarray(d.wf(0))
        ADC1 = np.asarray(d.wf(2))
        ADC2 = np.asarray(d.wf(4))
        ADC3 = np.asarray(d.wf(6))

    else:  #Vpol
        ADC0 = np.asarray(d.wf(1))
        ADC1 = np.asarray(d.wf(3))
        ADC2 = np.asarray(d.wf(5))
        ADC3 = np.asarray(d.wf(7))

    volt0 = (ADC0 - sum(ADC0) / len(ADC0))
    volt1 = (ADC1 - sum(ADC1) / len(ADC1))
    volt2 = (ADC2 - sum(ADC2) / len(ADC2))
    volt3 = (ADC3 - sum(ADC3) / len(ADC3))

    return (volt0, volt1, volt2, volt3, times)
def setup(run_num, ent_num, pol):
    #dd= bt.DataDirectory()
    #r=dd.run(run_num)
    #e = r.get_entry(ent_num)
    #times = r.get_entry(ent_num).times()

    d = bdr.Reader(os.environ['BEACON_DATA_DIR'], run_num)
    d.setEntry(ent_num)
    times = d.t()

    if(pol == 1): #Hpol
        #ADC0 = np.asarray(e.channel(0))
        #ADC1 = np.asarray(e.channel(2))
        #ADC2 = np.asarray(e.channel(4))
        #ADC3 = np.asarray(e.channel(6))
        ADC0 = d.wf(0)
        ADC1 = d.wf(2)
        ADC2 = d.wf(4)
        ADC3 = d.wf(6)
    else: #Vpol
        #ADC0 = np.asarray(e.channel(1))
        #ADC1 = np.asarray(e.channel(3))
        #ADC2 = np.asarray(e.channel(5))
        #ADC3 = np.asarray(e.channel(7))
        ADC0 = d.wf(1)
        ADC1 = d.wf(3)
        ADC2 = d.wf(5)
        ADC3 = d.wf(7)

    volt0 = (ADC0-sum(ADC0)/len(ADC0))
    volt1 = (ADC1-sum(ADC1)/len(ADC1))
    volt2 = (ADC2-sum(ADC2)/len(ADC2))
    volt3 = (ADC3-sum(ADC3)/len(ADC3))
    return (volt0,volt1,volt2,volt3,times)
Пример #3
0
def setup(run_num, ent_num, pol):  #grab waveforms and time of event
    #Ben's Analysis Code:
    #dd= bt.DataDirectory()
    #r=dd.run(run_num)
    #e = r.get_entry(ent_num)
    #if(pol == 1): #Hpol
    #    ADC0 = np.asarray(e.channel(0))
    #    ADC1 = np.asarray(e.channel(2))
    #    ADC2 = np.asarray(e.channel(4))
    #    ADC3 = np.asarray(e.channel(6))
    #else:
    #    ADC0 = np.asarray(e.channel(1))
    #    ADC1 = np.asarray(e.channel(3))
    #    ADC2 = np.asarray(e.channel(5))
    #    ADC3 = np.asarray(e.channel(7))

    #volt0 = (ADC0-sum(ADC0)/len(ADC0))
    #volt1 = (ADC1-sum(ADC1)/len(ADC1))
    #volt2 = (ADC2-sum(ADC2)/len(ADC2))
    #volt3 = (ADC3-sum(ADC3)/len(ADC3))
    #times = r.get_entry(ent_num).times()

    lon = -118.238
    lat = 37.589

    d = beacon_data_reader.Reader("/project2/avieregg/beacon/telem/root",
                                  run_num)
    d.setEntry(ent_num)
    times = d.t()

    if (pol == 1):  #Hpol
        volt0 = d.wf(0) - sum(d.wf(0)) / len(d.wf(0))
        volt1 = d.wf(2) - sum(d.wf(2)) / len(d.wf(2))
        volt2 = d.wf(4) - sum(d.wf(4)) / len(d.wf(4))
        volt3 = d.wf(6) - sum(d.wf(6)) / len(d.wf(6))

    else:  #Vpol
        volt0 = d.wf(1) - sum(d.wf(1)) / len(d.wf(1))
        volt1 = d.wf(3) - sum(d.wf(3)) / len(d.wf(3))
        volt2 = d.wf(5) - sum(d.wf(5)) / len(d.wf(5))
        volt3 = d.wf(7) - sum(d.wf(7)) / len(d.wf(7))

    #filter events:
    volt0 = filter(volt0, times)
    volt1 = filter(volt1, times)
    volt2 = filter(volt2, times)
    volt3 = filter(volt3, times)

    #grab time stamp of event and format for later calculations
    h = d.header()
    event_time = datetime.datetime.utcfromtimestamp(h.readout_time)
    hour = event_time.hour + event_time.minute / 60.0 + event_time.second / 3600.0
    loc = coord.EarthLocation(lon=lon * u.deg, lat=lat * u.deg)
    time = Time(event_time, location=loc)  #-offset
    alt, az = 0, 0

    return (volt0, volt1, volt2, volt3, times, alt, az, time, loc, hour)
Пример #4
0
def setup(run_num, ent_num, pol):

    d = beacon_data_reader.Reader("/project2/avieregg/beacon/telem/root",
                                  run_num)
    d.setEntry(ent_num)
    times = d.t()

    if (pol == 1):  #Hpol
        volt0 = d.wf(0) - sum(d.wf(0)) / len(d.wf(0))
        volt1 = d.wf(2) - sum(d.wf(2)) / len(d.wf(2))
        volt2 = d.wf(4) - sum(d.wf(4)) / len(d.wf(4))
        volt3 = d.wf(6) - sum(d.wf(6)) / len(d.wf(6))

    else:  #Vpol
        volt0 = d.wf(1) - sum(d.wf(1)) / len(d.wf(1))
        volt1 = d.wf(3) - sum(d.wf(3)) / len(d.wf(3))
        volt2 = d.wf(5) - sum(d.wf(5)) / len(d.wf(5))
        volt3 = d.wf(7) - sum(d.wf(7)) / len(d.wf(7))

    return (volt0, volt1, volt2, volt3, times)
Пример #5
0
def setup(run_num, ent_num, pol):
    #dd= bt.DataDirectory()
    #r=dd.run(run_num)
    #e = r.get_entry(ent_num)
    #times = r.get_entry(ent_num).times()

    lon = -118.238
    lat = 37.589

    d = beacon_data_reader.Reader("/project2/avieregg/beacon/telem/root",
                                  run_num)
    d.setEntry(ent_num)
    times = d.t()

    if (pol == 1):  #Hpol
        #ADC0 = np.asarray(e.channel(0))
        #ADC1 = np.asarray(e.channel(2))
        #ADC2 = np.asarray(e.channel(4))
        #ADC3 = np.asarray(e.channel(6))
        volt0 = d.wf(0) - sum(d.wf(0)) / len(d.wf(0))
        volt1 = d.wf(2) - sum(d.wf(2)) / len(d.wf(2))
        volt2 = d.wf(4) - sum(d.wf(4)) / len(d.wf(4))
        volt3 = d.wf(6) - sum(d.wf(6)) / len(d.wf(6))

    else:  #Vpol
        #ADC0 = np.asarray(e.channel(1))
        #ADC1 = np.asarray(e.channel(3))
        #ADC2 = np.asarray(e.channel(5))
        #ADC3 = np.asarray(e.channel(7))
        volt0 = d.wf(1) - sum(d.wf(1)) / len(d.wf(1))
        volt1 = d.wf(3) - sum(d.wf(3)) / len(d.wf(3))
        volt2 = d.wf(5) - sum(d.wf(5)) / len(d.wf(5))
        volt3 = d.wf(7) - sum(d.wf(7)) / len(d.wf(7))
    #volt0 = (ADC0-sum(ADC0)/len(ADC0))
    #volt1 = (ADC1-sum(ADC1)/len(ADC1))
    #volt2 = (ADC2-sum(ADC2)/len(ADC2))
    #volt3 = (ADC3-sum(ADC3)/len(ADC3))

    h = d.header()
    event_time = datetime.datetime.utcfromtimestamp(h.readout_time)
    #e2 = datetime.datetime.utcfromtimestamp(1538447820)
    #alt2=90-GetAltitude(lat,lon,e2)
    #print(alt2)
    #print("Run number is", run_num)
    #print("event is:", ent_num)
    #print("time is:", event_time)
    alt = 90 - GetAltitude(lat, lon, event_time)
    az = GetAzimuth(lat, lon, event_time) + 270
    #print(alt,az)

    #loc = coord.EarthLocation(lon=lon*u.deg,
    #lat=lat*u.deg)
    #print(loc)
    #now = Time(event_time)
    #altaz = coord.AltAz(location=loc, obstime=now)
    #sun = coord.get_sun(now)

    #print(sun.transform_to(altaz).alt)
    #print(sun.transform_to(altaz).az)

    return (volt0, volt1, volt2, volt3, times, -alt, -az)
Пример #6
0
def main():

    #Set these variables before running:

    run_num = 191
    ent_num = 33
    pol = 0  #1 for Hpol, 0 for Vpol
    #os.environ["BEACON_DATA_DIR"]="/project2/avieregg/beacon/telem/raw"
    d = beacon_data_reader.Reader("/project2/avieregg/beacon/telem/root",
                                  run_num)

    #Antenna Positions
    A0 = Antenna(0, 0, 0)
    A1 = Antenna(-6.039, -1.618, 2.275)  #east, north, elevation
    A2 = Antenna(-1.272, -10.362, 1.282)
    A3 = Antenna(3.411, -11.897, -0.432)

    #t1,t2,t3,t4,t5,t6 = generate_time_arrays(A0,A1,A2,A3)

    corr_val1 = np.zeros([60, 120])
    corr_val2 = np.zeros([60, 120])
    corr_val3 = np.zeros([60, 120])
    corr_val4 = np.zeros([60, 120])
    tot_corr = np.zeros([60, 120])

    #Day runs with more than 100,000 events: 191 (17-20), 172(19-22), 174,177, 179,190
    #Day runs with more than 10,000 events: 173, 175, 178,192

    #Night runs with more than 100,000 events: 180,181,182, 183, 186, 187,188,189
    for i in range(0, 500):
        val = i * 200
        corr_val1 = corr_val1 + correlator(191, val, pol, A0, A1, A2, A3)
        corr_val2 = corr_val2 + correlator(172, val, pol, A0, A1, A2, A3)
        corr_val3 = corr_val3 + correlator(174, val, pol, A0, A1, A2, A3)
        corr_val4 = corr_val4 + correlator(177, val, pol, A0, A1, A2, A3)
        tot_corr = tot_corr + corr_val1 + corr_val2 + corr_val3 + corr_val4

    fig = plt.figure(1)
    ax = fig.add_subplot(1, 1, 1)
    im = ax.imshow(corr_val1,
                   interpolation='none',
                   extent=[-180, 180, 180, 0],
                   cmap=plt.cm.coolwarm)  #cmap=plt.cm.jet)
    fig.colorbar(im, ax=ax)
    plt.xlabel('Azimuth Angle (Degrees)')
    plt.ylabel('Zenith Angle (Degrees)')

    fig = plt.figure(2)
    ax = fig.add_subplot(1, 1, 1)
    im = ax.imshow(corr_val2,
                   interpolation='none',
                   extent=[-180, 180, 180, 0],
                   cmap=plt.cm.coolwarm)  #cmap=plt.cm.jet)
    fig.colorbar(im, ax=ax)
    plt.xlabel('Azimuth Angle (Degrees)')
    plt.ylabel('Zenith Angle (Degrees)')

    fig = plt.figure(3)
    ax = fig.add_subplot(1, 1, 1)
    im = ax.imshow(corr_val3,
                   interpolation='none',
                   extent=[-180, 180, 180, 0],
                   cmap=plt.cm.coolwarm)  #cmap=plt.cm.jet)
    fig.colorbar(im, ax=ax)
    plt.xlabel('Azimuth Angle (Degrees)')
    plt.ylabel('Zenith Angle (Degrees)')

    fig = plt.figure(4)
    ax = fig.add_subplot(1, 1, 1)
    im = ax.imshow(corr_val4,
                   interpolation='none',
                   extent=[-180, 180, 180, 0],
                   cmap=plt.cm.coolwarm)  #cmap=plt.cm.jet)
    fig.colorbar(im, ax=ax)
    plt.xlabel('Azimuth Angle (Degrees)')
    plt.ylabel('Zenith Angle (Degrees)')

    fig = plt.figure(5)
    ax = fig.add_subplot(1, 1, 1)
    im = ax.imshow(tot_corr,
                   interpolation='none',
                   extent=[-180, 180, 180, 0],
                   cmap=plt.cm.coolwarm)  #cmap=plt.cm.jet)
    fig.colorbar(im, ax=ax)
    plt.xlabel('Azimuth Angle (Degrees)')
    plt.ylabel('Zenith Angle (Degrees)')

    plt.show()
else:
    event_min = 0
    event_max = 1000
    run=int('1')

print('Event Minimum is: ', event_min)
print('Event Maximum is: ', event_max)
print('run number is: ', run)


#Ben's analysis:
#dd = bt.DataDirectory()
#r = dd.run(141)

#Cosmin's analysis:
d = beacon_data_reader.Reader("/project2/avieregg/beacon/telem/root",run_num)
d.setEntry(45)
h = d.header())

#r.draw('trigger_thresholds')
h_delay =[]
v_delay =[]
event_num = []

#quit()

#loop over multiple entries

num_events = 131000
leng = 1535 #length of time array. THIS CAN CHANGE
Пример #8
0
import beacon_data_reader
import sys




run = int(sys.argv[1]) if len(sys.argv) > 1 else 188
datapath = sys.argv[2] if len(sys.argv) > 2 else "/data/beacon/root"


d = beacon_data_reader.Reader(datapath,run) 

last_wf = [-1]; 

for i in range(d.N()):
  d.setEntry(i) 
  wf = d.wf(0)
  print i, last_wf[0], wf[0]
  last_wf = wf;