def getSkyMeanSDinAnnulus(ann,delta=5):
	iraf.noao()
	iraf.digiphot()
	iraf.apphot()
	iraf.photpars.setParam('apertures','1')
	iraf.phot.setParam('interactive','no')
	iraf.phot.setParam('image',fitsDir+fitsFile)
	iraf.phot.setParam('coords',fitsDir+fitsFile+".coo")
	outmag=".maglim"
	try:	
		os.remove(fitsDir+fitsFile+outmag)
	except:
		print "File does not exist BEFORE running phot, so no need to delete."
	iraf.phot.setParam('output',fitsDir+fitsFile+outmag)
	iraf.phot.setParam('interac','no')	
	iraf.fitskypars.setParam('annulus',str(ann))	
	iraf.fitskypars.setParam('dannulus',str(delta))
	## NO SIGMA CLIPPING! JUST TO BE SAFE: (6/2013)
	iraf.fitskypars.setParam('sloclip',"0")
	iraf.fitskypars.setParam('shiclip',"0")

	iraf.phot(fitsDir+fitsFile,Stdin=cr)	
	aa, nn, xx, ss = ao.readPhotMagFile(fitsDir,fitsFile,outmag)
	try:	
		os.remove(fitsDir+fitsFile+outmag)
	except:
		print "File not found to delete AFTER running phot; that's odd."
	return xx
Exemple #2
0
def fitcoord_edge_each(fname, overwrite=False):
    nteractive = 'yes'
    database = 'database'
    function = 'chebyshev'
    xorder = 2
    yorder = 7
    logfiles = 'STDOUT,fitcoord_edge.log'
    interactive = 'yes'
    cursor = ''
    #    cursor = filibdir+'fitcoord_edge.cur'

    idfile = database + '/id' + fname
    if not os.path.isfile(idfile):
        print('\t Edge identification files do not exist. ' + idfile)
        return

    fcfile = database + '/fc' + fname
    if os.path.isfile(fcfile) and not overwrite:
        print('\t Edge fitcoord files already exist. ' + fcfile)
        print('\t This procedure is skipped.')
        return

    # Not to display items in IRAF packages
    sys.stdout = open('/dev/null', 'w')
    iraf.noao()
    iraf.twodspec()
    iraf.longslit()
    sys.stdout = sys.__stdout__  # Back to the stadard output

    iraf.fitcoord(fname, fitname='', interactive=interactive, \
                  combine='no', database=database, deletions='',\
                  function = function,xorder=xorder, yorder=yorder,\
                  logfiles=logfiles, graphics='stdgraph', cursor=cursor)

    return
Exemple #3
0
    def StandardTask(self, InputFile, OutputFile, FitsFolder, airmass_value, exptime_value):
   
        iraf.noao(_doprint=0)
        iraf.onedspec(_doprint=0)               
        
        #From the fits file determine which is the star being treated
        StarName = self.StarnameFromFileName(InputFile)
        
        #Get the corresponding Calibration file
        CalibrationFile, Bandwidth, Bandsep   = self.getCalibrationFile(StarName)
        
        #Incase no output name is given, we generate one with the provided "preffix" (The defaul format is a_std_wolf.dat)
        if OutputFile == None:
            OutputFile    = 'a_std_' + StarName
        
        #Prepare dictionary with the configuration for the tasks           
        Standard_conf_Comb  = self.StandardAttributes(InputFile, OutputFile, CalibrationFile, FitsFolder, airmass_value, exptime_value, Bandwidth, Bandsep)

        #Display the equivalent command in IRAF
        Command = self.printIrafCommand('standard', Standard_conf_Comb)
        print '--- Using the command'
        print Command
        
        #Run the task        
        iraf.onedspec.standard(**Standard_conf_Comb)
        
        return OutputFile 
Exemple #4
0
def align_combine(fitsdir, myfilter, examine=True):
    from pyraf import iraf 
    
    iraf.noao(_doprint=0)
    iraf.digiphot(_doprint=0)
    iraf.apphot(_doprint=0)
    
    os.chdir(fitsdir)
    listfiles = glob.glob(myfilter)
    listfiles.sort()
    
    if (examine):
        print "Opening ",listfiles[0]," to examine."
        iraf.imexamine(input=listfiles[0], \
                    logfile="coords.dat", \
                    keeplog="yes")
        
        with open("align.list",'w') as f:
            for i in listfiles:
                f.write(i+"\n")
    
    print "Aligning with reference:",listfiles[0]
    iraf.imalign( input   =  "@align.list", referenc= listfiles[0], coords  =  "coords.dat", output  = "*****@*****.**")  
    
    listfiles = glob.glob("a_"+myfilter)
    listfiles.sort()
    with open("comb.list",'w') as f:
        for i in listfiles:
            f.write(i+"\n")
            
    print "Combining"        
    iraf.imcombine(input = "@comb.list",\
                   output = "out.fits",\
                   combine= "median")
Exemple #5
0
def combinebias(lstfn):
    """
    call iraf command zerocombine, combine bias fits.
    lstfn : lst file name
    type : string
    output file : Zero.fits
    """
    iraf.noao()
    iraf.imred()
    iraf.ccdred()
    iraf.zerocombine(input='o//@' + lstfn,
                     output='Zero',
                     combine='average',
                     reject='minmax',
                     ccdtype='',
                     process=False,
                     delete=False,
                     clobber=False,
                     scale='none',
                     statsec='',
                     nlow=0,
                     nhigh=1,
                     nkeep=1,
                     mclip=True,
                     lsigma=3.0,
                     hsigma=3.0,
                     rdnoise='rdnoise',
                     gain='gain',
                     snoise=0.0,
                     pclip=-0.5,
                     blank=0.0)
Exemple #6
0
def standard(namelst):
    iraf.noao()
    iraf.twodspec()
    iraf.longslit(dispaxis=2, nsum=1, observatory=func.obs.name,
                  extinction=extpath, caldir=stdpath)
    if os.path.isfile('Std'):
        print('remove file Std')
        os.remove('Std')
    for std_fitsname in namelst:
        stdname, stdmag, stdmagband = func.standard_star_info(std_fitsname)
        print(colored('the standard star is ' + stdname, 'green'))
        wid, sep = get_band_width_sep(std_fitsname)
        airmas = pyfits.getval(std_fitsname, 'airmass')
        exposure = pyfits.getval(std_fitsname, 'exptime')
        iraf.standard(input=std_fitsname, output='Std', samestar=True,
                    beam_switch=False, apertures='', bandwidth=wid,
                    bandsep=sep,  # 30.0  20.0
                    fnuzero=3.6800000000000E-20, extinction=extpath,
                    caldir=stdpath, observatory=func.obs.name, interact=True,
                    graphics='stdgraph', cursor='', star_name=stdname,
                    airmass=airmas, exptime=exposure, mag=stdmag,
                    magband=stdmagband, teff='', answer='yes')
    if os.path.isfile('Sens.fits'):
        print('remove file Sens.fits')
        os.remove('Sens.fits')
    iraf.sensfunc(standards='Std', sensitivity='Sens',
                  extinction=extpath, function='spline3', order=9)
    iraf.splot('Sens')
def apall_config(
    config_file,
    config_default='/Users/ando/andry/research/Make_software/saltrss/apall_conf.yml'
):
    config = yaml.safe_load(open(config_default))
    custom_config = {}
    if os.path.exists(config_file):
        custom_config = yaml.safe_load(open(config_file))

    config = config_merge(custom_config, config)

    sections = [
        'iraf.apall',
    ]
    iraf.noao(_doprint=0)
    iraf.twodspec(_doprint=0)
    iraf.onedspec(_doprint=0)
    iraf.apextract(_doprint=0)
    iraf.apextract.unlearn()
    iraf.apall.unlearn()
    iraf.apsum.unlearn()
    iraf.apextract.setParam('dispaxis', 1)

    for section_name in sections:
        params = config[section_name].items()
        for param_id in params:
            eval(section_name).setParam(param_id[0], param_id[1])
    return config
Exemple #8
0
    def _get_photometry(self):
        """ Get the photometry for the target.

        If the target is a standard star, aperture photometry will be performed. For the moment nothing is done with
        the others, but in due time (TODO) photometry.py will be included here. """

        basename = "standards"
        fd, coords_file = tempfile.mkstemp(prefix=basename, suffix=".coords")
        os.write(fd, "{0} {1} \n".format(self.RA, self.DEC))
        os.close(fd)

        if self.objtype == "standard":
            iraf.noao(_doprint=0)
            iraf.digiphot(_doprint=0)
            iraf.apphot(_doprint=0)
            seeing = self.header.hdr[self.header.seeingk]
            photfile_name = self.header.im_name + ".mag.1"
            utilities.if_exists_remove(photfile_name)
            kwargs =  dict(output=photfile_name, coords=coords_file,
                      wcsin='world', fwhm=seeing, gain=self.header.gaink, exposure=self.header.exptimek,
                      airmass=self.header.airmassk, annulus=6*seeing, dannulus=3*seeing,
                      apert=2*seeing, verbose="no", verify="no", interac="no")
            iraf.phot(self.header.im_name, **kwargs)
            [counts] = iraf.module.txdump(photfile_name, 'FLUX', 'yes', Stdout=subprocess.PIPE)
            utilities.if_exists_remove(coords_file)
            return float(counts)
