Пример #1
0
def photdump(files, output):
    '''dump photometric information in the given list of 
    photometry files into output

    output can be either a file-like object open for writing, or a string, 
    if it is a string it is the path to a file, which is then opened in 'w'
    mode. 

    photdump returns the (still open) file object when done.
    
    it dumpst the following fields in the given order:

    id
    ifilter
    otime (observation time)
    magnitude
    airmass
    '''
    irafmod.check_init("can't dump")
    iraf = irafmod.iraf
    if isinstance(output, str):
        output = open(output, 'w')
    for pfile in files:
        iraf.pdump(pfile, FIELD_STR, iraf.yes, Stdout=output)
    return output
Пример #2
0
def sortphotfiles(folder, suffix=".nst.1"):
    '''sort all of the phot files in \p folder
    by id. They must end in \p suffix, which defaults to
    .nst.1'''
    irafmod.check_init("can't sort")
    irafmod.iraf.psort(os.path.join(folder, "*" + suffix), 'id')
    return
Пример #3
0
def phot(imageName,
         output_dir,
         coordFile,
         target_coords=None,
         sample_size=100,
         params=None,
         observat=observatories.default,
         **kwargs):
    '''perform daophot on imageName with the supplied
    coordinate file, and optionally the target coordinates, which
    defaults to the first coordinates in coordFile

    sample_size is the size of the sample box used for background measurement
    kwargs are additional args to pass to constructor for params (or update params)'''

    #first ensure that irafmod has been initialized
    irafmod.check_init("unable to phot")
    daophot = irafmod.iraf.daophot

    #first get the paramaters we need
    if not params:
        params = getDAOParams(observat,
                              imageName,
                              coordFile,
                              target_coords,
                              size=sample_size)
    params.update(kwargs)
    params.applyParams()

    with workingDirectory(output_dir):
        #temporarily change working directory

        logger.debug("in working directory: " + os.getcwd())
        logger.debug("Setting HJD")
        irafmod.iraf.setjd(imageName)
        logger.debug("starting phot")
        daophot.phot(imageName, coordFile, "default")
        logger.debug("starting pstselect")
        #params:  image, photfile, pstfile, maxnpsf
        daophot.pstselect(imageName, "default", "default", 25)
        #params: imagename photfile pstfile psfimage opstfile groupfile
        daophot.psf(imageName,
                    "default",
                    "default",
                    "default",
                    "default",
                    "default",
                    interactive=irafmod.no)
        #TODO should we be more sophisticated and do multiple runs of psf
        #along with using nstar and substar to try and get best fit?

        #use nstar for now, but we will make it a seperate function
        #so it is easy to switch out with peak or allstar
        #if we desire later
        do_nstar(imageName)
Пример #4
0
def photdump_all(globber, output):
    '''similar to photdump, except that instead 
    of a list of files, it takes a string, which is a
    glob expression for the files to use, 
    ex. *.nst.1'''
    irafmod.check_init("can't dump")
    iraf = irafmod.iraf
    if isinstance(output, str):
        output = open(output, 'w')
    iraf.pdump(globber, FIELD_STR, iraf.yes, Stdout=output)
    return output
Пример #5
0
    def applyParams(self):
        '''apply paramaters for daophot'''
        irafmod.check_init("DAO_params.applyParams")
        iraf = irafmod.iraf

        #photpars
        iraf.photpars.aperture = self.aperture
        iraf.photpars.zmag = self['zmag']
        #set world coordinates as input for phot
        iraf.phot.wcsin = "world"
        #datapars
        iraf.datapars.fwhmpsf = self['fwhm']
        iraf.datapars.sigma = self.get('sigma', 0)
        iraf.datapars.datamax = self.datamax
        iraf.datapars.datamin = self.datamin
        iraf.datapars.obstime = self['otime']
        iraf.datapars.exposure = self['exposure']
        iraf.datapars.airmass = self['airmass']
        iraf.datapars.filter = self['filter']
        #centerpars
        iraf.centerpars.cbox = self.cbox
        iraf.centerpars.calgorithm = self.get('calgorithm', 'centroid')
        #fitskypars
        iraf.fitskypars.annulus = self.annulus
        iraf.fitskypars.dannulus = self.dannulus
        iraf.fitskypars.salgorithm = self.get('salgorithm', 'mode')
        #daopars
        iraf.daopars.psfrad = 4.0 * self['fwhm'] + 1.0
        iraf.daopars.fitrad = self.aperture
        #psfpars
        iraf.psf.function = self['fitfunction']
        #make sure we are using default logical coordinate system
        #for everything except the phot command
        iraf.daophot.wcsin = "logical"
        iraf.daophot.wcsout = "logical"
        iraf.daophot.verify = iraf.no
        # setjd paramaters
        iraf.observatory.observatory = self['observat']
        iraf.setjd.date = self['obsdate']
        iraf.setjd.time = self['obstime']
        iraf.setjd.observatory = self['observat']
        iraf.setjd.exposur = self['exposure']
        iraf.setjd.epoch = self['epoch']
        iraf.setjd.ra = self['ra_key']
        iraf.setjd.dec = self['dec_key']
