示例#1
0
    def execute(self):
        """Execute pyraf task: gemcombine"""
        log.debug("GemcombineETI.execute()")

        # Populate object lists
        xcldict = copy(self.clparam_dict)
        for fil in self.file_objs:
            xcldict.update(fil.get_parameter())
        for par in self.param_objs:
            xcldict.update(par.get_parameter())
        iraf.unlearn(iraf.gemcombine)

        # Use setParam to list the parameters in the logfile 
        for par in xcldict:
            #Stderr and Stdout are not recognized by setParam
            if par != "Stderr" and par !="Stdout":
                gemini.gemcombine.setParam(par,xcldict[par])
        log.fullinfo("\nGEMCOMBINE PARAMETERS:\n")
        iraf.lpar(iraf.gemcombine, Stderr=xcldict["Stderr"], \
            Stdout=xcldict["Stdout"])

        # Execute the task using the same dict as setParam
        # (but this time with Stderr and Stdout)
        try:
            gemini.gemcombine(**xcldict)
        except:
            # catch hard crash of the primitive
            raise Errors.OutputError("The IRAF task gemcombine failed")
        if gemini.gemcombine.status:
            # catch graceful exit on error
            raise Errors.OutputError("The IRAF task gemcombine failed")
        else:
            log.fullinfo("The IRAF task gemcombine completed successfully")
示例#2
0
    def execute(self):
        """Execute pyraf task: gsappwave"""
        log.debug("GsappwaveETI.execute()")

        # Populate object lists
        xcldict = copy(self.clparam_dict)
        for fil in self.file_objs:
            xcldict.update(fil.get_parameter())
        for par in self.param_objs:
            xcldict.update(par.get_parameter())
        iraf.unlearn(iraf.gmos.gsappwave)

        # Use setParam to list the parameters in the logfile
        for par in xcldict:
            # Stderr and Stdout are not recognized by setParam
            if par != "Stderr" and par != "Stdout":
                gemini.gmos.gsappwave.setParam(par, xcldict[par])
        log.fullinfo("\nGSAPPWAVE PARAMETERS:\n")
        iraf.lpar(iraf.gmos.gsappwave, Stderr=xcldict["Stderr"], Stdout=xcldict["Stdout"])

        # Execute the task using the same dict as setParam
        # (but this time with Stderr and Stdout)
        # from pprint import pprint
        # pprint(xcldict)
        gemini.gmos.gsappwave(**xcldict)
        if gemini.gmos.gsappwave.status:
            raise Errors.OutputError("The IRAF task gmos.gsappwave failed")
        else:
            log.fullinfo("The IRAF task gmos.gsappwave completed successfully")
示例#3
0
    def execute(self):
        """Execute pyraf task: gmosaic"""
        log.debug("GmosaicETI.execute()")

        # Populate object lists
        xcldict = copy(self.clparam_dict)
        for fil in self.file_objs:
            xcldict.update(fil.get_parameter())
        for par in self.param_objs:
            xcldict.update(par.get_parameter())
        iraf.unlearn(iraf.gmos.gmosaic)

        # Use setParam to list the parameters in the logfile
        for par in xcldict:
            #Stderr and Stdout are not recognized by setParam
            if par != "Stderr" and par != "Stdout":
                gemini.gmos.gmosaic.setParam(par, xcldict[par])
        log.fullinfo("\nGMOSAIC PARAMETERS:\n")
        iraf.lpar(iraf.gmos.gmosaic, Stderr=xcldict["Stderr"], \
            Stdout=xcldict["Stdout"])

        # Execute the task using the same dict as setParam
        # (but this time with Stderr and Stdout)
        #from pprint import pprint
        #pprint(xcldict)
        try:
            gemini.gmos.gmosaic(**xcldict)
        except:
            # catch hard crash
            raise RuntimeError("The IRAF task gmos.gmosaic failed")
        if gemini.gmos.gmosaic.status:
            # catch graceful exit upon error
            raise RuntimeError("The IRAF task gmos.gmosaic failed")
        else:
            log.fullinfo("The IRAF task gmos.gmosaic completed successfully")