Exemple #9
0
def calibrate(namelst):
    iraf.noao()
    iraf.twodspec()
    iraf.longslit(dispaxis=2,
                  nsum=1,
                  observatory='ca',
                  extinction=extpath,
                  caldir=stdpath)

    for fitname in namelst:
        outname = 'mark_' + fitname
        if os.path.isfile(outname):
            print('remove file ' + outname)
            os.remove(outname)

        iraf.calibrate(input=fitname,
                       output=outname,
                       extinct='yes',
                       flux='yes',
                       extinction=extpath,
                       ignoreaps='yes',
                       sensitivity='Sens',
                       fnu='no')
        iraf.splot(images=outname)
        iraf.flpr()
def thar_cal(object_b_fn_ec, object_b_fn_ec_w, colour):
# Import IRAF modules:
  iraf.noao(_doprint=0)
  iraf.onedspec(_doprint=0)
# Check input file and reference extraction exist before proceeding:
  if os.path.isfile(object_b_fn_ec) == True:
# Perform dispersion correction:
    iraf.dispcor(input=object_b_fn_ec, output=object_b_fn_ec_w)
    print ' '
    print '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
    print colour.capitalize() + ' object spectrum             '
    print '(' + str(object_b_fn_ec) + ')'
    print 'successfully wavelength calibrated in file         '
    print str(object_b_fn_ec_w) + '.'
    print '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
    print ' '
  else:
    print ' '
    print '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
    print 'Input frame                                        ' 
    print str(object_b_fn_ec)
    print 'does not exist. Exiting script.                    '
    print '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
    print ' '
    print ' '
    sys.exit()
def identify_objects(fnlist,skysiglist,fwhmlist,suffix=".coo"):
    """Runs the IRAF routine 'daofind' to locate objects in a series of images,
    creating coordinate files.
    
    Inputs:
    fnlist -> List of strings, each the path to a fits image.
    skysiglist -> List of floats, each the sky background sigma for an image.
    fwhmlist -> List of floats, each the FWHM of objects in an image.
    suffix -> Suffix for the coordinate files. '.coo' by default.
    
    Outputs:
    coolist -> List of strings, each the path to the coordinate files created.
    
    """
    
    print "Identifying objects in images..."
    
    coolist = []
    
    #Open IRAF packages
    iraf.noao(_doprint=0)
    iraf.digiphot(_doprint=0)
    iraf.apphot(_doprint=0)
    for i in range(len(fnlist)):
        coolist.append(fnlist[i]+suffix)
        iraf.daofind(image=fnlist[i],
                     output=fnlist[i]+suffix,
                     fwhmpsf=fwhmlist[i],
                     sigma=skysiglist[i],
                     threshold=4.0,
                     datamin='INDEF',
                     datamax='INDEF',
                     verify='N')
    return coolist
Exemple #12
0
def standard():
    stdpath = os.path.split(os.path.realpath(__file__))[0] + os.sep + 'standarddir' + os.sep
    print('standard dir is ' + stdpath)
    extpath = os.path.split(os.path.realpath(__file__))[0] + os.sep + 'LJextinct.dat'
    iraf.noao()
    iraf.twodspec()
    iraf.longslit(dispaxis = 2, nsum = 1, observatory = 'Lijiang', 
            extinction = extpath, caldir = stdpath)
    for objname in stdgroup:
        stdname, stdmag, stdmagband = get_std_name(objname)
        print('the standard star is ' + stdname)
        stdmag = float(stdmag)
        outname1 = 'stdawftbo' + stdgroup[objname][0]
        inname   = ''
        for tmpname in stdgroup[objname]:
            inname = inname + 'awftbo' + tmpname + ','
        inname = inname[0:-1]
        iraf.standard(input = inname
                , output = outname1, samestar = True, beam_switch = False
                , apertures = '', bandwidth = 30.0, bandsep = 20.0
                , fnuzero = 3.6800000000000E-20, extinction = extpath
                , caldir = stdpath, observatory = ')_.observatory'
                , interact = True, graphics = 'stdgraph', cursor = ''
                , star_name = stdname, airmass = '', exptime = ''
                , mag = stdmag, magband = stdmagband, teff = '', answer = 'yes')
    for name in stdgroup:
        inpar = 'stdawftbo' + stdgroup[name][0]
        iraf.sensfunc(standards = inpar, sensitivity = 'sensawftbo' + stdgroup[name][0], 
            extinction = extpath, function = 'spline3', order = 9)
def run_fxcor(lstl, lstu, tpl, tpu, chip):
    if chip == 'l':
        templ = tpl
        lst = lstl
    else:
        templ = tpu
        lst = lstu
    lista = '@' + lst
    chip_par = 'rvout_' + chip
    iraf.noao()
    iraf.rv()
    iraf.fxcor(lista,
               templ,
               output=chip_par,
               verbose='txtonly',
               interac='no',
               observa='paranal')
    rv = []
    rvlist = open(chip_par + '.txt', "r")
    for cols in (raw.strip().split() for raw in rvlist):
        vobs_index = len(cols) - 3
        if cols[0][0] != '#':
            rv.append(float(cols[vobs_index]))
    rvlist.close()
    return rv
Exemple #14
0
def get_seeing(file, scale, ref):
    coords = file.replace('fits','dao')
    log = file.replace('fits','psf')
    out = file.replace('fits','seeing')

    iraf.noao()
    iraf.noao.obsutil()
    iraf.set(stdgraph="uepsf")

    data = iraf.psfmeasure(file, coords='markall', wcs='logical', display='no', frame=1, level=0.5, size='FWHM', radius=10.0, sbuffer=1.0, swidth=3.0, iterations=1, logfile=log, imagecur=coords, Stdout=1)

    fwhm = data.pop().split().pop()

    fwhm_pix = float(fwhm)
    fwhm = fwhm_pix*scale
    seeing = dimm_seeing(fwhm_pix, ref, scale)
    print "Seeing: ", seeing

    fp = open(out, 'w')
    fp.write("%f %f\n" % (fwhm_pix, seeing))
    fp.close()
    os.system("echo \"image;text 85 500 # text={Spot FWHM = %5.2f pixels}\" | xpaset WFS regions" % fwhm_pix)
    os.system("echo \'image;text 460 500 # text={Seeing = %4.2f\"}\' | xpaset WFS regions" % seeing)
    os.system("echo \"set wfs_seeing %4.2f\" | nc hacksaw 7666" % seeing)
    # New function call to insert seeing value into MySQL database.
    fits2mysql(file, mode, fwhm, seeing)
def run_scombine(listin, fn):
    namefil = []
    namelist = open(listin, "r")
    for cols in (raw.strip().split() for raw in namelist):
        namefil.append(cols[0])
    namelist.close()
    obs = []
    count = -1
    for i in range(len(namefil)):
        if namefil[i - 1][0:2] != namefil[i][0:2]:
            obs.append([])
            count += 1
        obs[count].append(namefil[i])
    spec = []
    for i in range(len(obs[0])):
        spec.append([])
        for j in range(len(obs)):
            spec[i].append(obs[j][i])
    iraf.noao()
    iraf.onedspec()
    for i in range(len(spec)):
        temp = open('temp_list', 'w')
        for j in range(len(spec[i])):
            temp.write(spec[i][j] + '\n')
        temp.close()
        if (spec[i][0][-6] == 'L') or (spec[i][0][-6] == 'U'):
            name_index = '0_' + spec[i][0][-6]
        else:
            name_index = spec[i][0][-6] + '_' + spec[i][0][-8]
        if len(fibnum) != 0:
            newname = ob_id[fibnum.index(name_index[0])] + '_' + name_index[-1]
            name_index = newname
        iraf.scombine('@temp_list', name_index, logfile='combine_log')
        fn.append(name_index)
Exemple #16
0
def coroverbiastrim(lstfile):
    iraf.noao()
    iraf.imred()
    iraf.ccdred()
    x1,x2,y1,y2 = get_trim_sec()
    iraf.ccdproc(images = '@' + lstfile + '//[1]'
        , output = '%bo%bo%@' + lstfile
        , ccdtype = '', max_cache = 0, noproc = False
        , fixpix = False, overscan = True, trim = False
        , zerocor = True, darkcor = False, flatcor = False
        , illumcor = False, fringecor = False, readcor = False
        , scancor = False, readaxis = 'line', fixfile = ''
        , biassec = '[5:45,%s:%s]'%(y1,y2), trimsec = '[%s:%s,%s:%s]'%(x1,x2,y1,y2)
        , zero = 'Zero', dark = '', flat = '', illum = '', fringe = ''
        , minreplace = 1.0, scantype = 'shortscan', nscan = 1
        , interactive = False, function = 'chebyshev', order = 1
        , sample = '*', naverage = 1, niterate = 1
        , low_reject = 3.0, high_reject = 3.0, grow = 1.0)
    iraf.ccdproc(images = '%bo%bo%@' + lstfile
        , output = '%tbo%tbo%@' + lstfile
        , ccdtype = '', max_cache = 0, noproc = False
        , fixpix = False, overscan = False, trim = True
        , zerocor = False, darkcor = False, flatcor = False
        , illumcor = False, fringecor = False, readcor = False
        , scancor = False, readaxis = 'line', fixfile = ''
        , biassec = '[5:45,%s:%s]'%(y1,y2), trimsec = '[%s:%s,%s:%s]'%(x1,x2,y1,y2)
        , zero = 'Zero', dark = '', flat = '', illum = '', fringe = ''
        , minreplace = 1.0, scantype = 'shortscan', nscan = 1
        , interactive = False, function = 'chebyshev', order = 1
        , sample = '*', naverage = 1, niterate = 1
        , low_reject = 3.0, high_reject = 3.0, grow = 1.0)
    iraf.flpr()
