Ejemplo n.º 1
0
def run_elli(input, xcntr, ycntr, eg, pa, sma):#,radd,background):
	
    iraf.stsdas(_doprint=0)
    iraf.tables(_doprint=0)
    iraf.stsdas.analysis(_doprint=0)
    iraf.stsdas.analysis.isophote(_doprint=0)
    image_exist = 1
    if(str(input)[:3] == 'ima'):
        output = 'elli_' + input[6:-4] + 'txt' 
    if(str(input)[:3] == 'out'):
        output = 'out_elli_' + str(input)[4:-7] + 'txt'
	#unlearn geompar	controlpar samplepar magpar ellipse
    iraf.geompar(x0=xcntr, y0=ycntr, ellip0=eg, pa0=pa, sma0=10, minsma=0.1, \
                 maxsma=sma*5.0, step=0.1,recente="yes")
    iraf.controlpar(conver=0.05, minit=10, maxit=50, hcenter="no", hellip="no",\
                    hpa="no", wander="", maxgerr=0.5, olthres=1,soft="no")
    iraf.samplepar(integrm="bi-linear", usclip=3,lsclip=3, nclip=0, fflag=0.5)
    iraf.magpar(mag0=0, refer=1, zerolev=0)
    iraf.ellipse("".join(input), output="test", interac="no",Stdout="ellip", \
                 Stderr="err")
    iraf.tprint("test.tab", prparam="no", prdata="yes", pwidth=80, plength=0, \
                showrow="no", orig_row="no", showhdr="no", showunits="no", \
                columns="SMA, INTENS, INT_ERR, MAG, MAG_LERR, MAG_UERR",\
                rows="-", \
                option="plain", align="yes", sp_col="", lgroup=0, Stdout=output)
    for myfile in ['ellip','err','test.tab']:
        if os.access(myfile,os.F_OK):
            os.remove(myfile)
Ejemplo n.º 2
0
def run_elli_full(cutimage, output, xcntr, ycntr, eg, pa, sma,
                  sky):  #,radd,background):
    """The function responsible for fit ellipse"""
    EllGal = c.outdir + 'GalEllFit.fits'
    fEl = pyfits.open(os.path.join(c.datadir, cutimage))
    GaLaXy = fEl[0].data
    fEl.close()
    GaLaXy = GaLaXy - sky
    hdu = pyfits.PrimaryHDU(GaLaXy.astype(n.float32))
    hdu.writeto(EllGal)
    try:
        iraf.stsdas(_doprint=0)
        iraf.tables(_doprint=0)
        iraf.stsdas.analysis(_doprint=0)
        iraf.stsdas.analysis.isophote(_doprint=0)
    except:
        iraf.stsdas()
        iraf.tables()
        iraf.stsdas.analysis()
        iraf.stsdas.analysis.isophote()
    image_exist = 1
    iraf.unlearn('geompar')
    iraf.geompar.x0 = xcntr
    iraf.geompar.y0 = ycntr
    iraf.geompar.ellip0 = eg
    iraf.geompar.pa0 = pa
    iraf.geompar.sma0 = 6.0
    iraf.geompar.minsma = 0.1
    iraf.geompar.maxsma = sma * 5.0
    iraf.geompar.step = 0.1
    iraf.geompar.recente = "no"
    iraf.geompar.xylearn = "no"
    iraf.unlearn('controlpar')
    iraf.controlpar.conver = 0.05
    iraf.controlpar.minit = 10
    iraf.controlpar.maxit = 50
    iraf.controlpar.hcenter = "no"
    iraf.controlpar.hellip = "no"
    iraf.controlpar.hpa = "no"
    iraf.controlpar.wander = "INDEF"
    iraf.controlpar.maxgerr = 0.5
    iraf.controlpar.olthres = 1
    iraf.controlpar.soft = "no"
    iraf.samplepar.integrm = "bi-linear"
    iraf.samplepar.usclip = 3
    iraf.samplepar.lsclip = 3
    iraf.samplepar.nclip = 0
    iraf.samplepar.fflag = 0.5
    iraf.unlearn('ellipse')
    iraf.ellipse("".join(EllGal), output="test", interac="no",Stdout="ellip", \
                 Stderr="err")
    iraf.tprint("test.tab", prparam="no", prdata="yes", pwidth=80, plength=0, \
                showrow="no", orig_row="no", showhdr="no", showunits="no", \
                columns="SMA, INTENS, INT_ERR, ELLIP, ELLIP_ERR, PA, PA_ERR, \
                MAG, MAG_LERR, MAG_UERR, TMAG_E, TMAG_C, A3, \
		A3_ERR, B3, B3_ERR, A4, A4_ERR, B4_ERR"                                         , rows="-", \
                option="plain", align="yes", sp_col="", lgroup=0, Stdout=output)
    for myfile in ['ellip', 'err', 'test.tab', EllGal]:
        if os.access(c.outdir + myfile, os.F_OK):
            os.remove(c.outdir + myfile)