示例#4
0
    def execute(self):
        """Execute pyraf task: gmosaic"""
        log.debug("GmosaicETI.execute()")

        # Populate object lists
        xcldict = copy(self.clparam_dict)
        for fil in self.file_objs:
            xcldict.update(fil.get_parameter())
        for par in self.param_objs:
            xcldict.update(par.get_parameter())
        iraf.unlearn(iraf.gmos.gmosaic)

        # Use setParam to list the parameters in the logfile
        for par in xcldict:
            #Stderr and Stdout are not recognized by setParam
            if par != "Stderr" and par != "Stdout":
                gemini.gmos.gmosaic.setParam(par, xcldict[par])
        log.fullinfo("\nGMOSAIC PARAMETERS:\n")
        iraf.lpar(iraf.gmos.gmosaic, Stderr=xcldict["Stderr"], \
            Stdout=xcldict["Stdout"])

        # Execute the task using the same dict as setParam
        # (but this time with Stderr and Stdout)
        #from pprint import pprint
        #pprint(xcldict)
        try:
            gemini.gmos.gmosaic(**xcldict)
        except:
            # catch hard crash
            raise RuntimeError("The IRAF task gmos.gmosaic failed")
        if gemini.gmos.gmosaic.status:
            # catch graceful exit upon error
            raise RuntimeError("The IRAF task gmos.gmosaic failed")
        else:
            log.fullinfo("The IRAF task gmos.gmosaic completed successfully")
示例#5
0
文件: SCRIPT.py 项目: dafh/stuff
def wave_cal (images):
    iraf.dispcor.glo = 'no'
    iraf.dispcor.flux = 'yes'
    iraf.dispcor.input = '@'+ images
    iraf.dispcor.output = 'd//@' + images
    iraf.lpar(iraf.dispcor)
    iraf.dispcor(mode = 'h')
示例#6
0
    def execute(self):
        """Execute pyraf task: gscrrej"""
        log.debug("GscrrejETI.execute()")

        # This task can only work on one file at a time, so loop over
        # the infiles
        for i in range(len(self.file_objs)):

            # Get infile
            fil = self.file_objs[i]
            if isinstance(fil, InFile):
                # Get default parameters
                xcldict = copy(self.clparam_dict)
                for par in self.param_objs:
                    xcldict.update(par.get_parameter())
                iraf.unlearn(iraf.gscrrej)

                # Get outfile
                outfil = self.file_objs[i+1]

                # Set in/out file parameters
                xcldict.update(fil.get_parameter())
                xcldict.update(outfil.get_parameter())

                # Use setParam to list the parameters in the logfile 
                for par in xcldict:
                    #Stderr and Stdout are not recognized by setParam
                    if par != "Stderr" and par !="Stdout":
                        gemini.gscrrej.setParam(par,xcldict[par])
                log.fullinfo("\nGSCRREJ PARAMETERS:\n")
                iraf.lpar(iraf.gscrrej, Stderr=xcldict["Stderr"], \
                              Stdout=xcldict["Stdout"])

                # Execute the task using the same dict as setParam
                # (but this time with Stderr and Stdout) 
                gemini.gscrrej(**xcldict)
                if gemini.gscrrej.status:
                    raise Errors.OutputError("The IRAF task gscrrej failed")
                else:
                    log.fullinfo("The IRAF task gscrrej completed successfully")
            else:
                continue
示例#7
0
    def execute(self):
        """Execute pyraf task: splot"""
        log.debug("SplotETI.execute()")

        # Populate object lists
        xcldict = copy(self.clparam_dict)
        for fil in self.file_objs:
            xcldict.update(fil.get_parameter())
        for par in self.param_objs:
            xcldict.update(par.get_parameter())
        iraf.unlearn(iraf.splot)

        # Use setParam to list the parameters in the logfile 
        for par in xcldict:
            #Stderr and Stdout are not recognized by setParam
            if par != "Stderr" and par !="Stdout":
                iraf.splot.setParam(par,xcldict[par])
        log.fullinfo("\nSPLOT PARAMETERS:\n")
        iraf.lpar(iraf.splot, Stderr=xcldict["Stderr"], \
            Stdout=xcldict["Stdout"])

        # Execute the task using the same dict as setParam
        # (but this time with Stderr and Stdout) 
        iraf.splot(**xcldict)
