Beispiel #1
0
    def alignClean(self):
        try:
            os.chdir(self.dirClean)

            # Get the align data type
            fitsFile = self.cleanFiles[0] + '.fits'
            alignType = nirc2_util.get_align_type(fitsFile, errors=False)
            alignCombo = alignType + 1

            # Make the align*.list file
            os.chdir(self.dirCleanAln)
            alnList = 'align_%s%s_%3.1f.list' % (self.imgSuffix, self.filt, self.corrClean)
            _list = open(alnList, 'w')

            # copy main map into it
            _list.write('%smag%s%s_%s_rms.lis %d ref\n' % 
                        (self.dirComboStf, self.epoch, self.imgSuffix, self.filt, alignCombo))
            # Add each clean file
            for ff in self.cleanFiles:
                _list.write('../%s_%3.1f_stf_cal.lis %d\n' %
                            (ff, self.corrClean, alignType))
            _list.close()

            # Run align
            cmd = 'java -Xmx1024m align %s ' % (self.alignFlags)
            cmd += '-N %s ' % self.labellist
            if (self.orbitlist != None) and (self.orbitlist != ''):
                cmd += '-o %s ' % self.orbitlist
            cmd += '-r align_%s%s_%3.1f_named ' % (self.imgSuffix, self.filt, self.corrClean)
            cmd += alnList

            #os.system(cmd)
            subp = subprocess.Popen(cmd, shell=True, executable="/bin/tcsh")
            tmp = subp.communicate()


            # Copy over the label.dat file that was used.
            shutil.copyfile(self.labellist,
                            'align_%s%s_%3.1f_named_label_list.txt' % 
                            (self.imgSuffix, self.filt, self.corrClean))
            if (self.orbitlist != None) and (self.orbitlist != ''):
                shutil.copyfile(self.orbitlist,
                                'align_%s%s_%3.1f_named_orbit_list.txt' % 
                                (self.imgSuffix, self.filt, self.corrClean))
                            
            os.chdir(self.dirStart)
        except:
            os.chdir(self.dirStart)
            raise
Beispiel #2
0
    def alignCombo(self):
        print 'ALIGN_RMS combo'

        if self.type == 'ao':
            file_ext = '_' + self.filt
        else:
            file_ext = self.filt

        try:
            os.chdir(self.dirCombo)
            # Get the align data type
            if self.type == 'ao':
                fitsFile = 'mag%s%s_%s.fits' % (self.epoch, self.imgSuffix, self.filt)
            elif self.type == 'speckle':
                fitsFile = 'mag%s.fits' % self.epoch
            alignType = nirc2_util.get_align_type(fitsFile, errors=False)


            os.chdir(self.dirComboAln)

            # Put the files in to the align*.list file
            alnList1 = 'align%s%s_%3.1f.list' % (self.imgSuffix, file_ext, self.corrMain)
            alnList2 = 'align%s%s_%3.1f_named.list' % (self.imgSuffix, file_ext, self.corrMain)


            _list = open(alnList1, 'w')
            if self.deblend == 1:
                _list.write('../mag%s%s%s_%3.1fd_stf_cal.lis %d ref\n' %
                            (self.epoch, self.imgSuffix, file_ext, self.corrMain, alignType))
            else:
                _list.write('../mag%s%s%s_%3.1f_stf_cal.lis %d ref\n' %
                            (self.epoch, self.imgSuffix, file_ext, self.corrMain, alignType))
            for ss in range(self.numSubMaps):
                if self.deblend == 1:
                    _list.write('../m%s%s%s_%d_%3.1fd_stf_cal.lis %d\n' %
                                (self.epoch, self.imgSuffix, file_ext, ss+1, self.corrSub, alignType))
                else:
                    _list.write('../m%s%s%s_%d_%3.1f_stf_cal.lis %d\n' %
                                (self.epoch, self.imgSuffix, file_ext, ss+1, self.corrSub, alignType))

                    
            _list.close()

            shutil.copyfile(alnList1, alnList2)

            # Make an unlabeled version
            cmd = 'java -Xmx1024m align %s ' % (self.alignFlags)
            cmd += '-r align%s%s_%3.1f ' % (self.imgSuffix, file_ext, self.corrMain)
            cmd += alnList1
            print cmd
            #os.system(cmd)
            subp = subprocess.Popen(cmd, shell=True, executable="/bin/tcsh")
            tmp = subp.communicate()

            # Make a named/labeled version
            cmd = 'java -Xmx1024m align %s ' % (self.alignFlags)
            cmd += '-N %s ' % self.labellist
            if (self.orbitlist != None) and (self.orbitlist != ''):
                cmd += '-o %s ' % self.orbitlist
            cmd += '-r align%s%s_%3.1f_named ' % (self.imgSuffix, file_ext, self.corrMain)
            cmd += alnList2
            print cmd

            subp = subprocess.Popen(cmd, shell=True, executable="/bin/tcsh")
            tmp = subp.communicate()


            align_options = 'align%s%s_%3.1f %d -e' % \
              (self.imgSuffix, file_ext, self.corrMain, self.minSubMaps)
            align_rms.run(align_options.split())

            align_options = 'align%s%s_%3.1f_named %d -e' % \
              (self.imgSuffix, file_ext, self.corrMain, self.minSubMaps)
            align_rms.run(align_options.split())


            # Move the resulting files to their final resting place
            os.rename('align%s%s_%3.1f_rms.lis' % 
                      (self.imgSuffix, file_ext, self.corrMain),
                      '../mag%s%s%s_rms.lis' % 
                      (self.epoch, self.imgSuffix, file_ext))
            os.rename('align%s%s_%3.1f_named_rms.lis' % 
                      (self.imgSuffix, file_ext, self.corrMain),
                      '../mag%s%s%s_rms_named.lis' % 
                      (self.epoch, self.imgSuffix, file_ext))

            # Copy over the label.dat and orbit.dat file that was used.
            shutil.copyfile(self.labellist,
                            'align%s%s_%3.1f_named_label_list.txt' % 
                            (self.imgSuffix, file_ext, self.corrMain))
                            
            if (self.orbitlist != None) and (self.orbitlist != ''):
                shutil.copyfile(self.orbitlist,
                                'align%s%s_%3.1f_named_orbit_list.txt' % 
                                (self.imgSuffix, file_ext, self.corrMain))

            # Now plot up the results
            plotSuffix = self.imgSuffix + file_ext
            os.chdir(self.dirComboStf)
            plotPosError('mag%s%s%s_rms.lis' % (self.epoch, self.imgSuffix, file_ext),
                         raw=True, suffix=plotSuffix, magCutOff=self.plotPosMagCut)

            os.chdir(self.dirStart)
        except:
            os.chdir(self.dirStart)
            raise