Ejemplo n.º 3
0
def run_elli_full(input, output, xcntr, ycntr, eg, pa, sma, sky):#,radd,background):
    """The function responsible for fit ellipse"""
    EllGal = 'GalEllFit.fits'
    fEl = pyfits.open(input)
    GaLaXy = fEl[0].data
    fEl.close()
    GaLaXy = GaLaXy - sky
    hdu = pyfits.PrimaryHDU(GaLaXy.astype(n.float32))
    hdu.writeto(EllGal)
    try:
        iraf.stsdas(_doprint=0)
        iraf.tables(_doprint=0)
        iraf.stsdas.analysis(_doprint=0)
        iraf.stsdas.analysis.isophote(_doprint=0)
    except:
        iraf.stsdas()
	iraf.tables()
	iraf.stsdas.analysis()
	iraf.stsdas.analysis.isophote()
    image_exist = 1
    iraf.unlearn('geompar')
    iraf.geompar.x0=xcntr
    iraf.geompar.y0=ycntr
    iraf.geompar.ellip0=eg
    iraf.geompar.pa0=pa
    iraf.geompar.sma0=6.0
    iraf.geompar.minsma=0.1
    iraf.geompar.maxsma=sma*5.0
    iraf.geompar.step=0.1
    iraf.geompar.recente="no"
    iraf.geompar.xylearn="no"
    iraf.unlearn('controlpar')
    iraf.controlpar.conver=0.05
    iraf.controlpar.minit=10
    iraf.controlpar.maxit=50
    iraf.controlpar.hcenter="no"
    iraf.controlpar.hellip="no"
    iraf.controlpar.hpa="no"
    iraf.controlpar.wander="INDEF"
    iraf.controlpar.maxgerr=0.5
    iraf.controlpar.olthres=1
    iraf.controlpar.soft="no"
    iraf.samplepar.integrm="bi-linear"
    iraf.samplepar.usclip=3
    iraf.samplepar.lsclip=3
    iraf.samplepar.nclip=0
    iraf.samplepar.fflag=0.5
    iraf.unlearn('ellipse')
    iraf.ellipse("".join(EllGal), output="test", interac="no",Stdout="ellip", \
                 Stderr="err")
    iraf.tprint("test.tab", prparam="no", prdata="yes", pwidth=80, plength=0, \
                showrow="no", orig_row="no", showhdr="no", showunits="no", \
                columns="SMA, INTENS, INT_ERR, ELLIP, ELLIP_ERR, PA, PA_ERR, \
                MAG, MAG_LERR, MAG_UERR, TMAG_E, TMAG_C, A3, \
		A3_ERR, B3, B3_ERR, A4, A4_ERR, B4_ERR", rows="-", \
                option="plain", align="yes", sp_col="", lgroup=0, Stdout=output)
    for myfile in ['ellip','err','test.tab', EllGal]:
        if os.access(myfile,os.F_OK):
            os.remove(myfile)
Ejemplo n.º 4
0
def run_elli(input, output, xcntr, ycntr, eg, pa, sma):#,radd,background):
    """The function resposible for fit ellipse"""
    iraf.stsdas(_doprint=0)
    iraf.tables(_doprint=0)
    iraf.stsdas.analysis(_doprint=0)
    iraf.stsdas.analysis.isophote(_doprint=0)
    image_exist = 1
#    if(str(input)[:3] == 'ima'):
#        output = 'elli_' + input[6:-4] + 'txt' 
#    if(str(input)[:3] == 'out'):
#        output = 'out_elli_' + str(input)[4:-7] + 'txt'
#    else:
#        output = 'elli_' + input[:-5] + '.txt'
	#unlearn geompar	controlpar samplepar magpar ellipse
    iraf.unlearn('geompar')
    iraf.geompar.x0=xcntr
    iraf.geompar.y0=ycntr
    iraf.geompar.ellip0=eg
    iraf.geompar.pa0=pa
    iraf.geompar.sma0=10
    iraf.geompar.minsma=0.1
    iraf.geompar.maxsma=sma*5.0
    iraf.geompar.step=0.1
    iraf.geompar.recente="no"
    iraf.geompar.xylearn="no"
    iraf.unlearn('controlpar')
    iraf.controlpar.conver=0.05
    iraf.controlpar.minit=10
    iraf.controlpar.maxit=50
    iraf.controlpar.hcenter="no"
    iraf.controlpar.hellip="no"
    iraf.controlpar.hpa="no"
    iraf.controlpar.wander="INDEF"
    iraf.controlpar.maxgerr=0.5
    iraf.controlpar.olthres=1
    iraf.controlpar.soft="no"
    iraf.samplepar.integrm="bi-linear"
    iraf.samplepar.usclip=3
    iraf.samplepar.lsclip=3
    iraf.samplepar.nclip=0
    iraf.samplepar.fflag=0.5
    iraf.magpar.mag0=c.mag_zero
    iraf.magpar.refer=1
    iraf.magpar.zerolev=0
    iraf.ellipse("".join(input), output="test", interac="no",Stdout="ellip", \
                 Stderr="err")
    iraf.tprint("test.tab", prparam="no", prdata="yes", pwidth=80, plength=0, \
                showrow="no", orig_row="no", showhdr="no", showunits="no", \
                columns="SMA, INTENS, INT_ERR, MAG, MAG_LERR, MAG_UERR, \
                TFLUX_E", rows="-", \
                option="plain", align="yes", sp_col="", lgroup=0, Stdout=output)
    for myfile in ['ellip','err','test.tab']:
        if os.access(myfile,os.F_OK):
            os.remove(myfile)
Ejemplo n.º 5
0
def getBgrd(tablename):
    iraf.tables()
    dumpfile = tablename + '_dump.txt'

    try:
        os.remove(dumpfile)
    except OSError:
        pass

    iraf.tdump(table=tablename, columns='INTENS', datafile=dumpfile)

    file = open(dumpfile, "r")
    lineList = file.readlines()
    lastLine = lineList[-1]
    lastLine = lastLine.replace('\t', '')
    lastLine = lastLine.replace('\s', '')
    lastLine = lastLine.replace('\n', '')
    bg = float(lastLine)
    file.close()

    os.remove(dumpfile)

    print(bg)
Ejemplo n.º 6
0
    threshold = float(coordLines[27].split()[3])
    coordFile.close()

    print(objname, filter_, fwhm, sigma, threshold)
    print('creating psf...')

    iraf.images(_doprint=0)
    iraf.tv(_doprint=0)
    iraf.ptools(_doprint=0)
    iraf.noao(_doprint=0)
    iraf.digiphot(_doprint=0)
    iraf.photcal(_doprint=0)
    iraf.apphot(_doprint=0)
    iraf.imutil(_doprint=0)
    iraf.daophot(_doprint=0)
    iraf.tables(_doprint=0)

    iraf.unlearn(iraf.ptools.pselect, iraf.tables.tcreate, iraf.tables.tmatch,
                 iraf.tables.tinfo, iraf.tables.tdump)

    # first measure the psf for the image
    iraf.unlearn(iraf.phot, iraf.datapars, iraf.photpars, iraf.centerpars,
                 iraf.fitskypars)

    iraf.apphot.phot.setParam('interactive', "no")
    iraf.apphot.phot.setParam('verify', "no")
    iraf.datapars.setParam('datamax', "INDEF")
    iraf.datapars.setParam('gain', "gain")
    iraf.datapars.setParam('ccdread', "rdnoise")
    iraf.datapars.setParam('exposure', "exptime")
    iraf.datapars.setParam('airmass', "airmass")
Ejemplo n.º 7
0
                os.system(s)
                repeatflag = 0
                print 'i think repeatflag = 0 ', repeatflag

            print 'repeatflag = ', repeatflag


os.system('mkdir Finished')
os.system('mkdir NearbyObjects')
os.system('mkdir PartialImages')
os.system('mkdir OffCenter')
raw_input('Make sure ds9 is open.  Hit return when ready.')
iraf.stsdas()
iraf.analysis()
iraf.isophote()
iraf.tables()
iraf.ttools()
mipsfiles = glob.glob('*cutout-24.fits')
mipsfiles.sort()

mipswcsfiles = glob.glob('*cutout-24-rot.fits')
mipswcsfiles.sort()

sdssrfiles = glob.glob('*cutout-sdss.fits')
sdssrfiles.sort()

ipa = 0
xcenter = 23.0
ycenter = 23.0
minr = 2
initialr = 6
Ejemplo n.º 8
0
                print 'i think repeatflag = 0', repeatflag
                return
            else:
                s='mv *'+imprefix+'* Finished/'
                os.system(s)
                repeatflag=0
                print 'i think repeatflag = 0 ', repeatflag

            print 'repeatflag = ',repeatflag
            

raw_input('Make sure ds9 is open.  Hit return when ready.')
iraf.stsdas()
iraf.analysis()
iraf.isophote()
iraf.tables()
iraf.ttools()

#t=os.getcwd()
#s=t.split('cutouts')
#t=s[1].split('/')
#prefix=t[1]
#s=prefix+'*cutout-24.fits'
#mipsfiles=glob.glob(s)
#s=prefix+'*cutout-sdss.fits'
#print s
fileprefix=sys.argv[1]
print fileprefix
sdssrfiles=glob.glob(fileprefix)
print sdssrfiles
Ejemplo n.º 9
0
            for n in self.dataset.frames:
                basename = os.path.splitext(os.path.basename(self.dataset.frames[n]['irafpath']))[0]
                shutil.copy(os.path.join(self.pars.wdir, self.dataset.masterdir, 'master.final'),
                            os.path.join(self.pars.wdir, self.irafphotdir, basename + '.coord'))
                f2.write(os.path.join(self.pars.wdir, self.irafphotdir, basename + '.phot') + '\n')
                f3.write(os.path.join(self.pars.wdir, self.irafphotdir, basename + '.coord') + '\n')
            f2.close()
            f3.close()

            logging.info('Photometry will be performed using the following apertures: %s' % self. apsizestr)

            # initialize IRAF
            iraf.noao(Stdout=1)
            iraf.digiphot(Stdout=1)
            iraf.daophot(Stdout=1, verify='no')
            iraf.tables(Stdout=1)
            iraf.ttools(Stdout=1)
            iraf.astutil(Stdout=1)

            # set some parameters for iraf photometry
            iraf.fitskypars.setParam('salgori', self.pars.iraf_phot['salgori'])
            iraf.fitskypars.setParam('annulus', self.pars.iraf_phot['annulus'])
            iraf.fitskypars.setParam('dannulu', self.pars.iraf_phot['dannulu'])
            iraf.centerpars.setParam('calgori', self.pars.iraf_phot['calgori'])
            iraf.centerpars.setParam('cbox',    self.pars.iraf_phot['cbox'])
            iraf.centerpars.setParam('maxshif', self.pars.iraf_phot['maxshif'])
            iraf.photpars.setParam('apertur', self.apsizestr)

            o = iraf.phot(image='@'+os.path.join(self.pars.wdir, self.dataset.framesdir, 'imagelist'), wcsin='world',
                          coords='@'+os.path.join(self.pars.wdir, self.irafphotdir, 'coordlist'),
                          output='@'+os.path.join(self.pars.wdir, self.irafphotdir, 'outputlist'),
Ejemplo n.º 10
0
 threshold = float(coordLines[27].split()[3])
 coordFile.close()
 
 print(objname, filter_, fwhm, sigma, threshold)
 print('creating psf...')
 
 iraf.images(_doprint=0)
 iraf.tv(_doprint=0)
 iraf.ptools(_doprint=0)
 iraf.noao(_doprint=0)
 iraf.digiphot(_doprint=0)
 iraf.photcal(_doprint=0)
 iraf.apphot(_doprint=0)  
 iraf.imutil(_doprint=0)
 iraf.daophot(_doprint=0)
 iraf.tables(_doprint=0)
 
 iraf.unlearn(iraf.ptools.pselect,iraf.tables.tcreate,iraf.tables.tmatch,iraf.tables.tinfo,iraf.tables.tdump)
 
 # first measure the psf for the image
 iraf.unlearn(iraf.phot,iraf.datapars,iraf.photpars,iraf.centerpars,iraf.fitskypars)
 
 iraf.apphot.phot.setParam('interactive',"no")
 iraf.apphot.phot.setParam('verify',"no")
 iraf.datapars.setParam('datamax',"INDEF")
 iraf.datapars.setParam('gain',"gain")
 iraf.datapars.setParam('ccdread',"rdnoise")
 iraf.datapars.setParam('exposure',"exptime")
 iraf.datapars.setParam('airmass',"airmass")
 iraf.datapars.setParam('filter',"filter")
 iraf.datapars.setParam('obstime',"time-obs")