示例#8
0
 def __init__(self, parfile):
     assert parfile.endswith(
         '.sim'), "Simulation input file must have extension .sim"
     try:
         c = yaml.load(open(parfile))
     except:
         c = parseconfig(parfile)
     self.c = c
     self.niter = c['NITER']
     self.n = c['NSTART']
     print c['SAVE']
     assert (c['SAVE'] and (c['NITER'] > 1)
             ) == False, "Error: You must use SAVE = no for NITER > 1"
     print "Simulation parameters from %s:" % (parfile)
     for k in c.keys():
         print "%-20s %s" % (k, c[k])
     self.detect_band = c['DETECTBAND']
     self.bands = c['BANDS']
     self.realimages = dict(zip(self.bands, c['REALIMAGE']))
     self.flagimages = dict(zip(self.bands, c['FLAGIMAGE']))
     self.rmsimages = dict(zip(self.bands, c['RMSIMAGE']))
     self.gains = dict(zip(self.bands, c['GAIN']))
     self.zeropoints = dict(zip(self.bands, c['MAGZPT']))
     self.psffiles = dict(zip(self.bands, c['PSFFILE']))
     self.detect_image = self.realimages[self.detect_band]
     self.fakeimages = {}
     self.segimages = {}
     self.catalogs = {}
     self.newcatalogs = {}
     self.noiselessimages = {}
     self.sextparfile = c['SEXTPARFILE']
     self.sexfile = c['SEXFILE']
     print "Artdata parameters:"
     iraf.lpar('artdata')
     self.root = os.path.splitext(parfile)[0]  # e.g. root = "run1m"
     hdr = pyfits.getheader(self.detect_image)
     self.xmax = hdr['naxis1']
     self.ymax = hdr['naxis2']
     self.logrmin = np.log10(c['RMIN'] / c['SCALE'])  # in pixels
     self.logrmax = np.log10(c['RMAX'] / c['SCALE'])
     self.pixscale = c['SCALE']
     self.rdistfunc = c['RADIUS_DISTRIBUTION']
     self.lognormal_mag0 = c['LOGNORMAL_MAG0']
     self.lognormal_peak = c['LOGNORMAL_PEAK']
     self.lognormal_sigma = c['LOGNORMAL_SIGMA']
     self.lognormal_beta = c['LOGNORMAL_BETA']
     self.diskfrac = c['DISKFRAC']
     self.ngal = c['NGALAXIES']
     self.maglow = c['MAGLOW']
     self.maghigh = c['MAGHIGH']
     self.flagmax = c['FLAGMAX']
     self.save = c['SAVE']
     for b in self.bands:
         broot = self.root + '_' + b
         if not os.path.exists(broot):
             # create output directory if needed
             os.mkdir(broot)
     # Create list of input galaxies in the detect band directory
     igalfile = "%s_%s/%s.allgal" % (self.root, self.detect_band, self.root)
     igfile = open(igalfile, 'a')
     igfile.write("# %s \n" % (time.ctime()))
     igfile.write("# %s \n" % (version))
     igfile.close()
     self._finished_sextractor = False
