def alignToMaster(self): refList = 'master.lis' for ii in range(len(self.images)): alignRoot = self.alignDir + 'master_' + str(ii) alignRoot += '_' + self.fields[ii] alignRootBoot = self.alignDir + 'master_boot_' + str(ii) alignRootBoot += '_' + self.fields[ii] starList = self.images[ii] + '_rms_dist.lis' print '*** Aligning to master:' print '*** Working on %s ***' % starList print # ========== # Re-order refList to shift common source to the top. # ========== newRefList = self.lisDir + 'master_%d_%s' % (ii, refList) # Always the same ref list, but with # different stars at the top newStarList = self.lisDir + 'nirc2_%d_%s' % (ii, starList) # Ref List shiftToTopOfList(self.lisDir + refList, newRefList, self.refStars[self.fields[ii]]) # Star List shiftToTopOfList(self.lisDir + starList, newStarList, self.refStars[self.fields[ii]]) # Get the align data type fitsFile = self.dataDir + '../%s.fits' % (self.images[ii]) alignType = dataUtil.get_align_type(fitsFile, errors=True) # Get the angle posAngle = dataUtil.get_pos_angle(fitsFile) if posAngle != 0 and self.alignOrder == 0: print 'You must allow for rotation with alignOrder > 0' # ========== # Align # ========== _list = open(alignRoot + '.list', 'w') _list.write('%s %d ref\n' % (newRefList, alignType)) _list.write('%s %d\n' % (newStarList, alignType)) _list.close() print '\n*** Aligning %s ***' % starList cmd = 'java align -v -p -a %d -r %s %s.list' % (self.alignOrder, alignRoot, alignRoot) os.system(cmd) # Bootstrap print '\n*** Aligning %s (bootstrap) ***' % starList ntrials = 100 cmd = 'java align -v -p -a %d -n %d -r %s %s.list' % \ (self.alignOrder, ntrials, alignRootBoot, alignRoot) os.system(cmd)
def alignToMakeMaster(self): """ Loop through and align the images to the master list that is slowly being built up. Include the alignment of central to central field in order to include the distortion error in that image and to include those positions when computing the average """ # Define a running variable that contains the refList. This # will be updated after each loop. refList = self.firstRefList for ii in range(0, len(self.images)): alignRoot = self.alignDir + 'align_' alignRoot += str(ii) + '_' + self.fields[ii] alignRootBoot = self.alignDir + 'align_boot_' alignRootBoot += str(ii) + '_' + self.fields[ii] starList = self.images[ii] + '_rms_dist.lis' # ========== # Re-order refList to shift common source to the top. # ========== newRefList = self.lisDir + 'ref_%d_%s' % (ii, refList) newStarList = self.lisDir + 'nirc2_%d_%s' % (ii, starList) # Ref List shiftToTopOfList(self.lisDir + refList, newRefList, self.refStars[self.fields[ii]]) # Star List shiftToTopOfList(self.lisDir + starList, newStarList, self.refStars[self.fields[ii]]) # Get the align data type fitsFile = self.dataDir + '../%s.fits' % (self.images[ii]) alignType = dataUtil.get_align_type(fitsFile, errors=True) # Get the angle posAngle = dataUtil.get_pos_angle(fitsFile) if posAngle != 0 and self.alignOrder == 0: print 'You must allow for rotation with alignOrder > 0' # ========== # Align # ========== _list = open(alignRoot + '.list', 'w') _list.write('%s %s ref\n' % (newRefList, alignType)) _list.write('%s %d\n' % (newStarList, alignType)) _list.close() print '\n*** Aligning %s ***' % starList cmd = 'java align -v -p -a %d -r %s %s.list' % (self.alignOrder, alignRoot, alignRoot) os.system(cmd) # Bootstrap print '\n*** Aligning %s (bootstrap) ***' % starList ntrials = 100 cmd = 'java align -v -p -a %d -n %d -r %s %s.list' % \ (self.alignOrder, ntrials, alignRootBoot, alignRoot) os.system(cmd) # ========== # Make a new reference list out of the previous align results # This builds up a list after each alignment # ========== refList = 'aligned_%d_%s' % (ii, starList) starPrefix = 'ep%d' % ii makeNewRefList(alignRootBoot, self.lisDir + refList, starPrefix=starPrefix) shutil.copyfile(self.lisDir + refList, self.lisDir + 'master.lis')