Exemple #17
0
def standard(imlist_name, obj, obs):
    """
    standard -- Add standard stars to sensitivity file
    standard input [records] output
    standard wfcdbstd.ms.fits (no) "sao"

    extinct = "/iraf/iraf/noao/lib/onedstds/iidscal/feige56.dat"

    caldir  = "/iraf/iraf/noao/lib/onedstds/iidscal/"
    """
    import glob
    import os, sys
    from pyraf import iraf
    iraf.noao()
    iraf.onedspec()
    imlist = glob.glob(imlist_name)
    imlist.sort()
    for i in range(len(imlist)):
        inim = imlist[i]
        iraf.standard(
            input=inim,
            output='s' + inim[:-5],
            extinct='/iraf/iraf/noao/lib/onedstds/iidscal/feige56.dat',
            observatory=obs,
            caldir="/iraf/iraf/noao/lib/onedstds/iidscal/",
            star_name=obj)
Exemple #18
0
def align_combine(fitsdir, myfilter, examine=True):
    from pyraf import iraf 
    
    iraf.noao(_doprint=0)
    iraf.digiphot(_doprint=0)
    iraf.apphot(_doprint=0)
    
    os.chdir(fitsdir)
    listfiles = glob.glob(myfilter)
    listfiles.sort()
    
    if (examine):
        print "Opening ",listfiles[0]," to examine."
        iraf.imexamine(input=listfiles[0], \
                    logfile="coords.dat", \
                    keeplog="yes")
        
        with open("align.list",'w') as f:
            for i in listfiles:
                f.write(i+"\n")
    
    print "Aligning with reference:",listfiles[0]
    iraf.imalign( input   =  "@align.list", referenc= listfiles[0], coords  =  "coords.dat", output  = "*****@*****.**")  
    
    listfiles = glob.glob("a_"+myfilter)
    listfiles.sort()
    with open("comb.list",'w') as f:
        for i in listfiles:
            f.write(i+"\n")
            
    print "Combining"        
    iraf.imcombine(input = "@comb.list",\
                   output = "out.fits",\
                   combine= "median")
Exemple #19
0
def wal(lstfile):
    iraf.noao()
    iraf.twodspec()
    iraf.longslit()
    iraf.identify(images = 'Lamp'
        , section = 'middle column', database = 'database'
        , coordlist = 'linelists$idhenear.dat', units = '', nsum = 10
        , match = -3.0, maxfeatures = 50, zwidth = 100.0
        , ftype = 'emission', fwidth = 20.0, cradius = 5.0
        , threshold = 0.0, minsep = 2.0, function = 'chebyshev'
        , order = 6, sample = '*', niterate = 0
        , low_reject = 3.0, high_reject = 3.0, grow = 0.0
        , autowrite = False, graphics = 'stdgraph', cursor = ''
        , crval = '', cdelt = '')
    iraf.reidentify(reference = 'Lamp'
        , images = 'Lamp', interactive = 'no', section = 'column'
        , newaps = True, override = True, refit = True, trace = False
        , step = 10, nsum = 10, shift = 0.0, search = 0.0, nlost = 5
        , cradius = 7.0, threshold = 0.0, addfeatures = False
        , coordlist = 'linelists$idhenear.dat', match = -3.0, maxfeatures = 50
        , minsep = 2.0, database = 'database', logfiles = 'logfile'
        , plotfile = '', verbose = False, graphics = 'stdgraph', cursor = ''
        , answer = 'yes', crval = '', cdelt = '', mode = 'al')
    iraf.fitcoords(images = 'Lamp'
        , fitname = 'Lamp', interactive = True, combine = False, database = 'database'
        , deletions = 'deletions.db', function = 'chebyshev', xorder = 6
        , yorder = 6, logfiles = 'STDOUT,logfile', plotfile = 'plotfile'
        , graphics = 'stdgraph', cursor = '', mode = 'al')
    iraf.longslit(dispaxis = 2)
    iraf.transform(input = '%ftbo%ftbo%@' + lstfile
        , output = '%wftbo%wftbo%@' + lstfile, minput = '', moutput = ''
        , fitnames = 'LampLamp', database = 'database', interptype = 'spline3'
        , flux = True)
Exemple #20
0
def combine_flat(lstfile):
    iraf.noao()
    iraf.imred()
    iraf.ccdred()
    iraf.flatcombine(input='tbo//@' + lstfile,
                     output='Halogen',
                     combine='average',
                     reject='crreject',
                     ccdtype='',
                     process=False,
                     subsets=False,
                     delete=False,
                     clobber=False,
                     scale='mode',
                     statsec='',
                     nlow=1,
                     nhigh=1,
                     nkeep=1,
                     mclip=True,
                     lsigma=3.0,
                     hsigma=3.0,
                     rdnoise='rdnoise',
                     gain='gain',
                     snoise=0.0,
                     pclip=-0.5,
                     blank=1.0)
Exemple #21
0
	def makeObject(self, inObjectFile="mkobject.coo"):
		
		"""IRAF routine: mkobjects. This places a star in the fits image that is the parent object of this class, at the given ra and dec. It takes as input a file of "ra dec magnitude" for a star type object.

		1. Get info from the header files if you want noise
		2. Get FWHM for size of the star for the given image
		3. Generate the star

		radius = FWHM / scale, from statistics, scale = 2*sqrt(2*ln(2))
		"""
	
		# 1.
		self.loadHeader()
		INFODICT = {
			"RON": self.getHeader("RON"), \
			"GAIN": self.getHeader("GAIN"), \
			"EXPTIME": self.getHeader("EXPTIME"), \
			"MAGZP": self._ZPDICT[self.getHeader("FILTER")], \
			"POISSON": "no", \
			"STAR": "gaussian", \
			}	
		# 2.
		scale = 2*scipy.sqrt(2*scipy.log(2))
		self.getMyMedianFWHM()
		INFODICT["RADIUS"] = self._MEDFWHM / scale

		# 3. 
		outputname = self._Name.replace(".fits", "_mko.fits")
		iraf.noao(_doprint=0)
		iraf.artdata(_doprint=0)
		
	        iraf.mkobjects(input=self._Name, \
                        output=outputname, \
                        # When creating new images
                        #title="",\
                        #ncols=self.xdim, \
                        #nlines=self.ydim, \
                        #header=self.hdrfile, \
                        #background=0.0, \
                        # When creating objects
                        objects=inObjectFile, \
                        xoffset=0.0, \
                        yoffset=0.0, \
                        star=INFODICT["STAR"], \
                        radius=INFODICT["RADIUS"], # this is fwhm/scale (pixels), where scale = 2sqrt(2ln2)\
                        #beta=2.5,  # for star=moffat profile\
                        ar=1.0, \
                        pa=0.0, \
                        distance=1.0, \
                        exptime=INFODICT["EXPTIME"], \
                        magzero=INFODICT["MAGZP"], \
                        # Noise parameters
                        gain=INFODICT["GAIN"], \
                        rdnoise=INFODICT["RON"], \
                        poisson=INFODICT["POISSON"], \
                        seed=1, \
                        comments=1)

		return outputname 
Exemple #22
0
def wspectext_allap(filepath, apaxis=0):
    """ this can be directly evaluated in terminal

    Parameters
    ----------
    filepath: string
        filepath

    apaxis: integer
        0 or 1.
        0 denotes dispersion along rows (this is the case for Xinglong216HRS)
        1 denotes dispersion along columns

    Examples
    --------
    wspectext_allap('./w20160120001s.fits')

    """
    nrow, ncol = fits.open(filepath)[0].data.shape
    print '@Cham: nrow = %d, ncol=%d' % (nrow, ncol)
    
    iraf.noao()
    iraf.noao.onedspec()
    
    filename = filepath.split(os.path.sep)[-1]
    
    # determine dirname & dirpath
    dirname = filepath.split(os.path.sep)[-1].replace('.fits', '')
    if os.path.dirname(filepath) == '':
        dirpath = dirname
    else:
        dirpath = os.path.dirname(filepath) + os.path.sep + dirname

    if os.path.exists(dirpath):
        # if dirpath exists
        print '@Cham: directory exists ... (%s)' % dirpath
    else:
        # if dirpath doesn't exist, mkdir
        os.mkdir(dirpath)
        print '@Cham: mkdir %s'%dirpath
    
    # execute wspectest
    if not apaxis == 1:
        for apnum in xrange(1, nrow+1):
            _input = '%s[1:%d, %d]' % (filename, ncol, apnum)
            _output = dirpath + os.sep + filename.replace('.fits', '_%04d.dat' % apnum)
            print '@Cham: wspectext running ... [%s]' % _output
            iraf.onedspec.wspectext(input=_input, output=_output, header='no')
    else:
        for apnum in xrange(1, ncol+1):
            _input = '%s[%d, 1:%d]' % (filename, apnum, nrow)
            _output = dirpath + os.sep + filename.replace('.fits', '_%04d.dat' % apnum)
            print '@Cham: wspectext running ... [%s]' % _output
            iraf.onedspec.wspectext(input=_input, output=_output, header='no')

    # print masseges
    print '@Cham: ----------------------'
    print '@Cham: mission complete!'
    print '@Cham: ----------------------'
