def main(): parseXML() heading("Collecting phase data") f = open("phase.csv", "w") lastSampleCnt = parseInt( readReg( getNode('GEM_AMC.TTC.STATUS.CLK.PHASE_MONITOR.SAMPLE_COUNTER'))) phaseArr = [] for i in range(NUM_READS): phaseRaw = parseInt( readReg(getNode('GEM_AMC.TTC.STATUS.CLK.PHASE_MONITOR.PHASE'))) phasePs = phaseRaw * PHASE_UNITS_PS phaseArr.append(phasePs) f.write("%f\n" % phasePs) sampleCnt = lastSampleCnt while sampleCnt == lastSampleCnt: sampleCnt = parseInt( readReg( getNode( 'GEM_AMC.TTC.STATUS.CLK.PHASE_MONITOR.SAMPLE_COUNTER')) ) sleep(0.0001) lastSampleCnt = sampleCnt if i % 1000 == 0: print("Progress: %d / %d" % (i, NUM_READS)) histogram(phaseArr) f.close()
def analyzeBxDiff(events): ohAmcBxOffsets = [] vfatOhBxOffsets = [] vfatAmcBxOffsets = [] for event in events: for chamber in event.chambers: ohAmcBxOffsets.append(chamber.ohBc - event.bxId) for vfat in chamber.vfats: vfatOhBxOffsets.append(vfat.bc - chamber.ohBc) vfatAmcBxOffsets.append(vfat.bc - event.bxId) # print "====================================================" # print "OH BC - AMC BC histogram:" # print "" # histogram(ohAmcBxOffsets, -3564, 3564, 100) # # print "" # print "====================================================" # print "VFAT BC - OH BC histogram:" # print "" # histogram(vfatOhBxOffsets, -3564, 3564, 100) print "" print "====================================================" print "VFAT BC - AMC BC histogram:" print "" # histogram(vfatAmcBxOffsets, -3564, 3564, 100) histogram(vfatAmcBxOffsets, -3564, 3564, 7130)
def analyzeNumChambers(events): numChambers = [] for event in events: numChambers.append(len(event.chambers)) print "====================================================" print "Number of chambers per event histogram:" print "" histogram(numChambers, 0, 8, 8)
def analyzeNumVfats(events): numVfats = [] for event in events: vfats = 0 for chamber in event.chambers: vfats += len(chamber.vfats) numVfats.append(vfats) print "====================================================" print "Number of VFATs per event histogram:" print "" histogram(numVfats)
def train(model_path=None, save_path='/home/cjl/tf_runet/models/20180612', pro_path='/home/cjl/tf_runet', max_size=None, total_step=0, display=False, displaystep=30, save=True, dataidx=10): print('begin_train') data_path = pro_path + '/data/vot2016' data_provider = VOT2016_Data_Provider(data_path, cfg) data_provider.random_batch_init() data_provider.dataidx = dataidx model = Model() train_writer = tf.summary.FileWriter(save_path, model.sess.graph) if model_path is None: model.init_vars_random() else: model.restore(model_path) import psutil training = True while training: total_step += 1 print('--------------------------------------') print('total_step:', total_step) iptdata, gtdata = data_provider.get_a_random_batch(jump=2) weight = ave_weight(gtdata) summary, cost, otherlabels, predict = model.train( iptdata, gtdata, weight) #text_histogram.histogram(list(iptdata.astype(float).reshape((-1)))) #text_histogram.histogram(list(gtdata.astype(float).reshape((-1)))) auc = calc_auc(predict, otherlabels) print("cost:", cost, " auc:", auc) print_step_auc(predict, otherlabels) text_histogram.histogram(list(predict.astype(float).reshape((-1)))) train_writer.add_summary(summary, total_step) if (save and total_step % 20 == 0): filename = save_path + '/train' + str(total_step) model.save(filename) print('========================================')
def analyzeBx(events): ohAmcBxOffsets = [] vfatOhBxOffsets = [] vfatAmcBxOffsets = [] for event in events: for chamber in event.chambers: ohAmcBxOffsets.append(chamber.ohBc - event.bxId) for vfat in chamber.vfats: vfatOhBxOffsets.append(vfat.bc - chamber.ohBc) vfatAmcBxOffsets.append(vfat.bc - event.bxId) print "====================================================" print "OH BC - AMC BC histogram:" print "" histogram(ohAmcBxOffsets, -3564, 3564, 100) print "" print "====================================================" print "VFAT BC - OH BC histogram:" print "" histogram(vfatOhBxOffsets, -3564, 3564, 100) print "" print "====================================================" print "VFAT BC - AMC BC histogram:" print "" histogram(vfatAmcBxOffsets, -3564, 3564, 100)
def benchmark(iterations, func, *args, **kwargs): print(f"running {func} with args {args} {iterations} times ") import timeit timer = timeit.default_timer times = [] for i in range(iterations): times.append(timer()) func(*args) times.append(timer()) deltas = [times[i] - times[i - 1] for i in range(1, len(times))] print(deltas) from text_histogram import histogram print(histogram(deltas))
trace_collection.add_trace(trace_path, 'ctf') except: print(howto) raise class ClientStats: def __init__(self): self.buffers_in_flight = dict() self.buffer_delays = [] clients = dict() for event in trace_collection.events: if event.name == 'mir_server_wayland:sw_buffer_committed': if event['client'] not in clients: clients[event['client']] = ClientStats() clients[event['client']].buffers_in_flight[ event['buffer_id']] = event.timestamp if event.name == 'mir_server_compositor:buffers_in_frame': for buffer in event['buffer_ids']: for client in clients.values(): if buffer in client.buffers_in_flight.keys(): client.buffer_delays.append( event.timestamp - client.buffers_in_flight[buffer]) del client.buffers_in_flight[buffer] for (id, client) in clients.items(): print("Client: ", id) histogram([delay // 1000000 for delay in client.buffer_delays])
for vcf_path in vcf_paths: print("============================") alt_allele_sizes = [] with gzip.open(vcf_path) if vcf_path.endswith(".gz") else open( vcf_path) as f: for line in f: if line.startswith("#"): continue fields = line.strip().split("\t") ref = fields[3] alt_alleles = fields[4] for alt in alt_alleles.split(","): c['total alleles'] += 1 if len(ref) < len(alt): c['insertions'] += 1 alt_allele_sizes.append(len(alt)) elif len(ref) > len(alt): c['deletions'] += 1 elif len(ref) == 1 and len(alt) == 1: c['snps'] += 1 for label, value in sorted(c.items(), key=lambda x: (x[1], x[0]), reverse=True): print("==> %15s : %9d" % (label, value)) print("log2(alt allele length) for insertions in " + vcf_path) histogram(np.log2(alt_allele_sizes), custbuckets=",".join(["%0.1f" % (k / 2.0) for k in range(1, 20)]))
def analyzeBx(events): amcBxs = [] ohBxs = [] vfatBxs = [] amcBxMin = 5000 amcBxMax = -1 numAmcBxOvf = 0 ohBxMin = 5000 ohBxMax = -1 numOhBxOvf = 0 vfatBxMin = 5000 vfatBxMax = -1 numVfatBxOvf = 0 for event in events: amcBxs.append(event.bxId) if event.bxId < amcBxMin: amcBxMin = event.bxId if event.bxId > amcBxMax: amcBxMax = event.bxId if event.bxId > 3564: numAmcBxOvf += 1 for chamber in event.chambers: ohBxs.append(chamber.ohBc) if chamber.ohBc < ohBxMin: ohBxMin = chamber.ohBc if chamber.ohBc > ohBxMax: ohBxMax = chamber.ohBc if chamber.ohBc > 3564: numOhBxOvf += 1 for vfat in chamber.vfats: vfatBxs.append(vfat.bc) if vfat.bc < vfatBxMin: vfatBxMin = vfat.bc if vfat.bc > vfatBxMax: vfatBxMax = vfat.bc if vfat.bc > 3564: numVfatBxOvf += 1 print "" print "====================================================" print "AMC BC histogram:" print "" histogram(amcBxs, 0, 4095, 4096) print "AMC BX Min: %d, AMC BX Max: %d, AMC BX > 3564: %d" % ( amcBxMin, amcBxMax, numAmcBxOvf) print "" print "====================================================" print "OH BC histogram:" print "" histogram(ohBxs, 0, 4095, 4096) print "OH BX Min: %d, OH BX Max: %d, OH BX > 3564: %d" % (ohBxMin, ohBxMax, numOhBxOvf) print "" print "====================================================" print "VFAT BC histogram:" print "" histogram(vfatBxs, 0, 4095, 4096) print "VFAT BX Min: %d, VFAT BX Max: %d, VFAT BX > 3564: %d" % ( vfatBxMin, vfatBxMax, numVfatBxOvf)
#Using text_histogram https://github.com/Kobold/text_histogram #display histogram for Hamming's errors from ex5_3 import errors import text_histogram as t t.histogram(errors, 5, 9, 4)