Пример #6
0
    def applyParams(self):
        """apply paramaters for daophot"""
        irafmod.check_init("DAO_params.applyParams")
        iraf = irafmod.iraf

        # photpars
        iraf.photpars.aperture = self.aperture
        iraf.photpars.zmag = self["zmag"]
        # set world coordinates as input for phot
        iraf.phot.wcsin = "world"
        # datapars
        iraf.datapars.fwhmpsf = self["fwhm"]
        iraf.datapars.sigma = self.get("sigma", 0)
        iraf.datapars.datamax = self.datamax
        iraf.datapars.datamin = self.datamin
        iraf.datapars.obstime = self["otime"]
        iraf.datapars.exposure = self["exposure"]
        iraf.datapars.airmass = self["airmass"]
        iraf.datapars.filter = self["filter"]
        # centerpars
        iraf.centerpars.cbox = self.cbox
        iraf.centerpars.calgorithm = self.get("calgorithm", "centroid")
        # fitskypars
        iraf.fitskypars.annulus = self.annulus
        iraf.fitskypars.dannulus = self.dannulus
        iraf.fitskypars.salgorithm = self.get("salgorithm", "mode")
        # daopars
        iraf.daopars.psfrad = 4.0 * self["fwhm"] + 1.0
        iraf.daopars.fitrad = self.aperture
        # psfpars
        iraf.psf.function = self["fitfunction"]
        # make sure we are using default logical coordinate system
        # for everything except the phot command
        iraf.daophot.wcsin = "logical"
        iraf.daophot.wcsout = "logical"
        iraf.daophot.verify = iraf.no
        # setjd paramaters
        iraf.observatory.observatory = self["observat"]
        iraf.setjd.date = self["obsdate"]
        iraf.setjd.time = self["obstime"]
        iraf.setjd.observatory = self["observat"]
        iraf.setjd.exposur = self["exposure"]
        iraf.setjd.epoch = self["epoch"]
        iraf.setjd.ra = self["ra_key"]
        iraf.setjd.dec = self["dec_key"]
Пример #7
0
def phot(imageName, output_dir,coordFile, target_coords=None,
    sample_size=100,params=None,observat=observatories.default,**kwargs):
    '''perform daophot on imageName with the supplied
    coordinate file, and optionally the target coordinates, which
    defaults to the first coordinates in coordFile

    sample_size is the size of the sample box used for background measurement
    kwargs are additional args to pass to constructor for params (or update params)'''

    #first ensure that irafmod has been initialized
    irafmod.check_init("unable to phot")
    daophot = irafmod.iraf.daophot

    #first get the paramaters we need
    if not params:
        params = getDAOParams(observat,imageName, coordFile, 
            target_coords, size=sample_size)
    params.update(kwargs)
    params.applyParams()

    with workingDirectory(output_dir):
        #temporarily change working directory

        logger.debug("in working directory: "+os.getcwd())
        logger.debug("Setting HJD")
        irafmod.iraf.setjd(imageName)
        logger.debug("starting phot")
        daophot.phot(imageName,coordFile,"default")
        logger.debug("starting pstselect")
        #params:  image, photfile, pstfile, maxnpsf
        daophot.pstselect(imageName,"default","default",25)
        #params: imagename photfile pstfile psfimage opstfile groupfile
        daophot.psf(imageName,"default","default","default","default","default",
            interactive=irafmod.no)
        #TODO should we be more sophisticated and do multiple runs of psf
        #along with using nstar and substar to try and get best fit?

        #use nstar for now, but we will make it a seperate function
        #so it is easy to switch out with peak or allstar
        #if we desire later
        do_nstar(imageName)