Exemple #23
0
def combine_lamp(lstfile):
    iraf.noao()
    iraf.imred()
    iraf.ccdred()
    iraf.imcombine(input='%ftbo%ftbo%@' + lstfile,
                   output=lstfile.replace('.lst', ''),
                   combine='sum',
                   reject='none')
Exemple #24
0
def combinelamp(lst):
    iraf.noao()
    iraf.imred()
    iraf.ccdred()
    iraf.imcombine(input='%ftbo%ftbo%@' + lst,
                   output='Lamp',
                   combine='sum',
                   reject='none')
Exemple #25
0
def initialize_iraf():
    iraf.noao(_doprint=0)
    iraf.imred(_doprint=0)
    iraf.ccdred(_doprint=0)
    iraf.specred(_doprint=0)
    iraf.twodspec(_doprint=0)
    iraf.longslit(_doprint=0)
    return
def normalize(fn):
    iraf.noao()
    iraf.onedspec()
    for i in range(len(fn)):
        if fn[i][-1] == 'L':
            nord = '10'
        else:
            nord = '7'
        iraf.continuum(fn[i], fn[i], order=nord, ask='no', logfile='norm_log')
Exemple #27
0
def combinelamp(lst):
    iraf.noao()
    iraf.imred()
    iraf.ccdred()
    iraf.imcombine(input='%ftb%ftb%@' + lst,
                   output='Lamp',
                   combine='sum',
                   reject='none')
    print('<<<<<combine the lamp & generate the Lamp.fits>>>>>')
    iraf.flpr()
def normalize(setup, filelist):
    iraf.noao()
    iraf.onedspec()
    for i in (filelist):
        name = setup + '/' + i
        iraf.continuum(name,
                       name,
                       order=1,
                       ask='no',
                       logfile=setup + '/norm_log')
Exemple #29
0
def psfmeasure(image,
               coords,
               radius,
               output='STDOUT',
               size='FWHM',
               pxscale=None):
    iraf.noao(_doprint=0)
    iraf.obsutil(_doprint=0)
    if size == 'all':
        sname = ['FWHM', 'GFWHM', 'MFWHM']
        tbls = []
        for s in sname:
            stbl = psfmeasure(image, coords, radius, output, s, pxscale)
            tbls.append(stbl)
        tbl = join(tbls[0], tbls[1])
        tbl = join(tbl, tbls[2])
        return tbl

    results = iraf.obsutil.psfmeasure(image,
                                      coords='mark1',
                                      size=size,
                                      imagecur=coords,
                                      display='no',
                                      radius=radius,
                                      logfile='',
                                      Stdout=1,
                                      StdoutG="dev$null",
                                      scale=1)
    #print results
    results = results[2:4]
    results[0] = results[0].strip()
    results = {k: v for k, v in zip(results[0].split(), results[1].split())}
    for k in results.keys():
        try:
            results[k] = np.float(results[k])
        except ValueError:
            continue
    tbl = Table([results])
    tbl = tbl[[k for k in P_COLMAP.keys() if k in tbl.colnames]]
    for k, v in P_COLMAP.iteritems():
        if k in tbl.colnames:
            tbl.rename_column(k, v)

    fwhmcol = tbl.colnames[-1]
    tbl[fwhmcol] /= 2.0  # make hwhm
    if pxscale:
        tbl.add_column(
            Column(tbl[fwhmcol] * u.pix * pxscale,
                   name='%s_s' % fwhmcol,
                   unit=u.arcsec,
                   format='%.3f'))
        tbl[fwhmcol].unit = u.pix

    return tbl
Exemple #30
0
def psf(args):
    """ Calculate the PSF of an image.
    """
    # Load iraf packages: phot, pstselect, psf will be needed
    iraf.noao(_doprint=0)
    iraf.digiphot(_doprint=0)
    iraf.module.daophot(_doprint=0)
    
    # Read the seeing and sigma of the sky from the header
    seeing, sigma = utils.get_from_header(args.input, args.FWHM_key, args.sigma)
    
    # Do photometry on the image
    #print "photometry: \n"
    photfile_name = args.input + ".mag.1"
    utils.if_exists_remove(photfile_name)
    iraf.module.phot(args.input, output=photfile_name, coords=args.stars, 
                     wcsin=args.coords, fwhm=seeing, 
                     sigma=sigma, datamax=args.maxval, datamin=args.minval,
                     ccdread=args.ron_key, gain=args.gain_key, exposure=args.expt_key,
                     airmass=args.airm_key, annulus=6*seeing, dannulus=3*seeing, 
                     apert=2*seeing, verbose="no", verify="no", interac="no")

    # Select stars on the image                 
    #print "pstselect: \n"
    pstfile_name = args.input + ".pst.1"
    utils.if_exists_remove(pstfile_name)
    iraf.module.pstselect(args.input, photfile=photfile_name, pstfile=pstfile_name,
                          maxnpsf=20, fwhm=seeing, sigma=sigma,
                       datamax=args.maxval, ccdread=args.ron_key, gain=args.gain_key,
                       exposure=args.expt_key,  function="auto", nclean=1, 
                       psfrad=2*seeing, fitrad=seeing, maxnstar=20, verbose="no",
                       verify="no")

    # Build psf of the stars
    #print "psf: \n"
    psffile_table = args.input + ".psf.1.fits"  # iraf keeps adding the .fits :(
    psgfile_name = args.input + ".psg.1"
    pstfile_name2 = args.input + ".pst.2"   
    utils.if_exists_remove(psffile_table,psgfile_name, pstfile_name2)
    iraf.module.psf( args.input, photfile=photfile_name, pstfile=pstfile_name,
                     groupfile=psgfile_name, opstfile=pstfile_name2,    
                     psfimage=psffile_table,fwhm=seeing, sigma=sigma, datamax=args.maxval, 
                     datamin=args.minval, ccdread=args.ron_key, gain=args.gain_key, 
                     exposure=args.expt_key, function="moffat25", nclean=1, 
                     psfrad=12, fitrad=seeing, maxnstar=20, interactive="no",
                     varorder=-1, verbose="no",verify="no")
                     
    # Use seepsf to build the image of the psf
    psffile_name = args.input + ".psf.fits" 
    utils.if_exists_remove(psffile_name)
    iraf.module.seepsf(psffile_table, psffile_name)

     
    return psffile_name
Exemple #31
0
def combine_flat(lstfile):
    if os.path.isfile('Halogen.fits'):
        print 'remove Halogen.fits'
        os.remove('Halogen.fits')
    if os.path.isfile('Resp.fits'):
        print 'remove Resp.fits'
        os.remove('Resp.fits')
    iraf.noao()
    iraf.imred()
    iraf.ccdred()
    iraf.flatcombine(input='tbo//@' + lstfile,
                     output='Halogen',
                     combine='average',
                     reject='crreject',
                     ccdtype='',
                     process=False,
                     subsets=False,
                     delete=False,
                     clobber=False,
                     scale='mode',
                     statsec='',
                     nlow=1,
                     nhigh=1,
                     nkeep=1,
                     mclip=True,
                     lsigma=3.0,
                     hsigma=3.0,
                     rdnoise='rdnoise',
                     gain='gain',
                     snoise=0.0,
                     pclip=-0.5,
                     blank=1.0)
    iraf.twodspec()
    iraf.longslit(dispaxis=2,
                  nsum=1,
                  observatory='Lijiang',
                  extinction=func.config_path + os.sep + 'LJextinct.dat',
                  caldir=func.std_path + os.sep,
                  interp='poly5')
    iraf.response(calibration='Halogen',
                  normalization='Halogen',
                  response='Resp',
                  interactive=True,
                  threshold='INDEF',
                  sample='*',
                  naverage=1,
                  function='spline3',
                  order=25,
                  low_reject=10.0,
                  high_reject=10.0,
                  niterate=1,
                  grow=0.0,
                  graphics='stdgraph',
                  cursor='')
Exemple #32
0
def darkcom(input_dark):
    import glob
    import os, sys
    import numpy as np    
    from pyraf import iraf
    from astropy.io import fits
    from astropy.io import ascii
    curdir = os.getcwd()
    curdate = curdir.split('/')[-1]
    #dark = ", ".join(input_dark)
    iraf.noao()
    iraf.imred()
    iraf.ccdred()
    iraf.ccdred.setinst(instrume='camera', directo='/iraf/iraf/noao/imred/ccdred/ccddb/', query='q', review='no')
    #iraf.chdir('./dark')
    #dark = glob.glob('cal*dk*.fit')
    #dark = ascii.read('dark.list', guess=True, data_start=0)
    '''
    allexptime = []
    for i in range(len(dark)) :
        hdr = fits.getheader(dark[i])
        allexptime.append(hdr['exptime'])
    expset = set(allexptime)
    exptime = list(sorted(expset))
    i=0
    for i in range(len(exptime)) :
        print('Find images with exptime of '+str(exptime[i]))
        imlist = []
        for j in range(len(dark)) :
            hdr = fits.getheader(dark[j])
            if hdr['exptime'] == exptime[i] :
                imlist.append(dark[j])
            else :
                pass
        print(imlist)
        input_name = 'dark'+str(int(exptime[i]))+'.list'
        output_name = curdate+'_dark'+str(int(exptime[i]))+'.fits'
        #input_name = output_name[:-5]+'.list'
        f=open(input_name,'w+')
        for k in range(len(imlist)) : 
            f.write(imlist[k]+'\n')
        f.close()
    '''
    #output_name = curdate+'_dark'+str(int(exptime[i]))+'.fits'
    output_name = curdate+'_'+input_dark[:-5]+'.fits'
    print('Darkcombine is running...')
    iraf.imstat(images='z@'+input_dark)
    iraf.darkcombine(input='z@'+input_dark, output=output_name, combine='median', reject='minmax', process='no', scale='none', ccdtype='' )
    #os.system('/usr/bin/cp '+output_name+' ../')
    os.system('/usr/bin/cp '+output_name+' /data1/KHAO/MDFTS/red/masterdark/')
    #os.system('/usr/bin/rm d*.list')
    #iraf.chdir('../')
    iraf.dir('.')
    print('Output master '+output_name+' is created.') 
Exemple #33
0
def findStars(frame,fwhm,sigma,thresh,extra="",overwrite=True,interactive=True):
	if overwrite:
		if os.path.isfile(frame+".fullcoo"):
			os.system("rm "+frame+".fullcoo")
	iraf.noao()
	iraf.digiphot()
	iraf.daophot()
	iraf.datapars.setParam("fwhmpsf",fwhm)
	iraf.datapars.setParam("sigma",sigma)
	iraf.findpars.setParam("thresh",thresh)
	foo = iraf.daofind(image=frame+extra,output=frame+".fullcoo",Stdin=cr,Stdout=1)
Exemple #34
0
def combinebias(filename):
    iraf.noao()
    iraf.imred()
    iraf.ccdred()
    iraf.zerocombine(input = 'o//@' + filename
	, output = 'Zero', combine = 'average', reject = 'minmax'
	, ccdtype = '', process = False, delete = False
	, clobber = False, scale = 'none', statsec = ''
	, nlow = 0, nhigh = 1, nkeep = 1, mclip = True
	, lsigma = 3.0, hsigma = 3.0, rdnoise = 'rdnoise'
	, gain = 'gain', snoise = 0.0, pclip = -0.5, blank = 0.0)
Exemple #35
0
def standard_sens(infile, caldir=')_.caldir', noext=False, overwrite=False):
    print('\n#############################')
    print('Deriving sensitivity funciton')

    # Not to display items in IRAF packages
    sys.stdout = open('/dev/null', 'w')
    iraf.noao()
    iraf.onedspec()
    sys.stdout = sys.__stdout__  # Back to the stadard output

    basename = fits.getval(infile, 'FRAMEID')
    std = basename + '.std'

    if noext:
        extinction = ''
    else:
        extinction = fi.filibdir + 'mkoextinct.dat'

    if os.path.isfile(std) and not overwrite:
        print('\t The output file of IRAF STANDARD '+\
              'task already exits. '+std)
        print('\t STANDARD is skipped.')
    else:
        if overwrite:
            print('Removing ' + std)
            try:
                os.remove(std)
            except:
                pass

        iraf.standard(infile, std, extinction=extinction,\
                      caldir=caldir, beam_sw='no', aperture='')
        print('Output file of IRAF STANDARD task: ' + std)

    sens = basename + '.sens.fits'
    if os.path.isfile(sens) and not overwrite:
        print('\t The output file of IRAF SENSFUNC task already exits. ' +
              sens)
        print('\t SENSFUNC is skipped.')
    else:
        if overwrite:
            print('Removing ' + sens)
            try:
                os.remove(sens)
            except:
                pass

        iraf.sensfunc(std, sens, aperture='', ignoreaps='yes',\
                      extinction=extinction,\
                      logfile='sensfunc.log')
        print('Output file of IRAF SENSFUNC task: ' + sens)

    return sens, True
Exemple #36
0
def get_masked_image(img):

    # Running IRAF
    iraf.noao(_doprint=0)  
    mask = make_mask_cross(img)    
    masked = img.replace(".fits", "_masked.fits")
    
    if (os.path.isfile(masked)):
        os.remove(masked)
    iraf.imarith(img, "*", mask, masked)
    
    return masked
Exemple #37
0
def get_masked_image(img):

    # Running IRAF
    iraf.noao(_doprint=0)
    mask = make_mask_cross(img)
    masked = img.replace(".fits", "_masked.fits")

    if (os.path.isfile(masked)):
        os.remove(masked)
    iraf.imarith(img, "*", mask, masked)

    return masked
Exemple #38
0
def standard(namelst):
    iraf.noao()
    iraf.twodspec()
    iraf.longslit(dispaxis=2,
                  nsum=1,
                  observatory='ca',
                  extinction=extpath,
                  caldir=stdpath)
    std_fitsname = namelst[0]
    stdname, stdmag, stdmagband = standard_star_info(std_fitsname)
    wid, sep = get_band_width_sep(stdname)
    print('<<<<<the standard star is ', stdname, '>>>>>')
    print std_fitsname
    if os.path.isfile('Std'):
        print('remove file Std')
        os.remove('Std')

    iraf.standard(
        input=std_fitsname,
        output='Std',
        samestar=True,
        beam_switch=False,
        apertures='',
        bandwidth=wid,
        bandsep=sep,  # 30.0  20.0
        fnuzero=3.6800000000000E-20,
        extinction=extpath,
        caldir=stdpath,
        observatory='ca',
        interact=True,
        graphics='stdgraph',
        cursor='',
        star_name=stdname,
        airmass='',
        exptime='',
        mag=stdmag,
        magband=stdmagband,
        teff='',
        answer='yes')

    if os.path.isfile('Sens.fits'):
        print('remove file Sens.fits')
        os.remove('Sens.fits')

    iraf.sensfunc(standards='Std',
                  sensitivity='Sens',
                  extinction=extpath,
                  function='spline3',
                  order=15)

    iraf.splot('Sens')
    iraf.flpr()
Exemple #39
0
def extractComps(assignments, dorefspec=1):
    '''This task takes a dictionary 'assignments' which has keywords equal
      to the objects spectrum and value equal to the comparison spectrum
      which should be used for the object spectrum.  You could use 
      closest_time_pos() to figure this out, for example.  The apertures
      of each comp are then extracted using apall and the object's spectrum
      as a reference.  Finally, the object's headers are updated using
      the REFSPEC1 keyword (unless dorefspec=0).'''
    iraf.noao()
    iraf.imred()
    iraf.echelle()
    # First things first, we save the old paramter list.
    iraf.apall.saveParList(filename='temp.apall.par')

    # iraf.apall.unlearn()
    iraf.apall.format = 'echelle'

    # now, get the associated list of references and comps:
    stuff = assignments

    for ref in stuff.keys():
        print 'extracting %s using %s as reference' % (stuff[ref], ref)
        comp = stuff[ref]
        if iraf.imaccess(re.sub('\.fits', '.ec.fits', comp)):
            print 'Extracted comparison exists, skipping...'
        else:
            iraf.apall(input=comp,
                       references=re.sub('\.ec', '', ref),
                       interactive=0,
                       find=0,
                       recenter=0,
                       resize=0,
                       edit=0,
                       trace=0,
                       fittrace=0,
                       extract=1,
                       extras=0,
                       review=0)

        # Now, since we've used them to extract the spectra, we can assign
        # them using refspec:
        # print "now assigning reference spectrum"
        if dorefspec:
            iraf.hedit(images=ref,
                       fields='REFSPEC1',
                       value=re.sub('\.fits', '.ec', comp),
                       add=1,
                       addonly=1,
                       verify=0,
                       show=1)

    iraf.apall.setParList(ParList='temp.apall.par')
Exemple #40
0
def flatcom(input_flat='zFLAT*.fit'):
    import glob
    import os, sys
    import itertools
    import numpy as np
    from pyraf import iraf
    from astropy.io import fits
    from astropy.io import ascii
    iraf.noao()
    iraf.imred()
    iraf.ccdred()
    iraf.ccdred.setinst(instrume='camera', directo='/iraf/iraf/noao/imred/ccdred/ccddb/', query='q', review='no')
    # Filter classification
    calflat = glob.glob(input_flat)
    allfilter = []
    i=0
    for i in range(len(calflat)) :
        hdr = fits.getheader(calflat[i])
        allfilter.append(hdr['filter'])
    filterset = set(allfilter)
    infilter = list(sorted(filterset))
    i=0
    for i in range(len(infilter)) :
        print('Find images with filter of '+str(infilter[i]))
        imlist = []
        for j in range(len(calflat)) :
            hdr = fits.getheader(calflat[j])
            if hdr['filter'] == infilter[i] :
                imlist.append(calflat[j])
            else :
                pass
        print(imlist)
        imlist.sort()
        input_name = str(infilter[i])+'flat.list'
        k=0
        f=open(input_name,'w+')
        for k in range(len(imlist)) : 
            f.write(imlist[k]+'\n')
        f.close()
        output_name = input_name[:-5]+'.fits'
        #iraf.flatcombine(input='@'+input_name, output=output_name, combine='average', reject='crreject', process='no', scale='mode', ccdtype='', lsigma='3.', hsigma='3.' )
        iraf.flatcombine(input='@'+input_name, output=output_name, combine='median', reject='minmax', process='no', scale='mode', ccdtype='')
        print(output_name+' is created. Normalizing...')
        data, newhdr = fits.getdata(output_name, header=True)
        x = np.mean(data)
        nimage = data/x
        newflat_name = curdate+'_n'+str(infilter[i])+'flat.fits'
        fits.writeto(newflat_name, nimage, header=newhdr, overwrite=True)
        #os.system('/usr/bin/cp '+newflat_name+' ../')
        os.system('/usr/bin/cp '+newflat_name+' /data1/KHAO/MDFTS/red/masterflat_'+infilter[i]+'/')
    print('Normalised master flats are created.')
    iraf.imstat(images='*n?flat.fits')
def thar_ref(object_b_fn_ec, wave_ref, colour):
# Import IRAF modules:
  iraf.noao(_doprint=0)
  iraf.onedspec(_doprint=0)
#  iraf.echelle(_doprint=0)
  parList = "wavelength_calibration_refspectra.par"
  if os.path.isfile(object_b_fn_ec) == True:
    if os.path.isfile(wave_ref) == True:
      if os.path.isfile(parList) == True:
# Assign reference spectra to input object spectra using IRAF task refspectra:
        iraf.refspectra.setParList(ParList="wavelength_calibration_refspectra.par")
        iraf.refspectra(input=object_b_fn_ec, references=wave_ref)
        print ' '
        print '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
        print colour.capitalize() + ' object spectrum             '
        print '(' + str(object_b_fn_ec) + ')                      '
        print 'assigned to ' + str(colour) + ' reference spectrum '
        print '(' + str(wave_ref) + ') successfully.              ' 
        print '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
        print ' '
      else:
        print ' '
        print '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
        print 'Wavelength reference IRAF .par file                ' 
        print str(parList)
        print 'does not exist. Exiting script.                    '
        print '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
        print ' '
        print ' '
        sys.exit()
    else:
      print ' '
      print '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
      print 'ThAr reference frame                               ' 
      print str(wave_ref)
      print 'does not exist. Exiting script.                    '
      print '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
      print ' '
      print ' '
      sys.exit()
  else:
    print ' '
    print '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
    print 'Input frame                                        ' 
    print str(object_b_fn_ec)
    print 'does not exist. Exiting script.                    '
    print '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
    print ' '
    print ' '
    sys.exit()
Exemple #42
0
def wavelength_calibration(targetdir):

    """
    Does wavelength calibration.

    Writes every fit to database so make sure it's using the correct one.

    This needs to be run in object directory for database

    """

    print 'Target directory is ' + targetdir
    print 'Doing wavelength calibration...'

    if os.getcwd() != targetdir:

        print 'Warning: current working directory must be target directory!'

        return None

    iraf.noao(_doprint=0)
    iraf.onedspec(_doprint=0)

    iraf.unlearn('identify')

    iraf.identify.setParam('images','aimcomb.fits')
    iraf.identify.setParam('coordli','/home/lc585/Dropbox/IoA/WHT_Proposal_2015a/argon+xenon.dat')
    iraf.identify.setParam('niterat',1)
    iraf.identify.setParam('function','spline3')
    iraf.identify.setParam('order',3)
    iraf.identify.setParam('zwidth',200.0) #  Zoom graph width in user units
    iraf.identify.setParam('database','database')

    iraf.identify()

    # Update fits header

    print '\n' '\n' '\n'
    print 'Updating fits header...'

    iraf.hedit.setParam('images','imcomb.ms.fits')
    iraf.hedit.setParam('fields','REFSPEC1')
    iraf.hedit.setParam('value','aimcomb.fits') # should be wavelength calibrated?
    iraf.hedit.setParam('add','yes')
    iraf.hedit.setParam('verify','yes')
    iraf.hedit.setParam('show','yes')

    iraf.hedit()

    return None
Exemple #43
0
def main():
	iraf.noao()
	iraf.imred()
	iraf.ccdred()
        print '=' * 20, 'Overscan', '=' * 20
	correct_overscan('spec.lst')
	print '=' * 20, 'combine bias', '=' * 20
	combine_bias('bias.lst')
	print '=' * 20, 'correct bias', '=' * 20
	correct_bias('spec_no_bias.lst', 'bias_spec.fits')
        name = os.popen('ls object*.lst').readlines()
        name = [i.split()[0] for i in name]
        for i in name:
            ntrim_flat(i)
def fitcoord_dispersion(basenames, overwrite=False):

    print('\n#############################')
    print('Getting the dispersion map.')

    # entering the channel image directory.
    print('\t Entering the channel image directory, \"'+fi.chimagedir+'\".')
    os.chdir(fi.chimagedir)

    database='database'
    function='chebyshev'
    xorder=3
    yorder=5
    logfiles='STDOUT,fitcoord_dispersion.log'
    # for multi-comparison images
    combine = 'yes'


    # Not to display items in IRAF packages
    sys.stdout = open('/dev/null', 'w')
    iraf.noao()
    iraf.twodspec()
    iraf.longslit()
    sys.stdout = sys.__stdout__ # Back to the stadard output

    for i in range(1,25):
        fcfile = basenames[0] + '.ch%02d'%i
        if os.path.isfile(database + '/fc' + fcfile) and overwrite == False:
            print('\t FC file already exits: ' + fcfile)
        else:
            if os.path.isfile(database + '/fc' + fcfile) and overwrite == True:
                print('Removing ' + fcfile)
                try:
                    os.remove(database + '/fc' + fcfile)
                except:
                    pass
                    
            infiles = ''
            for basename in basenames:
                infiles = infiles + basename + '.ch%02d,'%i
            
            iraf.fitcoord(infiles[:len(infiles)-1], fitname=fcfile, interactive='yes', \
                    combine=combine, database=database, deletions='',\
                    function = function,xorder=xorder, yorder=yorder,\
                    logfiles=logfiles, graphics='stdgraph', cursor='')

    print('Going back to the original directory.')
    os.chdir('..')
    return
Exemple #45
0
def marksn2(img,fitstab,frame=1,fitstab2='',verbose=False):
   from pyraf import iraf
   from numpy import array   #,log10
   import lsc
   iraf.noao(_doprint=0)
   iraf.digiphot(_doprint=0)
   iraf.daophot(_doprint=0)
   iraf.images(_doprint=0)
   iraf.imcoords(_doprint=0)
   iraf.proto(_doprint=0)
   iraf.set(stdimage='imt1024')
   hdr=lsc.util.readhdr(fitstab)
   _filter=lsc.util.readkey3(hdr,'filter')
   column=lsc.lscabsphotdef.makecatalogue([fitstab])[_filter][fitstab]

   rasex=array(column['ra0'],float)
   decsex=array(column['dec0'],float)


   if fitstab2:
      hdr=lsc.util.readhdr(fitstab2)
      _filter=lsc.util.readkey3(hdr,'filter')
      _exptime=lsc.util.readkey3(hdr,'exptime')
      column=lsc.lscabsphotdef.makecatalogue([fitstab2])[_filter][fitstab2]
      rasex2=array(column['ra0'],float)
      decsex2=array(column['dec0'],float)

   iraf.set(stdimage='imt1024')
   iraf.display(img + '[0]',frame,fill=True,Stdout=1)
   vector=[]
   for i in range(0,len(rasex)):
      vector.append(str(rasex[i])+' '+str(decsex[i]))

   xy = iraf.wcsctran('STDIN',output="STDOUT",Stdin=vector,Stdout=1,image=img+'[0]',inwcs='world',units='degrees degrees',outwcs='logical',\
                         formats='%10.1f %10.1f',verbose='yes')[3:]
   iraf.tvmark(frame,'STDIN',Stdin=list(xy),mark="circle",number='yes',label='no',radii=10,nxoffse=5,nyoffse=5,color=207,txsize=2)

   if verbose:
 #     print 2.5*log10(_exptime)
      for i in range(0,len(column['ra0'])):
         print xy[i],column['ra0'][i],column['dec0'][i],column['magp3'][i],column['magp4'][i],column['smagf'][i],column['magp2'][i]

   if fitstab2:
      vector2=[]
      for i in range(0,len(rasex2)):
         vector2.append(str(rasex2[i])+' '+str(decsex2[i]))
      xy1 = iraf.wcsctran('STDIN',output="STDOUT",Stdin=vector2,Stdout=1,image=img+'[0]',inwcs='world',units='degrees degrees',outwcs='logical',\
                            formats='%10.1f %10.1f',verbose='yes')[3:]
      iraf.tvmark(frame,'STDIN',Stdin=list(xy1),mark="cross",number='yes',label='no',radii=10,nxoffse=5,nyoffse=5,color=205,txsize=2)
def gcDAR():
    iraf.noao()
    obs = iraf.noao.observatory

    # Set up Keck observatory info
    obs(command="set", obsid="keck")
    keck = ephem.Observer()
    keck.long = math.radians(-obs.longitude)
    keck.lat = math.radians(obs.latitude)
    keck.elev = obs.altitude
    keck.pressure = 800.0
    keck.temp = 278.0
    
    # Date of Observations: 06maylgs1
    keck.date = '2006/05/03 %d:%d:%f' % (obs.timezone+3, 28, 46.33)

    # Set up the galactic center target
    sgra = ephem.FixedBody()
    sgra._ra = ephem.hours("17:45:40")
    sgra._dec = ephem.degrees("-29:00:10")
    sgra._epoch = 2000
    sgra.compute()

    pos2 = ephem.FixedBody()
    pos2._ra = ephem.hours("17:45:40")
    pos2._dec = ephem.degrees("-29:00:00")
    pos2._epoch = 2000
    pos2.compute()

    print 'Date of Obs: ', keck.date
    sgra.compute(keck)
    pos2.compute(keck)

    print 'Azimuth of Objects:  %s  vs.  %s' % (sgra.az, pos2.az)

    for ii in range(15):
	keck.lat = math.radians(obs.latitude - (ii*2))

	sgra.compute(keck)
	pos2.compute(keck)

	angAbs = ephem.separation((sgra.ra, sgra.dec), (pos2.ra, pos2.dec))
	angAbs *= 206265.0
	angRel = ephem.separation((sgra.az, sgra.alt), (pos2.az, pos2.alt))
	angRel *= 206265.0
	angDiff = angAbs - angRel

	print 'Sgr A*:  %s   vs.  %s  deltaR = %5d (muas)' % \
	    (sgra.alt, pos2.alt, angDiff*1e6)
Exemple #47
0
def gcDAR():
    iraf.noao()
    obs = iraf.noao.observatory

    # Set up Keck observatory info
    obs(command="set", obsid="keck")
    keck = ephem.Observer()
    keck.long = math.radians(-obs.longitude)
    keck.lat = math.radians(obs.latitude)
    keck.elev = obs.altitude
    keck.pressure = 800.0
    keck.temp = 278.0

    # Date of Observations: 06maylgs1
    keck.date = '2006/05/03 %d:%d:%f' % (obs.timezone + 3, 28, 46.33)

    # Set up the galactic center target
    sgra = ephem.FixedBody()
    sgra._ra = ephem.hours("17:45:40")
    sgra._dec = ephem.degrees("-29:00:10")
    sgra._epoch = 2000
    sgra.compute()

    pos2 = ephem.FixedBody()
    pos2._ra = ephem.hours("17:45:40")
    pos2._dec = ephem.degrees("-29:00:00")
    pos2._epoch = 2000
    pos2.compute()

    print 'Date of Obs: ', keck.date
    sgra.compute(keck)
    pos2.compute(keck)

    print 'Azimuth of Objects:  %s  vs.  %s' % (sgra.az, pos2.az)

    for ii in range(15):
        keck.lat = math.radians(obs.latitude - (ii * 2))

        sgra.compute(keck)
        pos2.compute(keck)

        angAbs = ephem.separation((sgra.ra, sgra.dec), (pos2.ra, pos2.dec))
        angAbs *= 206265.0
        angRel = ephem.separation((sgra.az, sgra.alt), (pos2.az, pos2.alt))
        angRel *= 206265.0
        angDiff = angAbs - angRel

        print 'Sgr A*:  %s   vs.  %s  deltaR = %5d (muas)' % \
            (sgra.alt, pos2.alt, angDiff*1e6)
Exemple #48
0
def apall(lstfile):
    iraf.noao()
    iraf.twodspec()
    iraf.apextract(dispaxis = 2, database = 'database')
    f = open(lstfile)
    l = f.readlines()
    f.close()
    l = [tmp.split('\n')[0] for tmp in l]
    path = os.getcwd()
    for i in l:
        infile = 'wftbo' + i
        outfile = 'awftbo' + i
        while True:
            if os.path.isfile(outfile):
                print('remove ' + outfile)
                os.remove(outfile)
            delfile = path + os.sep + 'database/ap' + infile[0:-5]
            if os.path.isfile(delfile):
                print('remove ' + delfile)
                os.remove(delfile)
            iraf.apall(input = infile
                , output = outfile, apertures = 2, format = 'multispec'
                , references = '', profiles = '', interactive = True
                , find = True, recenter = True, resize = False
                , edit = True, trace = True, fittrace = True
                , extract = True, extras = True, review = True
                , line = 'INDEF', nsum = 10, lower = -15.0
                , upper = 15.0, apidtable = '', b_function = 'chebyshev'
                , b_order = 2, b_sample = '-50:-26,26:50', b_naverage = -25
                , b_niterate = 1, b_low_reject = 3.0, b_high_reject = 3.0
                , b_grow = 0.0, width = 5.0, radius = 10.0
                , threshold = 0.0, nfind = 2, minsep = 5.0
                , maxsep = 100000.0, order = 'increasing', aprecenter = ''
                , npeaks = 'INDEF', shift = True, llimit ='INDEF'
                , ulimit = 'INDEF', ylevel = 0.1, peak = True
                , bkg = True, r_grow = 0.0, avglimits = False
                , t_nsum = 20, t_step = 10, t_nlost = 3, t_function = 'legendre'
                , t_order = 7, t_sample = '*', t_naverage = 1
                , t_niterate = 1, t_low_reject = 3.0, t_high_reject = 3.0
                , t_grow = 0.0, background = 'fit', skybox = 1
                , weights = 'variance', pfit = 'fit1d', clean = True
                , saturation = 'INDEF', readnoise = 9.4, gain = 0.35
                , lsigma = 4.0, usigma = 4.0, nsubaps = 1)
            iraf.flpr()
            sspecplot.sspecplot(outfile)
            getval = raw_input('Are you need repeat apall,may be clean should be close(r/n)')
            if getval != 'r':
                break
Exemple #49
0
def fwhm(directory,folders):
  iraf.noao(_doprint=0)
  iraf.obsutil(_doprint=0)
  iraf.unlearn("psfmeasure")
  
  rootdir = par.rootdir[0]
  
  dir_contents = os.listdir(directory+'/data')
  ds9s = [fn for fn in dir_contents if fn.startswith('ds9') and fn.endswith('.reg')]
  ds9 = directory+'/data/'+ds9s[0]

  print "\nMeasuring the fwhm of selected reference stars..."
  iraf.noao.obsutil.psfmeasure.coords = "mark1"
  iraf.noao.obsutil.psfmeasure.display = "no"
  iraf.noao.obsutil.psfmeasure.size = "FWHM"
  iraf.noao.obsutil.psfmeasure.scale = "1"
  iraf.noao.obsutil.psfmeasure.radius = "11"
  iraf.noao.obsutil.psfmeasure.swidth = "15"
  iraf.noao.obsutil.psfmeasure.iterati = "1"
  iraf.noao.obsutil.psfmeasure.imagecu = ds9
  iraf.noao.obsutil.psfmeasure.graphcur = rootdir+"/src/q.reg"
  iraf.noao.obsutil.psfmeasure.logfile = directory+"/data/fwhm.log"

  if os.path.isfile(directory+"/data/fwhm.log"):
    os.system("rm "+directory+"/data/fwhm.log")
    
  imgs = [fn for fn in dir_contents if fn.startswith(par.image_name[0]) and fn.endswith(par.image_name[1])]
  imgs = sorted(imgs)

  for i in range(len(imgs)):
    iraf.noao.obsutil.psfmeasure.imagecu = ds9
    iraf.noao.obsutil.psfmeasure(directory+'/data/'+imgs[i])
  
  N_stars = len(ds9)
  fwhm = [[] for _ in range(len(imgs))]
  values = [ line for line in open(directory+"/data/fwhm.log") if '.' in line and 'NOAO' not in line]
  j = 0
  for i in range(len(values)):
    if values[i][2:9] == 'Average':
      j += 1
    if values[i][2:9] != 'Average': 
      fwhm[j].append(float(values[i][41:47]))

  f = open(directory+'/data/fwhm.txt', 'w+')
  for i in range(len(imgs)):
    fwhm[i] = np.array(fwhm[i])
    print >> f, np.median(fwhm[i]), imgs[i]
  f.close()
Exemple #50
0
def main():

    config = {'combine': 'average', 'reject': 'minmax', 'nlow': 3, 'nhigh': 3}

    path = '/btfidr/data/20130902/007/cam2'
    kernel = 'biasEMOFF_A*'
    list_of_files = glob.glob(os.path.join(path, kernel))
    random.shuffle(list_of_files)
    number_of_files = len(list_of_files)

    iraf.noao(_doprint=0)
    iraf.imred(_doprint=0)
    iraf.ccdred(_doprint=0)

    n, a, s = [], [], []
    for l in range(2, number_of_files):

        temp_list = 'list'
        buffer = open(temp_list, mode='w')
        for i in range(l):
            buffer.write(list_of_files[i] + "\n")
        buffer.close()

        iraf.imcombine(input='@' + temp_list,
                       output='temp_output.fits',
                       **config)

        data = pyfits.getdata('temp_output.fits')[700:899, 700:899]

        n.append(l)
        a.append(np.average(data))
        s.append(np.std(data))

        os.remove('temp_output.fits')
        os.remove(temp_list)

    output = 'output.dat'
    buffer = open(output, mode='w')

    for key in config.keys():
        buffer.write('# {}: {}\n'.format(key, config[key]))

    buffer.write('# N\tAVG\tSTD\n')
    for i in range(len(n)):
        buffer.write(u'{0:3d}\t{1:5.1f}\t{2:5.1f}\n'.format(n[i], a[i], s[i]))

    buffer.close()
    return 0
Exemple #51
0
def findaperture(img, _interactive=False):
    # print "LOGX:: Entering `findaperture` method/function in %(__file__)s" %
    # globals()
    import re
    import string
    import os
    from pyraf import iraf
    import ntt
    iraf.noao(_doprint=0, Stdout=0)
    iraf.imred(_doprint=0, Stdout=0)
    iraf.specred(_doprint=0, Stdout=0)
    toforget = ['specred.apfind']
    for t in toforget:
        iraf.unlearn(t)

    iraf.specred.databas = 'database'
    iraf.specred.dispaxi = 2
    iraf.specred.apedit.thresho = 0

    dv = ntt.dvex()
    grism = ntt.util.readkey3(ntt.util.readhdr(img), 'grism')
    if _interactive:
        _interac = 'yes'
        _edit = 'yes'
    else:
        _interac = 'no'
        _edit = 'no'
    if os.path.isfile('database/ap' + re.sub('.fits', '', img)):
        ntt.util.delete('database/ap' + re.sub('.fits', '', img))
    xx = iraf.specred.apfind(img,
                             interac=_interac,
                             find='yes',
                             recenter='yes',
                             edit=_edit,
                             resize='no',
                             aperture=1,
                             Stdout=1,
                             nfind=1,
                             line=dv['line'][grism],
                             nsum=50,
                             mode='h')
    try:
        for line in open('database/ap' + re.sub('.fits', '', img)):
            if "center" in line:
                center = float(string.split(line)[1])
    except:
        center = 9999
    return center
Exemple #52
0
def ImportPackages():
	iraf.noao(_doprint=0)
	iraf.rv(_doprint=0)
	iraf.imred(_doprint=0)
	iraf.kpnoslit(_doprint=0)	
	iraf.ccdred(_doprint=0)
	iraf.astutil(_doprint=0)
	
	iraf.keywpars.setParam('ra','CAT-RA') 
	iraf.keywpars.setParam('dec','CAT-DEC')
	iraf.keywpars.setParam('ut','UT')
	iraf.keywpars.setParam('utmiddl','UT-M_E')
	iraf.keywpars.setParam('exptime','EXPTIME')
	iraf.keywpars.setParam('epoch','CAT-EPOC')
	iraf.keywpars.setParam('date_ob','DATE-OBS')
	iraf.keywpars.setParam('hjd','HJD')
	iraf.keywpars.setParam('mjd_obs','MJD-OBS')
	iraf.keywpars.setParam('vobs','VOBS')
	iraf.keywpars.setParam('vrel','VREL')
	iraf.keywpars.setParam('vhelio','VHELIO')
	iraf.keywpars.setParam('vlsr','VLSR')
	iraf.keywpars.setParam('vsun','VSUN')
	iraf.keywpars.setParam('mode','ql')
	iraf.fxcor.setParam('continu','both')
	iraf.fxcor.setParam('filter','none')
	iraf.fxcor.setParam('rebin','smallest')
	iraf.fxcor.setParam('pixcorr','no')
	iraf.fxcor.setParam('apodize','0.2')
	iraf.fxcor.setParam('function','gaussian')
	iraf.fxcor.setParam('width','INDEF')
	iraf.fxcor.setParam('height','0.')
	iraf.fxcor.setParam('peak','no')
	iraf.fxcor.setParam('minwidt','3.')
	iraf.fxcor.setParam('maxwidt','21.')
	iraf.fxcor.setParam('weights','1.')
	iraf.fxcor.setParam('backgro','0.')
	iraf.fxcor.setParam('window','INDEF')
	iraf.fxcor.setParam('wincent','INDEF')
	iraf.fxcor.setParam('verbose','long')
	iraf.fxcor.setParam('imupdat','no')
	iraf.fxcor.setParam('graphic','stdgraph')
	iraf.fxcor.setParam('interac','yes')
	iraf.fxcor.setParam('autowri','yes')
	iraf.fxcor.setParam('autodra','yes')
	iraf.fxcor.setParam('ccftype','image')
	iraf.fxcor.setParam('observa','lapalma')
	iraf.fxcor.setParam('mode','ql')
	return 0
Exemple #53
0
    def ReidentifyTask(self, ArcFile, Fits_Folder, ):

        iraf.noao(_doprint=0)
        iraf.twodspec(_doprint=0)         
        iraf.longslit(_doprint=0)
        
        ReidentifyConf = self.ReidentifyAttributes(ArcFile, Fits_Folder)

        #Display the equivalent command in IRAF
        Command = self.printIrafCommand('reidentify', ReidentifyConf)
        print '--- Using the command'
        print Command
        
        iraf.twodspec.longslit.reidentify(**ReidentifyConf)

        return
Exemple #54
0
    def FitcoordsTask(self, ArcFile, Fits_Folder):

        iraf.noao(_doprint=0)
        iraf.twodspec(_doprint=0)         
        iraf.longslit(_doprint=0)
        
        FitcoordsConf = self.FitcoordsAttributes(ArcFile, Fits_Folder)

        #Display the equivalent command in IRAF
        Command = self.printIrafCommand('fitcords', FitcoordsConf)
        print '--- Using the command'
        print Command
        
        iraf.twodspec.longslit.fitcoords(**FitcoordsConf)

        return
Exemple #55
0
def set_instrument():

    """
    Needed so that when we do flatcombine iraf doesn't try to do flat correction
    etc. Might need to run before calling any other function. Not sure if specphot
    is appropriate but seems to work.
    """

    iraf.noao(_doprint=0)
    iraf.imred(_doprint=0)
    iraf.ccdred(_doprint=0)

    iraf.setinstrument.setParam('instrument','specphot')
    iraf.setinstrument()

    return None
Exemple #56
0
    def inspect(self, event):
    # Pull up the current TDSS spectrum in IRAF SPLOT
    ####
        global TDSS_fiber_indices, TDSS_fiber_index
        global plate, mjd 

	# load packages; splot is in the onedspec package, which is in noao.
    	# the special keyword _doprint=0 turns off displaying the tasks
    	# when loading a package.
    	iraf.noao(_doprint=0)
    	iraf.onedspec(_doprint=0) 

    	# set/view IRAF task parameter.
    	#iraf.onedspec.splot.save_file = "splot_%s.log" % (root,)

    	# call IRAF task, and specify some parameters.
	iraf.onedspec.splot('spPlate-'+str(plate)+'-'+str(mjd)+'.fits[0][*,'+str(TDSS_fiber_index+1)+']')
Exemple #57
0
def atmofile(imgstd, imgout=''):
    # print "LOGX:: Entering `atmofile` method/function in %(__file__)s" %
    # globals()
    from pyraf import iraf
    import os
    import ntt

    iraf.noao(_doprint=0)
    iraf.onedspec(_doprint=0)
    iraf.set(direc=ntt.__path__[0] + '/')
    _cursor = 'direc$standard/ident/cursor_sky_0'
    if not imgout:
        imgout = 'atmo_' + imgstd
    os.system('rm -rf ' + imgout)
    iraf.noao.onedspec.bplot(imgstd, cursor=_cursor,
                             spec2=imgstd, new_ima=imgout, overwri='yes')
    return imgout
Exemple #58
0
def createMagFile(inputDir, inputFile, useCoordFile, outputFile, fullyAutomatic=False, aperturesString='5,10,15,20', bestSkyAperture='100'):	
	cr=['\n']
	iraf.cd(inputDir)
	iraf.noao()
	iraf.digiphot()
	iraf.apphot()
	iraf.phot.setParam('interactive','no')
	iraf.centerpars.setParam('cbox','5')
	iraf.photpars.setParam('apertures',aperturesString)
	iraf.fitskypars.setParam('annulus',bestSkyAperture)
	iraf.fitskypars.setParam('dannulus','10')
	iraf.phot.setParam('image',inputFile)
	iraf.phot.setParam('coords',useCoordFile)
	iraf.phot.setParam('output',outputFile)
	if fullyAutomatic: ## If you use this option, it will not prompt you for any of the aperture/sky settings
		iraf.phot(mode='h',Stdin=cr)
	else: # Otherwise, you can change them at will, and get to press enter a bunch
		iraf.phot(mode='h')
Exemple #59
0
def calibrate(lstfile):
    stdpath = os.path.split(os.path.realpath(__file__))[0] + os.sep + 'standarddir' + os.sep
    extpath = os.path.split(os.path.realpath(__file__))[0] + os.sep + 'LJextinct.dat'
    iraf.noao()
    iraf.twodspec()
    iraf.longslit(dispaxis = 2, nsum = 1, observatory = 'Lijiang', 
        extinction = extpath, caldir = stdpath)
    f = open(lstfile)
    l = f.readlines()
    f.close()
    l = [tmp.split('\n')[0] for tmp in l]
    for fitname in l:
        stdobjname = select_std(fitname)
        stdfitname = 'sensawftbo' + stdgroup[stdobjname][0]
        iraf.calibrate(input = 'awftbo'+ fitname, output = 'mark_awftbo' + fitname, 
            extinct = 'yes', flux = 'yes', extinction = extpath, 
            ignoreaps = 'yes', sensitivity = stdfitname, fnu = 'no')
        iraf.splot(images = 'mark_awftbo' + fitname)
Exemple #60
0
def coroverscan(filename):
    iraf.noao()
    iraf.imred()
    iraf.ccdred()
    iraf.ccdproc(images = '@' + filename + '//[1]'
    	, output = '%o%o%@' + filename
	, ccdtype = '', max_cache = 0, noproc = False
	, fixpix = False, overscan = True, trim = False
	, zerocor = False, darkcor = False, flatcor = False
	, illumcor = False, fringecor = False, readcor = False
	, scancor = False, readaxis = 'line', fixfile = ''
	, biassec = '[5:45,1:4612]', trimsec = '', zero = ''
	, dark = '', flat = '', illum = '', fringe = ''
	, minreplace = 1.0, scantype = 'shortscan', nscan = 1
	, interactive = False, function = 'chebyshev', order = 1
	, sample = '*', naverage = 1, niterate = 1
	, low_reject = 3.0, high_reject = 3.0, grow = 1.0)
    iraf.flpr()