def reset( self, chipReaderType=None ): if self.chipReaderType is not None: JChip.StopListener() RaceResult.StopListener() Ultra.StopListener() self.chipReaderType = (chipReaderType or ChipReader.JChip) if self.chipReaderType == ChipReader.RaceResult: self.StartListener = RaceResult.StartListener self.GetData = RaceResult.GetData self.StopListener = RaceResult.StopListener self.CleanupListener = RaceResult.CleanupListener self.IsListening = RaceResult.IsListening elif self.chipReaderType == ChipReader.Ultra: self.StartListener = Ultra.StartListener self.GetData = Ultra.GetData self.StopListener = Ultra.StopListener self.CleanupListener = Ultra.CleanupListener self.IsListening = Ultra.IsListening else: # self.chipReaderType == ChipReader.JChip: self.StartListener = JChip.StartListener self.GetData = JChip.GetData self.StopListener = JChip.StopListener self.CleanupListener = JChip.CleanupListener self.IsListening = JChip.IsListening
else: print('Run = ' + rdir + ' does not have the form YYYY-MM') exit(1) if os.path.exists(edir) and not os.path.isdir(edir): print(edir,'exists but is not a directory; please fix.') exit(1) elif not os.path.exists(edir): os.makedirs(edir) print('Created directory =',edir) # get a list of night-by-night directories ndirs = [d for d in os.listdir(rundir) if os.path.isdir(os.path.join(rundir, d))] ndirs.sort() runs = Ultra.load_runs(rdir) print('Read',len(runs),'runs.') # look for all runs which match the supplied identifier matches = {} for i,run in enumerate(runs): if run.pid is None or idtest.match(run.pid): matches[run.night + ('%03d' % run.number)] = i science = dict(matches) # look for all calibrations that match the runs located for key,value in science.items(): rdat = runs[value] for i,rcal in enumerate(runs):
# combine the files print '.... combining the frames' ofile = os.path.join(cwd, 'derived_data', bias) args = (combine, 'list=' + ldisk, 'method=c', 'sigma=2.8', 'careful=yes', 'adjust=b', 'output=' + ofile, 'nodefs') output = subprocess.Popen(args, stdout=subprocess.PIPE, cwd='/tmp', stderr=subprocess.PIPE).communicate()[0].split('\n') print '.... combined file written to',ofile+'.ucm' if len(output) < 3 or output[-3] != 'Finished.': print 'ERROR: "combine" failed with output:' print '\n'.join(output) exit(1) # compute some stats to add to file print '.... computing some stats to store in file -- this can take a while.' lmin,lmax,lmm,lrm,lgrad,rmin,rmax,rmm,rrm,rgrad = Ultra.flist_stats([os.path.join('/tmp',fname) for fname in flist], 2, 2, 3.) modf = ucm.rucm(ofile + '.ucm') modf['Procbias'] = {'comment': 'procbias information', 'type' : ucm.ITYPE_DIR, 'value': None} modf['Procbias.nframe'] = {'comment': 'number of contributing frames', 'type' : ucm.ITYPE_INT, 'value': len(flist)} modf['Procbias.first'] = {'comment': 'first contributing frame', 'type' : ucm.ITYPE_INT, 'value': first} modf['Procbias.last'] = {'comment': 'last contributing frame', 'type' : ucm.ITYPE_INT, 'value': last} modf['Procbias.lmid'] = {'comment': 'mid-ranges of mean values of left-hand sides of CCDs', 'type' : ucm.ITYPE_FVECTOR, 'value': (lmin+lmax)/2.} modf['Procbias.lmean'] = {'comment': 'means of mean values of left-hand sides of CCDs', 'type' : ucm.ITYPE_FVECTOR, 'value': lmm} modf['Procbias.lrng'] = {'comment': 'ranges of mean values of left-hand sides of CCDs', 'type' : ucm.ITYPE_FVECTOR, 'value': lmax-lmin} modf['Procbias.lrms'] = {'comment': 'means of RMSs of left-hand sides of CCDs', 'type' : ucm.ITYPE_FVECTOR, 'value': lrm} modf['Procbias.lgrad'] = {'comment': 'gradients of means of left-hand sides of CCDs (counts/frame)', 'type' : ucm.ITYPE_FVECTOR, 'value': lgrad} modf['Procbias.rmid'] = {'comment': 'mid-ranges of mean values of right-hand sides of CCDs', 'type' : ucm.ITYPE_FVECTOR, 'value': (rmin+rmax)/2.} modf['Procbias.rmean'] = {'comment': 'means of mean values of right-hand sides of CCDs', 'type' : ucm.ITYPE_FVECTOR, 'value': rmm} modf['Procbias.rrng'] = {'comment': 'ranges of mean values of right-hand sides of CCDs', 'type' : ucm.ITYPE_FVECTOR, 'value': rmax-rmin} modf['Procbias.rrms'] = {'comment': 'means of RMSs of right-hand sides of CCDs', 'type' : ucm.ITYPE_FVECTOR, 'value': rrm} modf['Procbias.rgrad'] = {'comment': 'gradients of means of right-hand sides of CCDs (counts/frame)', 'type' : ucm.ITYPE_FVECTOR, 'value': rgrad}