def db_datedir(datedir_list, ABS, cursor): for datedir in datedir_list: print datedir iv_files = glob.glob(datedir + '/iv_1?????????') det_ivs = [] for iv_file in iv_files: ctime = iv_file.split('v_')[1] print iv_file try: db_bias = np.genfromtxt(iv_file + '.bias', skiprows=1) rec_biases = fh.IV_data_to_arr(iv_file + '.out', 'rec_biases') bias_volts = rec_biases[:, 0] * ABS.db_DAC_volts / 2**ABS.db_bits / ABS.Rdetb data = fh.get_mce_data(iv_file, row_col=True) for col in np.arange(ABS.num_cols): Rsh = ABS.Rshunt_cols[col] target_bias = bias_volts[ABS.bias_lines[col]] for row in np.arange(ABS.num_rows): # print 'col:', col,' row: ', row data_tes = data[row, col, :] if np.median(np.diff( data_tes[0:ABS.index_normal])) > 0: data_tes = data_tes * -1 clean = Clean() data_tes = clean.data_fix_jumps(data_tes) # tes=iv.IV(data=data_tes,db_bias=db_bias,Rsh=Rsh,filtgain=ABS.filtgain,Rfb=ABS.Rfb,Rdetb=ABS.Rdetb, index_normal=ABS.index_normal, dac_bits=ABS.dac_bits, M_ratio=ABS.M_ratio, db_bits=ABS.db_bits, fb_DAC_volts=ABS.fb_DAC_volts, db_DAC_volts=ABS.db_DAC_volts) # Rn=np.median(tes.Rtes[0:ABS.index_normal]) # Psat=tes.calc_Psat_inter(Rn,PRn_min=0.75,PRn_max=0.85) # fit=tes.fit_params() # det=(int(ctime),int(col),int(row),Rsh,Rn,Psat,target_bias,fit[0],fit[1],fit[2],fit[3],fit[4],fit[5],fit[6]) # det_ivs.append(det) except: print sys.exc_info() break
def db_datedir(datedir_list, ABS, cursor): for datedir in datedir_list: print datedir iv_files=glob.glob(datedir+'/iv_1?????????') det_ivs=[] for iv_file in iv_files: ctime=iv_file.split('v_')[1] ind_miss=np.where(missing==int(ctime))[0] print ind_miss if len(ind_miss) > 0: print iv_file # try: db_bias=np.genfromtxt(iv_file+'.bias',skiprows=1) rec_biases=fh.IV_data_to_arr(iv_file+'.out','rec_biases') bias_volts=rec_biases[:,0]*ABS.db_DAC_volts/2**ABS.db_bits/ABS.Rdetb data=fh.get_mce_data(iv_file,row_col=True) print "first col loop start" for col in np.arange(ABS.num_cols): Rsh=ABS.Rshunt_cols[col] target_bias=bias_volts[ABS.bias_lines[col]] for row in np.arange(ABS.num_rows): # print 'col:', col,' row: ', row data_tes=data[row,col,:] if np.median(np.diff(data_tes[0:ABS.index_normal])) > 0: data_tes=data_tes*-1 clean=Clean() data_tes=clean.data_fix_jumps(data_tes) tes=iv.IV(data=data_tes,db_bias=db_bias,Rsh=Rsh,filtgain=ABS.filtgain,Rfb=ABS.Rfb,Rdetb=ABS.Rdetb, index_normal=ABS.index_normal, dac_bits=ABS.dac_bits, M_ratio=ABS.M_ratio, db_bits=ABS.db_bits, fb_DAC_volts=ABS.fb_DAC_volts, db_DAC_volts=ABS.db_DAC_volts) Rn=np.median(tes.Rtes[0:ABS.index_normal]) Psat=tes.calc_Psat_inter(Rn,PRn_min=0.75,PRn_max=0.85) fit=tes.fit_params() det=(int(ctime),int(col),int(row),Rsh,Rn,Psat,target_bias,fit[0],fit[1],fit[2],fit[3],fit[4],fit[5],fit[6]) det_ivs.append(det) # except: # print sys.exc_info() # break cursor.executemany('''INSERT INTO ivs(ctime,col,row,rsh,rn,psat,target_bias,fit0,fit1,fit2,fit3,fit4,fit5,fit6) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)''',det_ivs) db.commit()
ax1=fig.add_subplot(211) ax2=fig.add_subplot(212) fig=plt.figure(3) ax4=fig.add_subplot(111) #ax5=fig.add_subplot(312) #ax6=fig.add_subplot(313) Psat=np.zeros(len(temp)) i=0 for filename in filenames: print filename data=fh.get_mce_data(filename,row_col=True) data_tes=data[row,col,:]*args.polarity clean=Clean() data_tes=clean.data_fix_jumps(data_tes) db_bias=np.genfromtxt(filename+'.bias',skiprows=1) if args.ABS: tes=iv.IV(data_tes,db_bias,Rsh,filtgain=1311,Rfb=7080,Rdetb=582) else: tes=iv.IV(data_tes,db_bias,Rsh) Ites,Vtes,Rtes,Ptes,Ibias=tes.IV_calib(index_normal) Ibias_target=tes.detbias_dac_to_Ibias(target_bias) if Ibias_target > 0: index_target=np.where(Ibias < Ibias_target)[0][0] print Ibias[index_target],Ibias_target print 'Rtes target=',Rtes[index_target] else: index_target=0 resp=tes.resp(index_normal)
from matplotlib.backends.backend_pdf import PdfPages parser = argparse.ArgumentParser( description= 'analyses CLASS test array iv, picks optimal bias for each group', formatter_class=argparse.ArgumentDefaultsHelpFormatter, fromfile_prefix_chars='@') parser.add_argument('filename', type=str, help='I-V file to analyze') parser.add_argument('--plot', action='store_true', help='plot I-V raw data and results for all detectors') args = parser.parse_args() filename = args.filename test = param() clean = Clean(thres_jump=test.thres_jump) def find_optimal_bias_DAC(PRn_group, DAC_bias_group, PRn_low, PRn_high, optimal_DAC_default): DAC_bias_group_Rn_cut = [] for i in np.arange(len(DAC_bias_group)): bias_set = DAC_bias_group[i] PRn_set = PRn_group[i] bias_set_cut = bias_set[np.where( np.logical_and(PRn_set > PRn_low, PRn_set < PRn_high))] DAC_bias_group_Rn_cut.append(bias_set_cut) all_bias = np.concatenate(DAC_bias_group_Rn_cut, axis=0) if len(all_bias) == 0: all_bias = [optimal_DAC_default]
import matplotlib.pyplot as plt import iv import filehandler as fh from Qband_param import Qband_param from clean_timestream import Clean import argparse from matplotlib.backends.backend_pdf import PdfPages parser=argparse.ArgumentParser(description= 'analyses CLASS Qband array iv, picks optimal bias for each group', formatter_class=argparse.ArgumentDefaultsHelpFormatter,fromfile_prefix_chars='@') parser.add_argument('filename', type=str,help='I-V file to analyze') parser.add_argument('--plot', action='store_true', help='plot I-V raw data and results for all detectors') args=parser.parse_args() filename=args.filename Qband=Qband_param() clean=Clean(thres_jump=Qband.thres_jump) def find_optimal_bias_DAC(PRn_group,DAC_bias_group, PRn_low, PRn_high, optimal_DAC_default): DAC_bias_group_Rn_cut=[] for i in np.arange(len(DAC_bias_group)): bias_set=DAC_bias_group[i] PRn_set=PRn_group[i] bias_set_cut=bias_set[np.where(np.logical_and(PRn_set > PRn_low, PRn_set < PRn_high))] DAC_bias_group_Rn_cut.append(bias_set_cut) all_bias=np.concatenate(DAC_bias_group_Rn_cut,axis=0) if len(all_bias) == 0: all_bias=[optimal_DAC_default] bias_count=np.bincount(np.int0(all_bias)) common_biases=np.where(bias_count == np.max(bias_count))[0]