def check_pols(packets): start = 0 while packets[start].headers[1] != packets[start + 1].headers[1]: start += 1 num_pkts = len(packets) for ctr in range(start, num_pkts-start, 2): pktp0 = packets[ctr] pktp1 = packets[ctr+1] d80p0 = AdcData.sixty_four_to_eighty_skarab(pktp0.data) d80p1 = AdcData.sixty_four_to_eighty_skarab(pktp1.data) for d in d80p0[1:]: if (d >> 79) != 0: msg = 'pol0 data MSB wrong' print(msg) print(pktp0.headers) print(pktp1.headers) IPython.embed() raise RuntimeError(msg) for d in d80p1[1:]: if (d >> 79) != 1: msg = 'pol1 data MSB wrong' print(msg) print(pktp0.headers) print(pktp1.headers) IPython.embed() raise RuntimeError(msg) for dctr in range(len(d80p0)): if (d80p0[dctr] & ((2**79)-1)) != (d80p1[dctr] & ((2**79)-1)): msg = 'pols do not agree' print(msg) print(pktp0.headers) print(pktp1.headers) IPython.embed() raise RuntimeError(msg)
def get_data(): fpga.snapshots.snapadc0_ss.arm() fpga.snapshots.snapadc1_ss.arm() fpga.registers.ctrl2.write(trig_adc_snaps='pulse') snapdata_p0 = fpga.snapshots.snapadc0_ss.read(arm=False)['data'] snapdata_p1 = fpga.snapshots.snapadc1_ss.read(arm=False)['data'] snapdata_p1['p1'] = [] for ctr, msb_data in enumerate(snapdata_p0['p1_msb']): snapdata_p1['p1'].append((msb_data << 32) + snapdata_p1['p1_lsb'][ctr]) data_p0 = AdcData.eighty_to_ten(snapdata_p0['p0']) data_p1 = AdcData.eighty_to_ten(snapdata_p1['p1']) return {'p0': data_p0, 'p1': data_p1}
def check_counter80(packets): start = 0 while packets[start].headers[1] != packets[start + 1].headers[1]: start += 1 num_pkts = len(packets) last_cnt = None for ctr in range(start, num_pkts - start, 2): # print('DOING PKT', ctr, last_cnt) pkt = packets[ctr] d80 = AdcData.sixty_four_to_eighty_skarab(pkt.data) if pkt.headers[1] != d80[0]: msg = 'timestamp in data does not match SPEAD header' print(pkt.headers[1]) print(d80[0]) print(msg) IPython.embed() raise RuntimeError(msg) for d80ctr in range(len(d80)): d80[d80ctr] = d80[d80ctr] & ((2**79)-1) if last_cnt is None: last_cnt = d80[1] - 2 if d80[1] != last_cnt + 2: msg = 'break in the count at the first word' print(ctr) print(packets[ctr-1].headers) print(pkt.headers) d80_0 = AdcData.sixty_four_to_eighty_skarab(packets[ctr - 1].data) d80_1 = AdcData.sixty_four_to_eighty_skarab(packets[ctr].data) d80_2 = AdcData.sixty_four_to_eighty_skarab(packets[ctr + 1].data) print([(d & ((2 ** 79) - 1)) for d in d80_0[0:5]]) print([(d & ((2 ** 79) - 1)) for d in d80_1[0:5]]) print([(d & ((2 ** 79) - 1)) for d in d80_2[0:5]]) print(d80[1]) print(last_cnt) print(msg) IPython.embed() raise RuntimeError(msg) last_cnt = d80[1] - 1 for dword in d80[1:]: if dword != last_cnt + 1: msg = 'break in the count' print(dword) print(last_cnt) print(msg) IPython.embed() raise RuntimeError(msg) last_cnt += 1
def get_data(tvg=False): fpga.snapshots.packed_p0_ss.arm() fpga.snapshots.packed_p1_ss.arm() fpga.registers.ctrl2.write(arm_pack_snap='pulse') snapdata_p0 = fpga.snapshots.packed_p0_ss.read(arm=False)['data']['p0'] snapdata_p1 = fpga.snapshots.packed_p1_ss.read(arm=False)['data']['p0'] data_p0 = AdcData.sixty_four_to_eighty(snapdata_p0) data_p1 = AdcData.sixty_four_to_eighty(snapdata_p1) if tvg: data_p0 = eighty_to_ten_TVG(data_p0) data_p1 = eighty_to_ten_TVG(data_p1) else: data_p0 = AdcData.eighty_to_ten(data_p0) data_p1 = AdcData.eighty_to_ten(data_p1) return {'p0': data_p0, 'p1': data_p1}
gbe_data = [] for pkt in gbepackets: gbe_data.append(pkt[data_key]) spead_processor.process_data(gbe_data) del gbepackets print 'Checking packet contents.' last_time = spead_processor.packets[0].headers[0x1600] - 8192 errors_headers = 0 errors_datatime = 0 errors_dataramp = 0 pkt_times = [] for pkt in spead_processor.packets: if pkt.headers[0x1600] != last_time + 8192: errors_headers += 1 pkt_times.append(pkt.headers[0x1600]) data80 = AdcData.sixty_four_to_eighty(pkt.data) data_tvg = [] for word80 in data80: time80 = word80 >> 32 ctr80 = (word80 & 0xffffffff) >> 1 pol80 = word80 & 0x01 data_tvg.append((time80, ctr80, pol80)) del data80 if data_tvg[0][0] != last_time + 8192: errors_datatime += 1 if data_tvg[0][1] != 0: errors_dataramp += 1 data_time = data_tvg[0][0] - 8 data_ctr = data_tvg[0][1] - 1 for ctr, data in enumerate(data_tvg): if data[0] != data_time + 8: