def dohist(base_name='hist', type='sin', gethist=True, plt=True): hc_name=base_name+'_cores' if gethist: get_hist(fname=hc_name) res = np.empty([5, 256], dtype=float) res[0] = np.arange(256, dtype=float) z_fact = 500.0/256.0 (a1,z1), res[1] =fit_cores.fit_hist(1,type, hc_name) (a2,z2), res[2] =fit_cores.fit_hist(2,type, hc_name) (a3,z3), res[3] =fit_cores.fit_hist(3,type, hc_name) (a4,z4), res[4] =fit_cores.fit_hist(4,type, hc_name) avamp = (a1+a2+a3+a4)/4.0 # Reverse the amplitude and zero differences so they can be applied to the # offset and gain registers directly. The phase registers don't need the # reversal a1p = 100*(avamp -a1)/avamp a2p = 100*(avamp -a2)/avamp a3p = 100*(avamp -a3)/avamp a4p = 100*(avamp -a4)/avamp ogp=np.array([z_fact*z1, a1p, 0, z_fact*z2, a2p, 0, z_fact*z3, a3p, 0, \ z_fact*z4, a4p, 0]) avz=(z1+z2+z3+z4)*z_fact/4.0 print "#avg %7.4f %7.4f %8.4f" % (ogp[1], avamp, 0) print "core A %7.4f %7.4f %8.4f" % tuple(ogp[0:3]) print "core B %7.4f %7.4f %8.4f" % tuple(ogp[3:6]) print "core C %7.4f %7.4f %8.4f" % tuple(ogp[6:9]) print "core D %7.4f %7.4f %8.4f" % tuple(ogp[9:12]) np.savetxt(base_name+"_ogp.meas", ogp, fmt= "%8.4f") r_name=base_name+'.res' np.savetxt(r_name, np.transpose(res), fmt='%3i %6.3f %6.3f %6.3f %6.3f') fit_cores.fit_inl(fname=r_name) if plt: plotres(r_name)
def dohist(base_name='hist', type='sin', gethist=True, plt=True): hc_name = base_name + '_cores' if gethist: get_hist(fname=hc_name) res = np.empty([5, 256], dtype=float) res[0] = np.arange(256, dtype=float) z_fact = 500.0 / 256.0 (a1, z1), res[1] = fit_cores.fit_hist(1, type, hc_name) (a2, z2), res[2] = fit_cores.fit_hist(2, type, hc_name) (a3, z3), res[3] = fit_cores.fit_hist(3, type, hc_name) (a4, z4), res[4] = fit_cores.fit_hist(4, type, hc_name) avamp = (a1 + a2 + a3 + a4) / 4.0 # Reverse the amplitude and zero differences so they can be applied to the # offset and gain registers directly. The phase registers don't need the # reversal a1p = 100 * (avamp - a1) / avamp a2p = 100 * (avamp - a2) / avamp a3p = 100 * (avamp - a3) / avamp a4p = 100 * (avamp - a4) / avamp ogp=np.array([z_fact*z1, a1p, 0, z_fact*z2, a2p, 0, z_fact*z3, a3p, 0, \ z_fact*z4, a4p, 0]) avz = (z1 + z2 + z3 + z4) * z_fact / 4.0 print "#avg %7.4f %7.4f %8.4f" % (ogp[1], avamp, 0) print "core A %7.4f %7.4f %8.4f" % tuple(ogp[0:3]) print "core B %7.4f %7.4f %8.4f" % tuple(ogp[3:6]) print "core C %7.4f %7.4f %8.4f" % tuple(ogp[6:9]) print "core D %7.4f %7.4f %8.4f" % tuple(ogp[9:12]) np.savetxt(base_name + "_ogp.meas", ogp, fmt="%8.4f") r_name = base_name + '.res' np.savetxt(r_name, np.transpose(res), fmt='%3i %6.3f %6.3f %6.3f %6.3f') fit_cores.fit_inl(fname=r_name) if plt: plotres(r_name)
def multifreq(start=100, end=560, step=50, repeat=5, do_sfdr=False): """ Calls dosnap for a range of frequenciesi in MHz. The actual frequencies are picked to have an odd number of cycles in the 16384 point snapshot. """ global ogp_name name = "if%d" % (zdok) sfd = open('sinad', 'a') f = samp_freq / numpoints nstart = int(0.5 + start / f) nend = int(0.5 + end / f) nstep = int(0.5 + step / f) for n in range(nstart, nend, nstep): freq = f * n set_freq(freq) # ogp, avg_pwr_sinad = dosnap(rpt=repeat, donot_clear = False) ogp, avg_pwr_sinad = dosnap(rpt=repeat, name=name,\ donot_clear = n!=nstart, plot=False) sinad = 10.0 * np.log10(avg_pwr_sinad) print >> sfd, "%8.3f %7.2f" % (freq, sinad) if do_sfdr: dopsd(rpt=3) fit_cores.dosfdr(freq) np.savetxt(ogp_name + ".meas", ogp[3:], fmt="%8.4f") fit_cores.fit_inl(name + '.res')
def multifreq(start=100, end=560, step=50, repeat=5, do_sfdr=False): """ Calls dosnap for a range of frequenciesi in MHz. The actual frequencies are picked to have an odd number of cycles in the 16384 point snapshot. """ global ogp_name name = "if%d" % (zdok) sfd = open('sinad', 'a') f = samp_freq / numpoints nstart = int(0.5+start/f) nend = int(0.5+end/f) nstep = int(0.5+step/f) for n in range(nstart, nend, nstep): freq = f*n set_freq(freq) # ogp, avg_pwr_sinad = dosnap(rpt=repeat, donot_clear = False) ogp, avg_pwr_sinad = dosnap(rpt=repeat, name=name,\ donot_clear = n!=nstart, plot=False) sinad = 10.0*np.log10(avg_pwr_sinad) print >>sfd, "%8.3f %7.2f" % (freq, sinad) if do_sfdr: dopsd(rpt=3) fit_cores.dosfdr(freq) np.savetxt(ogp_name+".meas", ogp[3:], fmt="%8.4f") fit_cores.fit_inl(name+'.res')
def do_inl(self, zdok): self.set_zdok(zdok) #timestamp = '_' #FNAME = 'snapshot_adc%d_raw%s.dat'%(zdok, timestamp) #rww_init(zdok, clockrate) print('doing inl calibration for zdok ' + str(zdok)) logger.debug("Clearing INL") #rww_tools.clear_inl() self.clear_inl() print("sleeping for 1 secs") time.sleep(1) #fit_cores.fit_inl(FNAME + ".res") # The .res file used here is a 256 by 4 (by cores?) list of residuals. TBF: who writes this? # This is used to compute the INLs, which are stored in inl*.meas self.inls = fit_cores.fit_inl(self.get_snapshot_res_filename(), outname = self.get_inl_meas_filename()) #rww_tools.update_inl(fname = 'inl%s.meas'%timestamp) self.update_inl() #fname = self.get_inl_meas_filename()) print('INL done')
def do_inl(self, zdok): self.set_zdok(zdok) #timestamp = '_' #FNAME = 'snapshot_adc%d_raw%s.dat'%(zdok, timestamp) #rww_init(zdok, clockrate) logger.debug('doing inl calibration for zdok ' + str(zdok)) logger.debug("Clearing INL") #rww_tools.clear_inl() self.clear_inl() logger.debug("sleeping for 1 secs") time.sleep(1) #fit_cores.fit_inl(FNAME + ".res") # The .res file used here is a 256 by 4 (by cores?) list of residuals. TBF: who writes this? # This is used to compute the INLs, which are stored in inl*.meas self.inls = fit_cores.fit_inl(self.get_snapshot_res_filename(), outname = self.get_inl_meas_filename()) #rww_tools.update_inl(fname = 'inl%s.meas'%timestamp) self.update_inl() #fname = self.get_inl_meas_filename()) logger.debug('INL done')
rww_tools.set_gains(t[1], t[4], t[7], t[10]) rww_tools.set_phase(t[2], t[5], t[8], t[11]) print "OGP registers ADC 1: " rww_tools.zdok = 1 # set ADC to calibrate rww_tools.get_ogp() # INL CORRECTIONS textname = "snapshot_adc1_raw.dat.res" print "INL corrections correction... " rww_tools.clear_inl() rww_tools.get_inl() fit_cores.fit_inl(textname) rww_tools.set_inl("inl.meas") print "INL registers: " rww_tools.get_inl() print "done" ################################################################## ################### CALIBRACION ZDOK0 ############################ ################################################################## # rwwtools parameters to use rww_tools.roach2 = fpga rww_tools.freq = opts.testfreq
rww_tools.set_gains(t[1], t[4], t[7], t[10]) rww_tools.set_phase(t[2], t[5], t[8], t[11]) print 'OGP registers ADC 1: ' rww_tools.zdok = 1 # set ADC to calibrate rww_tools.get_ogp() # INL CORRECTIONS textname = 'snapshot_adc1_raw.dat.res' print 'INL corrections correction... ' rww_tools.clear_inl() rww_tools.get_inl() fit_cores.fit_inl(textname) rww_tools.set_inl('inl.meas') print 'INL registers: ' rww_tools.get_inl() print 'done' ################################################################## ################### CALIBRACION ZDOK0 ############################ ################################################################## # rwwtools parameters to use rww_tools.roach2 = fpga rww_tools.freq = opts.testfreq