def image_asics(data1=None, data2=None, all1=None): """ Return an image of detectors on the focal plane. Each asic has 124 TES and 4 thermometers. Parameters ---------- data1 : 1D array of shape 128 or 256 Signal of 1 or 2 asics at a given time sample. data2 : same as data1 all1 : bool True if you have 2 asics and False if you have only one. """ if all1 is not None: nn = len(all1)/2 data2 = all1[nn:] data1 = all1[0:nn] if data1 is not None: a1 = qp() a1.assign_asic(1) a1.pix_grid[1,16] = 1005 a1.pix_grid[2,16] = 1006 a1.pix_grid[3,16] = 1007 a1.pix_grid[4,16] = 1008 if data2 is not None: a2 = qp() a2.assign_asic(2) a2.pix_grid[0,15] = 1004 a2.pix_grid[0,14] = 1003 a2.pix_grid[0,13] = 1002 a2.pix_grid[0,12] = 1001 nrows = 17 ncols = 17 img = np.zeros((nrows,ncols)) + np.nan for row in range(nrows): for col in range(ncols): if data1 is not None: physpix = a1.pix_grid[row , col] if physpix in a1.TES2PIX[0]: TES = a1.pix2tes(physpix) img[row,col] = data1[TES - 1] if data2 is not None: physpix = a2.pix_grid[row, col] if physpix in a2.TES2PIX[1]: TES = a2.pix2tes(physpix) img[row,col] = data2[TES - 1] return img
def read_data_from_20170905(): ''' read the data from the measurement campaign of 5/6 Sept 2017 ''' fitslist=['QUBIC_TES_20170905T082847UTC.fits', 'QUBIC_TES_20170905T091628UTC.fits', 'QUBIC_TES_20170905T095550UTC.fits', 'QUBIC_TES_20170905T145150UTC.fits', 'QUBIC_TES_20170905T154040UTC.fits', 'QUBIC_TES_20170905T165531UTC.fits', 'QUBIC_TES_20170905T172101UTC.fits', 'QUBIC_TES_20170906T075624UTC.fits', 'QUBIC_TES_20170906T085757UTC.fits', 'QUBIC_TES_20170906T091909UTC.fits', 'QUBIC_TES_20170906T094433UTC.fits', 'QUBIC_TES_20170906T101411UTC.fits', 'QUBIC_TES_20170906T113411UTC.fits', 'QUBIC_TES_20170906T121954UTC.fits', 'QUBIC_TES_20170906T123554UTC.fits'] datlist=[] for F in fitslist: datlist.append(qp()) datlist[-1].read_fits(F) return datlist
def qs2array(file, FREQ_SAMPLING, timerange=None): """ Loads qubic instance to create 'dd' which is TOD for each TES Also normalises raw data Also returns 'time' which is linear time array Can also specify a timerange """ a = qp() a.read_fits(file) npix = a.NPIXELS nsamples = len(a.timeline(TES=1)) dd = np.zeros((npix, nsamples)) ##### Normalisation en courant #Rfb=100e3 #changing to read from pystudio dictionary Rfb = a.Rfeedback NbSamplesPerSum = 64. #this could also be a.NPIXELS_sampled gain=1./2.**7*20./2.**16/(NbSamplesPerSum*Rfb) for i in xrange(npix): dd[i,:] = a.timeline(TES=i+1) dd[i,:] = gain * dd[i,:] time = np.arange(nsamples)/FREQ_SAMPLING if timerange is not None: print('Selecting time range: {} to {} sec'.format(timerange[0], timerange[1])) oktime = (time >= timerange[0]) & (time <= timerange[1]) time = time[oktime] dd = dd[:,oktime] return time, dd, a
def make_translation_table(): go = qp() transdic = [] RTlist = read_txtcolumns('P73_room_temperature.txt') npts_rt = len(RTlist) for val in RTlist: entry = {} PIX = int(eval(val[0])) entry['PIX'] = PIX try: entry['R300'] = eval(val[1]) except: if val[1] == 'HS': entry['R300'] = 'open' else: entry['R300'] = val[1] if PIX in go.TES2PIX[0, :]: asic = 1 elif PIX in go.TES2PIX[1, :]: asic = 2 else: entry['TES'] = -1 entry['ASIC'] = -1 transdic.append(entry) continue go.assign_asic(asic) TES = go.pix2tes(PIX) entry['TES'] = TES entry['ASIC'] = asic transdic.append(entry) transdic = assign_openloop_results(transdic, 1) transdic = assign_openloop_results(transdic, 2) # assign the results of the Carbon Fibre tests transdic = assign_carbon_fibre_results(transdic) # make sure all entries have all keys allkeys = ['TES', 'PIX', 'ASIC', 'R300', 'OpenLoop', 'CarbonFibre'] nkeys = len(allkeys) for entry in transdic: for key in allkeys: if not key in entry: entry[key] = 'no data' return transdic
def assign_room_temperature_results(transdic, detector_name): ''' assign the Room Temperature Results ''' RTlist = read_txtcolumns('%s_room_temperature.txt' % detector_name) if not isinstance(RTlist, list): print('WARNING! Could not find the Room Temperature test results') return transdic go = qp() npts_rt = len(RTlist) for val in RTlist: entry = {} PIX = int(eval(val[0])) entry['PIX'] = PIX try: entry['R300'] = eval(val[1]) except: if val[1] == 'HS': entry['R300'] = 'open' else: entry['R300'] = val[1] if PIX in go.TES2PIX[0, :]: asic = 1 elif PIX in go.TES2PIX[1, :]: asic = 2 else: entry['TES'] = -1 entry['ASIC'] = -1 transdic.append(entry) continue go.assign_asic(asic) TES = go.pix2tes(PIX) entry['TES'] = TES entry['ASIC'] = asic transdic.append(entry) return transdic
def read_data_from_20170804(): ''' read data from the test campaign of 2017-08-04 I-V curves of P73 at different bath temperatures ''' files=[] datlist=[] files.append('QUBIC_TES_20170804T134238UTC.fits') files.append('QUBIC_TES_20170804T144916UTC.fits') files.append('QUBIC_TES_20170804T150120UTC.fits') files.append('QUBIC_TES_20170804T151319UTC.fits') files.append('QUBIC_TES_20170804T152431UTC.fits') files.append('QUBIC_TES_20170804T153704UTC.fits') files.append('QUBIC_TES_20170804T155105UTC.fits') files.append('QUBIC_TES_20170804T160111UTC.fits') idx=0 for F in files: datlist.append(qp()) datlist[idx].read_fits(F) idx+=1 return datlist
def plot_V_phi(Asic): # Mutual inductance Min=1./10.4E-6 AsicNum=Asic ### V Phi plot ### # !!!!!!!!!!!!!!!! Attention un peu long , a remanier !!!!!!!!!!!!!! for z in range (128): # the first 8 index are too low to induce curves, so we start at 7 for i in range(9): thedir = dirs[i+7] # reading the data from qubicpack b = qp() b.read_qubicstudio_dataset(thedir, asic=AsicNum) Rbias=b.Rbias # Amplitude peak to peak of the sinus amp=b.max_bias-b.min_bias # offset of the sinus signal offset=0.5*(b.max_bias+b.min_bias) Vbias=(offset+amp*b.bias_phase()/2.) # Ind : this allow to avoid the noncoherent points in raw data for the flux ind=np.argsort(Vbias) # temp is a temporaly variable that will be used after for the filter if i == 0: Vsqoffset=np.mean(b.timeline(TES=z+1)*62.5/(70.*100)/(b.nsamples-b.n_masked())) temp = b.timeline(TES=z+1)[ind]*62.5/(70.*100)/(b.nsamples-b.n_masked())-Vsqoffset # savitzky golay filter filt = sp.signal.savgol_filter(temp, 51, 3) ### plot parameters ### plt.plot(((Vbias[ind]/Rbias*Min)-(Vbias[ind]/Rbias*Min)[0])/2.,filt*-1) plt.grid() plt.xlabel('Flux (in quantum of flux)') plt.ylabel('Tension ($\mu$V)') plt.title('ASIC%i (input), SQUID number %i'%(AsicNum,(z+1))) save("./TEST/Analysis"+day+"/ASIC%i_Vphi/ASIC%i_%i"%(AsicNum,AsicNum,(z+1)),ext="png",close=True,verbose=True)
import glob from qubicpack import qubicpack as qp import string basedir = '/Users/hamilton/Qubic/Grounding/' dirs = glob.glob(basedir+'/*') motor = [] grounding = [] for i in range(len(dirs)): bla = string.split(dirs[i],'_') grounding.append(bla[-2]) motor.append(bla[-1]) a1 = qp() a1.read_qubicstudio_dataset(dirs[0], asic=1) a2 = qp() a2.read_qubicstudio_dataset(dirs[0], asic=2) nsamples = len(a1.timeline(TES=66)) FREQ_SAMPLING = 1./a1.sample_period() spectrum, freq = mlab.psd(2 a1.timeline(TES=66), Fs=FREQ_SAMPLING, NFFT=nsamples, window=mlab.window_hanning) ok1 = np.array(FitsArray('/Users/hamilton/Qubic/ExternalSource/ScanAz2019-01-30_OK_Asic1.fits'), dtype=bool) ok2 = np.array(FitsArray('/Users/hamilton/Qubic/ExternalSource/ScanAz2019-01-30_OK_Asic2.fits'), dtype=bool) ok = np.append(ok1,ok2)
spectrum_f[okfit], np.ones(np.sum(okfit)), guess, functname=dl.gauss, fixpars=[1, 0, 0, 0, 0], nohesse=True, force_chi2_ndf=True) return t_data, data, FREQ_SAMPLING, freq_f, spectrum_f, amp_peak, okfit, res # =========== Test with one TES ============== # Read data from a given ASIC AsicNum = 1 a = qp() a.read_qubicstudio_dataset(thedir, asic=AsicNum) freq_mod = 1. tes_num = 44 t_data, data, FREQ_SAMPLING, freq_f, spectrum_f, amp_peak, okfit, res = get_amp_first_harmonic( a, tes_num, freq_mod) print('FREQ_SAMPLING = {}'.format(FREQ_SAMPLING)) # Signal as a function of time plot(t_data, (data - np.mean(data)) / np.std(data), label='Data') # Look at the amplitude of the peak print('Amplitude = {}'.format(res[1][2])) figure('TES spectrum')
$auth: Steve Torchinsky <*****@*****.**> $created: Fri 15 Dec 2017 17:58:35 CET $license: GPLv3 or later, see https://www.gnu.org/licenses/gpl-3.0.txt This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. this is a translation of the Dscript: Comp_offset_ASIC1b.dscript once tested, it will be moved into qubicpack acquisition.py ''' from qubicpack import qubicpack as qp import numpy as np go = qp() go.assign_asic(1) go.assign_integration_time(0.5) client = go.connect_QubicStudio() if client is None: quit() count = 10 consigne = 0 # first switch off the loop client.sendActivatePID(go.QS_asic_index, 0) # make sure relay=10kOhm val=1 -> 10kOhm, val=0 -> 100kOhm client.sendSetFeedbackRelay(go.QS_asic_index, 1)
def plot_physical_layout(a1=None, a2=None, figsize=(16, 16), xwin=True, lutmin=None, lutmax=None, timeline_index=None, tmin=None, tmax=None): ''' plot an image of the TES array labeling each pixel plot the I-V curves in the appropriate boxes if a1 and/or a2 given ''' obj_list = [a1, a2] asic1_obj = None asic2_obj = None temperature = None temperature_str = '' detector_name = 'undefined' for obj in obj_list: if isinstance(obj, qp): temperature = obj.temperature detector_name = obj.detector_name if obj.asic == 1: asic1_obj = obj elif obj.asic == 2: asic2_obj = obj else: print( 'PROBLEM! QubicPack object does not have a valid ASIC definition' ) return None if asic1_obj is None: asic1_obj = qp() asic1_obj.assign_asic(1) asic1_fontsize = figsize[0] if asic2_obj is None: asic2_obj = qp() asic2_obj.assign_asic(2) asic2_fontsize = figsize[0] # Option: plot timeline instead of I-V if timeline_index is not None: print('plotting timelines in focal plane') tdata = asic1_obj.tdata[timeline_index] timeline_npts = tdata['TIMELINE'].shape[1] ilim = [None, None] tlim = [0, timeline_npts] if tmin is not None: tlim[0] = tmin if tmax is not None: tlim[1] = tmax if lutmax is None: lutmax = tdata['TIMELINE'].max() - tdata['TIMELINE'].min() if lutmin is None: lutmin = 0.0 # Option: a1 and a2 can be simply arrays with numbers to use as the colours for each pixel asic1_mapdata = False asic2_mapdata = False if (isinstance(a1, np.ndarray) or isinstance(a1, list)) and len(a1) == 128: print('using mapping data for asic 1') asic1_mapdata = True if (isinstance(a2, np.ndarray) or isinstance(a2, list)) and len(a2) == 128: print('using mapping data for asic 2') asic2_mapdata = True if lutmin is None: if asic1_mapdata and asic2_mapdata: lutmin = min(min(a1), min(a2)) elif asic1_mapdata: lutmin = min(a1) elif asic2_mapdata: lutmin = min(a2) if lutmax is None: if asic1_mapdata and asic2_mapdata: lutmax = max(max(a1), max(a2)) elif asic1_mapdata: lutmax = max(a1) elif asic2_mapdata: lutmax = max(a2) asic1_data = True asic1_iv_data = True asic1_timeline_data = True asic1_fontsize = 8 asic2_data = True asic2_iv_data = True asic2_timeline_data = True asic2_fontsize = 8 if not asic1_obj.exist_iv_data(): asic1_iv_data = False if not asic1_obj.exist_timeline_data() or timeline_index is None: asic1_timeline_data = False if not asic1_iv_data and not asic1_timeline_data: asic1_data = False asic1_fontsize = figsize[0] asic1_subttl = 'ASIC 1 blue background' else: asic1_subttl = 'Array %s ASIC1 black curves' % asic1_obj.detector_name if not asic2_obj.exist_iv_data(): asic2_iv_data = False if not asic2_obj.exist_timeline_data() or timeline_index is None: asic2_timeline_data = False if not asic2_iv_data and not asic2_timeline_data: asic2_data = False asic2_fontsize = figsize[0] asic2_subttl = 'ASIC 2 green background' else: asic2_subttl = 'Array %s ASIC2 blue curves' % asic2_obj.detector_name asic1_obj.figsize = figsize fontsize = figsize[0] ttlfontsize = figsize[0] * 1.2 nrows = asic1_obj.pix_grid.shape[0] ncols = asic1_obj.pix_grid.shape[1] if temperature is not None: temperature_str = '%.0fmK' % (1000 * temperature) if xwin: plt.ion() else: plt.ioff() fig, ax = plt.subplots(nrows, ncols, figsize=asic1_obj.figsize) fig.text(0.5, 0.985, 'QUBIC TES array', ha='center', fontsize=ttlfontsize) pngname = 'TES_Array-%s_%s.png' % (detector_name, temperature_str) if xwin: fig.canvas.set_window_title('plt: QUBIC TES array') ngood = 0 npix = 0 if asic1_data: asic1_subttl+=', data from %s, T$_\mathrm{bath}$=%.3fmK'\ % (asic1_obj.obsdate.strftime('%Y-%m-%d %H:%M'),asic1_obj.temperature*1000) ngood += asic1_obj.ngood() npix += asic1_obj.NPIXELS if asic2_data: asic2_subttl+=', data from %s, T$_\mathrm{bath}$=%.3fmK'\ % (asic2_obj.obsdate.strftime('%Y-%m-%d %H:%M'),asic2_obj.temperature*1000) ngood += asic2_obj.ngood() npix += asic2_obj.NPIXELS subttl = asic1_subttl + '\n' + asic2_subttl if asic1_iv_data or asic2_iv_data: subttl += '\nbad pixels in black background. %i good pixels out of %i = %.1f%%' % ( ngood, npix, 100.0 * ngood / npix) subttl += '\nV$_\mathrm{turnover}$ from red to blue (%.1fV to %.1fV)' % ( lutmin, lutmax) fig.suptitle(subttl, fontsize=fontsize) for row in range(nrows): for col in range(ncols): TES = 0 ax[row, col].get_xaxis().set_visible(False) ax[row, col].get_yaxis().set_visible(False) # the pixel identity associated with its physical location in the array physpix = asic1_obj.pix_grid[row, col] pix_index = physpix - 1 face_colour = 'black' label_colour = 'white' text_y = 0.5 text_x = 0.5 if physpix == 0: pix_label = '' label_colour = 'black' face_colour = 'black' elif physpix in asic1_obj.TES2PIX[0]: TES = asic1_obj.pix2tes(physpix) TES_index = TES - 1 pix_label = str('%i' % TES) label_colour = 'yellow' face_colour = 'blue' curve_colour = 'black' fontsize = asic1_fontsize if asic1_iv_data: Iadjusted = asic1_obj.adjusted_iv(TES) turnover = asic1_obj.turnover(TES) text_x = max(asic1_obj.vbias) text_y = min(Iadjusted) if (asic1_obj.is_good_iv(TES) is not None) and (not asic1_obj.is_good_iv(TES)): face_colour = 'black' label_colour = 'white' curve_colour = 'white' else: face_colour = mylut(turnover, lutmin, lutmax) asic1_obj.draw_iv(Iadjusted, colour=curve_colour, axis=ax[row, col]) if asic1_timeline_data: face_colour = 'white' label_colour = 'black' tline = asic1_obj.timeline(timeline_index=timeline_index, TES=TES) ax[row, col].plot(tline, color=curve_colour) ax[row, col].set_xlim(tlim) # get min/max from timeline window negpeak = min(tline[tlim[0]:tlim[1]]) pospeak = max(tline[tlim[0]:tlim[1]]) ilim[0] = negpeak ilim[1] = pospeak text_x = tlim[1] text_y = ilim[0] ax[row, col].set_xlim(tlim) ax[row, col].set_ylim(ilim) elif asic1_mapdata: face_colour = mylut(a1[TES_index], lutmin, lutmax) elif physpix in asic2_obj.TES2PIX[1]: TES = asic2_obj.pix2tes(physpix) TES_index = TES - 1 pix_label = str('%i' % TES) label_colour = 'black' face_colour = 'green' curve_colour = 'blue' fontsize = asic2_fontsize if asic2_iv_data: Iadjusted = asic2_obj.adjusted_iv(TES) turnover = asic2_obj.turnover(TES) text_x = max(asic2_obj.vbias) text_y = min(Iadjusted) curve_colour = 'blue' if (asic2_obj.is_good_iv(TES) is not None) and (not asic2_obj.is_good_iv(TES)): face_colour = 'black' label_colour = 'white' curve_colour = 'white' else: face_colour = mylut(turnover, lutmin, lutmax) asic2_obj.draw_iv(Iadjusted, colour=curve_colour, axis=ax[row, col]) if asic2_timeline_data: face_colour = 'white' tline = asic2_obj.timeline(timeline_index=timeline_index, TES=TES) ax[row, col].plot(tline, color=curve_colour) ax[row, col].set_xlim(tlim) # get min/max from timeline window negpeak = min(tline[tlim[0]:tlim[1]]) pospeak = max(tline[tlim[0]:tlim[1]]) ilim[0] = negpeak ilim[1] = pospeak text_x = tlim[1] text_y = ilim[0] ax[row, col].set_xlim(tlim) ax[row, col].set_ylim(ilim) elif asic2_mapdata: face_colour = mylut(a2[TES_index], lutmin, lutmax) else: pix_label = '???' label_colour = 'blue' face_colour = 'yellow' ax[row, col].set_facecolor(face_colour) ax[row, col].text(text_x, text_y, pix_label, va='center', ha='center', color=label_colour, fontsize=fontsize) plt.savefig(pngname, format='png', dpi=100, bbox_inches='tight') if xwin: plt.show() else: plt.close('all') return
import os,sys jupyter=False if sys.argv[0].find('ipykernel')>=0:jupyter=True # make plots within the notebook if using jupyter notebook if jupyter: %matplotlib notebook import matplotlib.pyplot as plt from qubicpack import qubicpack as qp from qubicpack.temperature_analysis import * from qubicpack.plot_physical_layout import * # create the qubicpack object and read the data d0=qp() if jupyter: d0.figsize=9,5 # the first data file contains measurements at high temperature # these are used to correct the Normal Resistance d0.read_fits('QUBIC_timeline_20180301T184953UTC.fits') # The data contains multiple timelines at different temperatures # you can print out a summary table print_datlist(d0) # we will work with the first timeline which is at 601mK # (we set timeline_index=0) # first of all, have a look at all timelines for all the TES d0.plot_timeline_physical_layout(timeline_index=0)
def plot_histo_sig(Asic): AsicNum=Asic histo=np.empty(16) # create tab for peak to peak val data=np.empty((128,16)) # create a tab for each squid to keep all ptp value for each invdata=np.empty((16,128)) for i in range (16) : thedir = dirs[i] h = qp() h.read_qubicstudio_dataset(thedir, asic=AsicNum) for z in range (128): # Amplitude peak to peak of the sinus amp=h.max_bias-h.min_bias # offset of the sinus signal offset=0.5*(h.max_bias+h.min_bias) Vbias=(offset+amp*h.bias_phase()/2.) # Ind : this allow to avoid the noncoherent points in raw data for the flux ind=np.argsort(Vbias) # temp is a temporaly variable that will be used after for the filter if i == 0 : Vsqoffset=np.mean(h.timeline(TES=z+1)*62.5/(70.*100)/(h.nsamples-h.n_masked())) temp = h.timeline(TES=z+1)[ind]*62.5/(70.*100)/(h.nsamples-h.n_masked())-Vsqoffset # savitzky golay filter filt = sp.signal.savgol_filter(temp, 51, 3) histo[i] = np.max(filt) - np.min(filt) data[z,i]=histo[i] invdata[i,z]=histo[i] plt.plot(data) plt.grid() plt.ylabel("PtP value") plt.xlabel("Number of SQUID") save("./TEST/Analysis"+day+"/Results/ASIC%i_data_plot1"%AsicNum,ext="png",close=True,verbose=True) plt.plot(invdata[:,:]) plt.grid() plt.xlabel("Intensity (index of I)") plt.ylabel("SQUIDs") save("./TEST/Analysis"+day+"/Results/ASIC%i_data_plot2"%AsicNum,ext="png",close=True,verbose=True) # argmax take the position of the maxvalue for each squid plt.hist(np.argmax(data, axis=1), range=[0,16], bins=16) plt.grid() plt.ylabel("Number of SQUIDs") plt.xlabel("Index of current") plt.title("Histogram of the optimum current for the SQUID response for ASIC 1") save("./TEST/Analysis"+day+"/Results/ASIC%i_Histogram"%AsicNum,ext="png",close=True,verbose=True) plt.hist(data[:,9],range=[0,30], bins=30, alpha = 0.5, color= 'r' ,label="Isq = 25.5 µA") plt.hist(data[:,10],range=[0,30], bins=30, alpha = 0.5, color= 'b',label="Isq = 28 µA ") plt.hist(data[:,11],range=[0,30], bins=30, alpha = 0.5, color= 'g', label="Isq = 30.6 µA") plt.legend() plt.grid() plt.xlabel("Voltage ($\mu$V)") plt.xlim(0,25) plt.ylabel('Number of SQUID') plt.title("ASIC 1 histogram") save("./TEST/Analysis"+day+"/Results/ASIC%i_Histogram_multiindex"%AsicNum,ext="png",close=True,verbose=True) dat=np.empty(16) ind=np.empty(16) file = open("mean.txt", "w") for z in range (16): file.write("for index %i"%z) a=np.shape((np.where(data[:,z]>= 10))) prct=a[1]/128. *100 file.write("%f working squid" %prct) file.write("median = %f" %np.median(data[:,z])) file.write("\n") dat[z]= prct ind[z]= z file.close() plt.plot(ind,dat) plt.grid() plt.ylabel("Distribution of working SQUID >10µV ($\mu$V)") plt.xlabel('Index') plt.title("Working SQUID by index") save("./TEST/Analysis"+day+"/Results/ASIC%i_percentage"%AsicNum,ext="png",close=True,verbose=True)
def plot_physical_layout(xwin=True, figsize=(16, 16), a1=None, a2=None): ''' plot an image of the TES array labeling each pixel plot the I-V curves in the appropriate boxes if a1 and/or a2 given ''' obj_list = [a1, a2] asic1_obj = None asic2_obj = None for obj in obj_list: if isinstance(obj, qp): if obj.asic == 1: asic1_obj = obj elif obj.asic == 2: asic2_obj = obj else: print( 'PROBLEM! QubicPack object does not have a valid ASIC definition' ) return None if asic1_obj == None: asic1_obj = qp() asic1_obj.assign_asic(1) asic1_fontsize = figsize[0] if asic2_obj == None: asic2_obj = qp() asic2_obj.assign_asic(2) asic2_fontsize = figsize[0] asic1_data = True asic1_fontsize = 8 asic2_data = True asic2_fontsize = 8 if not isinstance(asic1_obj.adu, np.ndarray): asic1_data = False asic1_fontsize = figsize[0] if not isinstance(asic2_obj.adu, np.ndarray): asic2_data = False asic2_fontsize = figsize[0] asic1_obj.figsize = figsize fontsize = figsize[0] ttlfontsize = figsize[0] * 1.2 nrows = asic1_obj.pix_grid.shape[0] ncols = asic1_obj.pix_grid.shape[1] if xwin: plt.ion() else: plt.ioff() fig, ax = plt.subplots(nrows, ncols, figsize=asic1_obj.figsize) fig.text(0.5, 0.985, 'QUBIC TES array', ha='center', fontsize=ttlfontsize) pngname = 'TES_ARRAY.png' if xwin: fig.canvas.set_window_title('plt: QUBIC TES array') asic1_subttl = 'ASIC1 blue background' asic2_subttl = 'ASIC2 green background' ngood = 0 if asic1_data: asic1_subttl += asic1_obj.obsdate.strftime( ', data from %Y-%m-%d %H:%M') ngood += asic1_obj.ngood() if asic2_data: asic2_subttl += asic2_obj.obsdate.strftime( ', data from %Y-%m-%d %H:%M') ngood += asic2_obj.ngood() subttl = asic1_subttl + '\n' + asic2_subttl if asic1_data or asic2_data: subttl += '\nbad pixels in red background. %i good pixels.' % ngood fig.suptitle(subttl, fontsize=fontsize) for row in range(nrows): for col in range(ncols): TES = 0 ax[row, col].get_xaxis().set_visible(False) ax[row, col].get_yaxis().set_visible(False) #ax[row,col].set_xlim([0,1]) #ax[row,col].set_ylim([0,1]) # the pixel identity associated with its physical location in the array physpix = asic1_obj.pix_grid[row, col] pix_index = physpix - 1 text_y = 0.5 text_x = 0.5 if physpix == 0: pix_label = '' label_colour = 'black' face_colour = 'black' elif physpix in asic1_obj.TES2PIX[0]: TES = asic1_obj.pix2tes(physpix) pix_label = str('%i' % TES) label_colour = 'white' face_colour = 'blue' if asic1_data: fontsize = asic1_fontsize Iadjusted = asic1_obj.adjusted_iv(TES) text_x = max(asic1_obj.vbias) text_y = min(Iadjusted) asic1_obj.draw_iv(Iadjusted, colour='yellow', axis=ax[row, col]) if (not asic1_obj.is_good_iv(TES) == None) and (not asic1_obj.is_good_iv(TES)): face_colour = 'red' label_colour = 'white' elif physpix in asic2_obj.TES2PIX[1]: TES = asic2_obj.pix2tes(physpix) pix_label = str('%i' % TES) label_colour = 'white' face_colour = 'green' if asic2_data: fontsize = asic2_fontsize Iadjusted = asic2_obj.adjusted_iv(TES) text_x = max(asic1_obj.vbias) text_y = min(Iadjusted) asic2_obj.draw_iv(Iadjusted, colour='blue', axis=ax[row, col]) if (not asic2_obj.is_good_iv(TES) == None) and (not asic2_obj.is_good_iv(TES)): face_colour = 'red' label_colour = 'white' else: pix_label = '???' label_colour = 'blue' face_colour = 'yellow' ax[row, col].set_facecolor(face_colour) ax[row, col].text(text_x, text_y, pix_label, va='center', ha='center', color=label_colour, fontsize=fontsize) plt.savefig(pngname, format='png', dpi=100, bbox_inches='tight') if xwin: plt.show() else: plt.close('all') return
def plot_noise() : #################################################### ### variable declaration ### fmi=input("Enter frequence min value: ") fma=input("Enter frequence max value: ") fmin=int(fmi) fmax=int(fma) file = open("Noise.txt", "w") current_noise_test=np.zeros((2,16,128))#ASIC/index/TES Ibias=[] Noise_plot=[] ######################################################### ### loop for filling noise ### #selection courant et ASIC for i in range (2): AsicNum = i+1 for j in range (16): thedir = dirs[j] print(thedir) b = qp() b.read_qubicstudio_dataset(thedir, asic=AsicNum) #passe a travers tous les TES Rbias=b.Rbias Min=1./10.4E-6 for z in range (128): amp=b.max_bias-b.min_bias offset=0.5*(b.max_bias+b.min_bias) Vbias=(offset+amp*b.bias_phase()/2.) ind=np.argsort(Vbias) Vsqoffset=np.mean(b.timeline(TES=z+1)*62.5/(70.*100)/(b.nsamples-b.n_masked())) temp = b.timeline(TES=z+1)[ind]*62.5/(70.*100)/(b.nsamples-b.n_masked())-Vsqoffset filt = sp.signal.savgol_filter(temp, 51, 3) phi0=((Vbias[ind]/Rbias*Min)-(Vbias[ind]/Rbias*Min)[0])/2. #Bruit de lecture timeline_brut=b.timeline(TES=z+1) Timeline_volt=timeline_brut*62.5/(70.*100)/(b.nsamples-b.n_masked()) fs = 156.25 f, t, Sxx = scsig.spectrogram(Timeline_volt, fs,nperseg=2**10,window='hann') indf=(f>fmin) & (f<fmax) a=np.median(Sxx[indf,0]) val=np.sqrt(a) #Bruit du SQUID DeltaX=max(np.gradient(phi0)) slope_plot=(np.gradient(filt)/DeltaX) #slope=(max(slope_plot)) slope_filt = sp.signal.savgol_filter(slope_plot, 51, 3) slope=(max(slope_filt)) #plt.plot(slope_plot) phi0_Hz=(val*1e-6)/(slope*1e-6) A_Hz=phi0_Hz*0.2e-6 noise=A_Hz*1e12 Ibias.append(j) Noise_plot.append(noise) current_noise_test[i,j,z]= noise file.write("ASIC n° %i ... Index n° %i ... TES n° %i ... SQUID Noise = %d pA(Hz)^-1/2\n" %(i+1,j,z+1,noise)) file.close() #TES=127 for TES in range (128): plt.plot(current_noise_test[0,:,TES],label="ASIC 1",color="blue") plt.plot(current_noise_test[1,:,TES],label='ASIC 2',color="red") plt.legend() plt.title("Noise regarding of the Index number, TES : %i" %(TES+1)) plt.ylabel("Noise pA/(Hz)^1/2") plt.grid() save("./TEST/Analysis"+day+"/Noise"+day+"/Graph/Noise_Index_TES%i"%(TES+1),ext="png",close=True,verbose=True) #ind=4 for ind in range (16): plt.hist(current_noise_test[0,ind,:],bins=25,alpha=0.5,label="ASIC 1",color="blue") plt.hist(current_noise_test[1,ind,:],bins=25,alpha=0.5,label="ASIC 2",color="red") plt.grid() plt.legend() plt.title("Number of TES regarding the noise, index : %i" %(ind)) plt.xlabel("Noise pA/(Hz)^1/2") plt.ylabel("Number of TESs") save("./TEST/Analysis"+day+"/Noise"+day+"/Hist/TES_Noise_ind%i"%(ind),ext="png",close=True,verbose=True) ########################################### ###3D plot ### current_noise=np.zeros((2,16,128))#ASIC/TES/Index for i in range (2): current_noise[i,:,:]=i+1 for k in range (16): current_noise[:,k,:]=k for z in range (128): current_noise[:,:,z]=z+1 from mpl_toolkits import mplot3d fig = plt.figure() ax = plt.axes(projection='3d') # Data for a three-dimensional line zline = Noise_plot xline = current_noise yline = Ibias ax.scatter3D(yline, xline, zline,c=zline, cmap='jet') #ax.set_ylim(0,6) #ax.set_zlim(0,300) #ax.set_xlim(74.5,75.5) ax.set_ylabel('TES') ax.set_xlabel('Index') plt.xticks([0,2,4,6,8,10,12,14]) ax.set_zlabel('Noise') ax.set_title('Noise distribution for all TESs') save("./TEST/Analysis"+day+"Noise"+day+"/3D_data_plot",ext="png",close=True,verbose=True) ########################################################################### ### Noise Histogram ### z=0 #for ind in range (9): plt.hist(current_noise_test[z,9,:],bins=50,alpha=0.5,label="25.5 µA",color="red") plt.hist(current_noise_test[z,10,:],bins=50,alpha=0.5,label="28 µA",color="blue") plt.hist(current_noise_test[z,11,:],bins=50,alpha=0.5,label="30.6 µA",color="green") plt.grid() plt.legend() plt.title("ASIC %i" %(z+1)) plt.xlabel("Noise pA/(Hz)^1/2") plt.xlim(0,500) plt.ylabel("Number of TESs") save("./TEST/Analysis"+day+"Noise"+day+"/Noise_ASIC1",ext="png",close=True,verbose=True) z=1 #for ind in range (9): plt.hist(current_noise_test[z,10,:],bins=50,alpha=0.5,label="28 µA",color="red") plt.hist(current_noise_test[z,11,:],bins=50,alpha=0.5,label="30.6 µA",color="blue") plt.hist(current_noise_test[z,12,:],bins=50,alpha=0.5,label="33.2 µA",color="green") plt.grid() plt.legend() plt.title("ASIC %i" %(z+1)) plt.xlabel("Noise pA/(Hz)^1/2") plt.xlim(0,500) plt.ylabel("Number of TESs") save("./TEST/Analysis"+day+"Noise"+day+"/Noise_ASIC2",ext="png",close=True,verbose=True)
from copy import copy reload(sys) sys.setdefaultencoding('utf8') from satorchipy.datefunctions import * def read_bath_temperature(qpobject): qpobject.writelog('reading temperature') Tbath=qpobject.oxford_read_bath_temperature() if Tbath is None: qpobject.writelog('ERROR! Could not read bath temperature.') Tbath=qpobject.temperature qpobject.writelog('Tbath=%.2f mK' % (1000*Tbath)) return Tbath # create the qubicpack object go=qp() # set verbosity to 2 if you want lots of messages on the screen go.verbosity=2 # set TESTMODE to False for a real measurement (default) TESTMODE=False # default is to ask for parameters # command line arguments will suppress questions for the corresponding parameters asic=None detname=None meastype=None # Mon 22 Jan 2018 08:46:16 CET: we have removed the 5x bias factor go.max_permitted_bias=10.0 min_bias=None
def plot_Fiber_on_focalPlane(dataToPlot, tagd, xwin=True, figsize=(16, 16), color="black", pngname='TES_ARRAY.png'): ''' plot an image of the TES array labeling each pixel dataToPlot is an array[asic,pixel] ''' go = qp() go.figsize = figsize fontsize = figsize[0] ttlfontsize = fontsize * 1.2 ttl = 'QUBIC TES array\nASIC1 in blue. ASIC2 in green.' nrows = go.pix_grid.shape[0] ncols = go.pix_grid.shape[1] if xwin: plt.ion() else: plt.ioff() count_bad = 0 plt.rc('xtick', labelsize=9) # fontsize of the tick labels plt.rc('ytick', labelsize=9) # fontsize of the tick labels fig, ax = plt.subplots(nrows, ncols, figsize=go.figsize) if xwin: fig.canvas.set_window_title('plt: ' + ttl) fig.suptitle(ttl, fontsize=ttlfontsize) TES_translation_table_ASIC1 = go.TES2PIX[0] TES_translation_table_ASIC2 = go.TES2PIX[1] #WhichTranslat=TES_translation_table_ASIC1 #if self.asic == "2": # WhichTranslat=TES_translation_table_ASIC2 for row in range(nrows): for col in range(ncols): TES = 0 ax[row, col].get_xaxis().set_visible(False) ax[row, col].get_yaxis().set_visible(False) physpix = go.pix_grid[row, col] pix_index = physpix - 1 text_y = 0.5 text_x = 0.5 asic_of_pixel = -10 if physpix == 0: pix_label = '' label_colour = 'black' face_colour = 'black' elif physpix in TES_translation_table_ASIC1: go.assign_asic(1) asic_of_pixel = 1 TES = go.pix2tes(physpix) pix_label = str('%i' % TES) label_colour = 'white' face_colour = 'blue' elif physpix in TES_translation_table_ASIC2: asic_of_pixel = 2 go.assign_asic(2) TES = go.pix2tes(physpix) pix_label = str('%i' % TES) label_colour = 'white' face_colour = 'green' else: pix_label = '???' label_colour = 'blue' face_colour = 'yellow' current = ax[row, col] current.set_axis_bgcolor(face_colour) current.text(0.5, 0.5, pix_label, color="white", fontsize=9, ha='center', va='center', transform=current.transAxes, weight="bold") if pix_label != '???' and asic_of_pixel > 0: if tagd[asic_of_pixel - 1][int( pix_label ) - 1] == 1: # and (int(pix_label)-1 not in self.tes_blacklist): current.set_axis_bgcolor("red") current.text(0.5, 0.5, pix_label, color="black", fontsize=9, ha='center', va='center', transform=current.transAxes, weight="bold") count_bad += 1 alld = dataToPlot[asic_of_pixel - 1] d = alld[int(pix_label) - 1] d = d[2:] if numpy.size(d) != 0: mini = d.min() maxi = d.max() deltai = maxi - mini maxi = maxi + 15. * deltai / 100. mini = mini - 15. * deltai / 100. current.set_ylim([mini, maxi]) current.plot(d, color=color, linewidth=2.0) print 'count_bad', count_bad plt.savefig(pngname, format='png', dpi=100, bbox_inches='tight') if xwin: fig.show() plt.show() else: plt.close('all') return
# import necessary stuff import os,sys if sys.argv[0].find('ipykernel')>=0:jupyter=True if jupyter: %matplotlib notebook import matplotlib.pyplot as plt from qubicpack import qubicpack as qp from qubicpack.temperature_analysis import * from qubicpack.plot_physical_layout import * import datetime as dt # create the qubicpack object and read the data d0=qp() if jupyter:d0.figsize=10,5 result=d0.read_fits('QUBIC_timeline_20180301T142554UTC.fits') # The data contains multiple timelines at different temperatures # you can print out a summary table result=print_datlist(d0) # we will work with the third timeline. # (we set timeline_index=2) # first of all, have a look at all timelines for all the TES result=d0.plot_timeline_physical_layout(timeline_index=2) # let's look at one TES and also look at the power spectrum result=d0.plot_ASD(85,timeline_index=2)