示例#9
0
 def __init__(self, parfile):
    assert parfile.endswith('.sim'), "Simulation input file must have extension .sim"
    c = yaml.load(open(parfile))
    self.c = c
    self.start = c['NSTART']
    self.nstop = c['NSTOP']
    self.n = c['NSTART']
    assert (c['SAVE'] and (c['NSTOP'] > 1))==False, "Error: You must use SAVE = no for NSTOP > 1"
    print "Simulation parameters from %s:" % (parfile)
    for k in c.keys():
       print "%-20s %s" % (k, c[k])
    self.detect_band = c['DETECTBAND']
    self.bands = c['BANDS']
    self.realimages = dict(zip(self.bands, c['REALIMAGE']))
    self.flagimages = dict(zip(self.bands, c['FLAGIMAGE']))
    self.rmsimages = dict(zip(self.bands, c['RMSIMAGE']))
    try:
       self.wht_type = c['WEIGHT_TYPE']
    except:
       self.wht_type = 'MAP_RMS'
    self.gains = dict(zip(self.bands, c['GAIN']))
    self.zeropoints = dict(zip(self.bands, c['MAGZPT']))
    self.psffiles = dict(zip(self.bands, c['PSFFILE']))
    self.detect_image = self.realimages[self.detect_band]
    self.fakeimages = {}
    self.segimages = {}
    self.catalogs = {}
    self.newcatalogs = {}
    self.noiselessimages = {}
    self.sextparfile = c['SEXTPARFILE']
    self.sexfile = c['SEXFILE']
    # Can take PSF-matching kernels... but require that they are specified
    # as dictionaries in the parameter file, to avoid confusion
    if 'PSFMATCH' not in c.keys():
       self.psfmatch = False
    else:
       self.psfmatch = c['PSFMATCH']
    if self.psfmatch:
       self.psfmatch_kernels = c['PSFMATCH_KERNELS']
    print "Artdata parameters:"
    iraf.lpar('artdata')
    self.root = os.path.splitext(parfile)[0]   # e.g. root = "run1m"
    hdr = pyfits.getheader(self.detect_image)
    self.xmax = hdr['naxis1']
    self.ymax = hdr['naxis2']
    # put in this try/except clause so that TPHOT sims will work...
    try:
       self.logrmin = np.log10(c['RMIN'] / c['SCALE'])  # in pixels
       self.logrmax = np.log10(c['RMAX'] / c['SCALE'])
       self.pixscale = c['SCALE']
    except:
       self.logrmin = np.log10(c['RMIN'] / c['SCALE'][0])
       self.logrmax = np.log10(c['RMAX'] / c['SCALE'][0])
       self.pixscale = c['SCALE'][0]
    self.rdistfunc = c['RADIUS_DISTRIBUTION']
    self.lognormal_mag0 = c['LOGNORMAL_MAG0']
    self.lognormal_peak = c['LOGNORMAL_PEAK']
    self.lognormal_sigma = c['LOGNORMAL_SIGMA']
    self.lognormal_beta = c['LOGNORMAL_BETA']
    self.diskfrac = c['DISKFRAC']
    self.ngal = c['NGALAXIES']
    self.maglow = c['MAGLOW']
    self.maghigh = c['MAGHIGH']
    self.flagmax = c['FLAGMAX']
    self.save = c['SAVE']
    if c.has_key('OTHERCOLNAMES'):
       self.othercolnames = c['OTHERCOLNAMES']
    else:
       self.othercolnames = []
    if c.has_key('MAGFILE'):
       self.magfile = c['MAGFILE']
    else:
       self.magfile = None
    for b in self.bands:
       broot = self.root+'_'+b
       if not os.path.exists(broot):  
          # create output directory if needed
          os.mkdir(broot)
    # Create list of input galaxies in the detect band directory
    igalfile = "%s_%s/%s.allgal" % (self.root, self.detect_band, self.root)
    igfile = open(igalfile, 'a')
    igfile.write("# %s \n" % (time.ctime()))
    igfile.write("# %s \n" % (version))
    igfile.close()
    self._finished_sextractor = False
    # Fake galaxies...
    fg_args = [self.realimages, self.flagimages, self.bands]
    fg_kwargs = dict(ngal=self.ngal, diskfrac=self.diskfrac, 
                magfile=self.magfile, rdist=self.rdistfunc, mag0=self.maglow,
                mag1=self.maghigh, logr0=self.logrmin, logr1=self.logrmax, 
                lognormal_beta=self.lognormal_beta, 
                lognormal_mag0=self.lognormal_mag0, 
                lognormal_peak=self.lognormal_peak,
                lognormal_sigma=self.lognormal_sigma, 
                flagmax=self.flagmax,
                othercols_list=self.othercolnames)
    self.fg = fake_galaxies.fake_galaxies(*fg_args, **fg_kwargs)