def plot_timeline_focalplane(self): ''' plot all the timelines in the focal plane ''' args= {} args['title'] = 'QUBIC Focal Plane: %s' % self.dataset_name subttl_list = [] obsdates = [] for idx,asic_obj in enumerate(self.asic_list): if asic_obj is None: continue if not asic_obj.exist_timeline_data(): continue key = 'ASIC%i' % (idx+1) subttl_list.append(asic_obj.infotext()) args[key] = asic_obj.timeline_array() obsdates.append(asic_obj.obsdate) args['subtitle'] = '\n'.join(subttl_list) args['obsdate'] = min(obsdates) plot_fp(args) return args
def plot_iv_focalplane(self,labels=True): ''' plot all the I-V curves in the focal plane ''' args= {} args['title'] = 'QUBIC Focal Plane I-V curves: %s' % self.dataset_name if not labels: args['nolabels'] = True subttl_list = [] obsdates = [] ngood = [] tot_ngood = 0 tot_npixels = 0 for idx,asic_obj in enumerate(self.asic_list): if asic_obj is None: continue if not asic_obj.exist_iv_data(): continue obsdates.append(asic_obj.obsdate) key = 'ASIC%i' % (idx+1) subttl_list.append(asic_obj.infotext()) bias,adu = asic_obj.best_iv_curve() args[key] = adu keyx = '%s x-axis' % key args[keyx] = bias keygood = '%s good' % key args[keygood] = asic_obj.is_good_iv() keybg = '%s bg' % key args[keybg] = asic_obj.turnover() filtersummary = asic_obj.filterinfo() for idx,f in enumerate(filtersummary): if f['ignore_turnover']: args[keybg][idx] = None ngood = asic_obj.ngood() if ngood is not None: tot_ngood += ngood subttl_list.append('%i flagged as bad pixels : yield = %.1f%%' % (asic_obj.NPIXELS-ngood,100.0*ngood/asic_obj.NPIXELS)) tot_npixels += asic_obj.NPIXELS if tot_npixels>0: subttl_list.append('overall yield %i/%i = %.1f%%' % (tot_ngood,tot_npixels,100.0*tot_ngood/tot_npixels)) args['subtitle'] = '\n'.join(subttl_list) if len(obsdates)>0: args['obsdate'] = min(obsdates) plot_fp(args) return args
def plot_timeline_physical_layout(self, timeline_index=None, xwin=True, imin=None, imax=None, tmin=None, tmax=None, lutmin=None, lutmax=None): ''' plot the timeline curves in thumbnails mapped to the physical location of each detector ''' TES2PIX = assign_pix2tes(self.obsdate) if not self.exist_timeline_data(): return None ntimelines = self.ntimelines() if timeline_index is None: # by default, plot the first one. timeline_index = 0 if timeline_index >= ntimelines: self.printmsg('Please enter a timeline between 0 and %i' % (ntimelines - 1)) return None tdata = self.tdata[timeline_index] keys = tdata.keys() timeline_npts = tdata['TIMELINE'].shape[1] if lutmax is None: lutmax = tdata['TIMELINE'].max() - tdata['TIMELINE'].min() if lutmin is None: lutmin = 0.0 if 'DATE-OBS' in keys: timeline_date = tdata['DATE-OBS'] else: timeline_date = self.obsdate if 'BEG-OBS' in keys: timeline_start = tdata['BEG-OBS'] else: timeline_start = timeline_date ttl = str('QUBIC Timeline curves (%s)' % (timeline_start.strftime('%Y-%b-%d %H:%M UTC'))) if 'TES_TEMP' in keys: tempstr = '%.0f mK' % (1000 * tdata['TES_TEMP']) else: if self.temperature is None: tempstr = 'unknown' else: tempstr = str('%.0f mK' % (1000 * self.temperature)) subttl = str('Array %s, ASIC #%i, T$_\mathrm{bath}$=%s' % (self.detector_name, self.asic, tempstr)) # use the plot_fp algorithm to plot the focal plane asic_key = 'ASIC%i' % self.asic args = {} args['title'] = ttl args['subtitle'] = subttl pngname = str('QUBIC_Array-%s_ASIC%i_timeline_%s.png' % (self.detector_name, self.asic, timeline_start.strftime('%Y%m%dT%H%M%SUTC'))) pngname_fullpath = self.output_filename(pngname) args['pngname'] = pngname_fullpath # plot subsection of timeline tlim = [0, timeline_npts] if tmin is None: tlim[0] = 0 else: tlim[0] = tmin if tmax is None: tlim[1] = timeline_npts else: tlim[1] = tmax args[asic_key] = self.timeline_array( timeline_index=timeline_index)[:, tlim[0]:tlim[1]] plot_fp(args) return args
def plot_ASD_physical_layout(self, timeline_index=0, xwin=True, amin=None, amax=None, nbins=None): ''' plot the ASD for each TES in it's location in the focal plane ''' if not self.exist_timeline_data(): print('ERROR! No timeline data!') return None ntimelines = self.ntimelines() if timeline_index >= ntimelines: print( 'ERROR! timeline index out of range. Enter an index between 0 and %i' % (ntimelines - 1)) return None if nbins is None: nbins = 1 Tbath = self.tdata[timeline_index]['TES_TEMP'] obsdate = self.tdata[timeline_index]['BEG-OBS'] fs = 1.0 / self.sample_period() pngname = str( 'QUBIC_Array-%s_ASIC%i_ASD_%s.png' % (self.detector_name, self.asic, obsdate.strftime('%Y%m%dT%H%M%SUTC'))) pngname_fullpath = self.output_filename(pngname) ttl = 'Amplitude Spectral Density (%s)' % obsdate.strftime( '%Y-%m-%d %H:%M') subttl = '\nQUBIC Array %s, ASIC %i, T$_\mathrm{bath}$=%.1f mK' % ( self.detector_name, self.asic, 1000 * Tbath) timeline_npts = self.timeline_array(timeline_index=timeline_index).shape[1] psd_npts = timeline_npts // 2 if np.modf(0.5 * timeline_npts)[0] == 0.5: psd_npts += 1 freq_array = np.zeros((self.NPIXELS, psd_npts)) psd_array = np.zeros((self.NPIXELS, psd_npts)) for TES_idx in range(self.NPIXELS): TES = TES_idx + 1 timeline = self.timeline(TES, timeline_index) current = self.ADU2I(timeline) PSD, freqs = mlab.psd(current, Fs=fs, NFFT=timeline_npts // nbins, window=mlab.window_hanning, detrend='mean') ASD = np.sqrt(PSD) logASD = np.log10(ASD) logFreq = np.log10(freqs) psd_array[TES_idx, :] = logASD freq_array[TES_idx, :] = logFreq args = {} args['title'] = ttl args['subtitle'] = subttl args['obsdate'] = obsdate args['pngname'] = pngname_fullpath key = 'ASIC%i' % self.asic args[key] = psd_array args['%s x-axis'] = freq_array plot_fp(args) return args