コード例 #1
0
ファイル: spectra_reduc.py プロジェクト: rajin/rajin_code
def lacosmic(name, irafhome, la_iter):
    import time

    iraf.task(lacos_spec=irafhome + "lacos_spec.cl")
    outname = "la" + name
    pl = "mask" + name
    iraf.lacos_spec(
        input=name,
        output=outname,
        outmask=pl,
        gain=1.0,
        readn=2.89,
        xorder=9,
        yorder=0,
        sigclip=4.5,
        sigfrac=0.5,
        objlim=1.0,
        niter=la_iter,
        verbose="yes",
        mode="al",
    )
    old = time.time()
    pidds9 = subprocess.Popen(["ds9", pl, outname, "-zscale"]).pid
    os.system("mv %s history/" % (name))
    return pidds9
コード例 #2
0
ファイル: SCRIPT.py プロジェクト: dafh/stuff
def cosmic_rays (List_image):
    full_path = List_image
    path = os.path.dirname(full_path)
    List_image = full_path.replace(path + '/','')
    os.chdir(path)
    iraf.chdir(path)

    image_list = open(List_image,'r')
    image_out = open('c'+List_image,'w')
    for line in image_list:
        line = line.split('\n')
        print 'Cosmic rays removal: ' + line[0]
        hdulist = fits.open(line[0])
        #print hdulist[0].header['HIERARCH ESO DET OUT1 RON']
        iraf.lacos_spec.input =  line[0]
        iraf.lacos_spec.output = 'c' + line[0]
        if os.path.isfile('c' + line[0]):
           os.system('rm c'+line[0])
        if os.path.isfile('mask_'+line[0]):
           os.system('rm mask_'+line[0])
        iraf.lacos_spec.outmask= 'mask_'+line[0]
        iraf.lacos_spec.readn= hdulist[0].header['HIERARCH ESO DET OUT1 RON']
        iraf.lacos_spec.gain = hdulist[0].header['HIERARCH ESO DET OUT1 GAIN']
        iraf.lacos_spec.verbose = 'no'
        iraf.lacos_spec(mode='h')
        os.system('rm mask_'+line[0])
        image_out.write('c'+line[0]+'\n')
        hdulist.close()
    image_list.close()
    image_out.close()
コード例 #3
0
def lacosmic(name,irafhome):
	import time
	iraf.task(lacos_spec=irafhome+'lacos_spec.cl')
	outname = 'la'+name
	pl = 'mask'+name
	iraf.lacos_spec(input=name,output=outname,outmask=pl,gain=1.,readn=2.89,
				xorder=9,yorder=0,sigclip=4.5,sigfrac=0.5,objlim=1.,niter=7,verbose='yes',mode='al')
	old = time.time()
	os.system('ds9 %s -zscale %s -zscale -blink &' % (pl,name))
	os.system('ds9 %s -zscale &' % outname)
	return
コード例 #4
0
def call_lacos(args, science, Nslits=0, longslit=False):
    outfile = '{0}_lacos.fits'.format(science)
    #if os.path.isfile(outfile):
        #os.remove(outfile)
    if utils.skip(args, 'lacos', outfile):
        return outfile[:-5]
    print()
    print('-' * 30)
    print()
    print('Removing cosmic rays with LACos ...')
    to = time()
    head = pyfits.getheader(science + '.fits')
    gain = head['GAIN']
    rdnoise = head['RDNOISE']
    #utils.delete(outfile)
    if os.path.isfile(outfile):
        iraf.imdelete(outfile)
    os.system('cp  -p ' + science + '.fits ' +  outfile)
    utils.removedir('slits')
    utils.makedir('slits')
    iraf.imcopy.unlearn()
    if longslit:
        slit = '{0}[sci,1]'.format(science)
        outslit = os.path.join('slits' '{0}_long'.format(science))
        outmask = os.path.join('slits' '{0}_longmask'.format(science))
        iraf.lacos_spec(slit, outslit, outmask, gain=gain, readn=rdnoise)
        iraf.imcopy(outslit, '{0}[SCI,1,overwrite]'.format(outfile[:-5]),
                    verbose='no')
    else:
        for i in xrange(1, Nslits+1):
            slit = '{0}[sci,{1}]'.format(science, i)
            print('slit =', slit)
            outslit = os.path.join('slits', '{0}_{1}'.format(science, i))
            outmask = os.path.join('slits', '{0}_mask{1}'.format(science, i))
            if os.path.isfile(outslit):
                iraf.imdelete(outslit)
            if os.path.isfile(outmask):
                iraf.imdelete(outmask)
            iraf.lacos_spec(slit, outslit, outmask, gain=gain, readn=rdnoise)
            iraf.imcopy(
                outslit, '{0}[SCI,{1},overwrite]'.format(outfile[:-5], i),
                verbose='yes')
    utils.delete('lacos*')
    utils.removedir('slits')
    print(outfile[:-5])
    print('Done in {0:.2f}'.format((time()-to)/60))
    print()
    print('-' * 30)
    print()
    return outfile[:-5]
コード例 #5
0
ファイル: SCRIPT.py プロジェクト: dafh/stuff
def single_cosmic (image):
    hdulist = fits.open(image)
    iraf.lacos_spec.input =  image
    iraf.lacos_spec.output = 'c' + image
    if os.path.isfile('c' + image):
       os.system('rm c'+image)
    if os.path.isfile('mask_'+image):
       os.system('rm mask_'+image)
    iraf.lacos_spec.outmask= 'mask_'+image
    iraf.lacos_spec.readn= hdulist[0].header['HIERARCH ESO DET OUT1 RON']
    iraf.lacos_spec.gain = hdulist[0].header['HIERARCH ESO DET OUT1 GAIN']
    iraf.lacos_spec.verbose = 'no'
    iraf.lacos_spec(mode='h')
    os.system('rm mask_'+ image)
    hdulist.close()
    return 'c' + image
コード例 #6
0
ファイル: spectra_reduc.py プロジェクト: rajin/rajin_code
def lacosmic(name, irafhome, la_iter):
    import time
    iraf.task(lacos_spec=irafhome + 'lacos_spec.cl')
    outname = 'la' + name
    pl = 'mask' + name
    iraf.lacos_spec(input=name,
                    output=outname,
                    outmask=pl,
                    gain=1.,
                    readn=2.89,
                    xorder=9,
                    yorder=0,
                    sigclip=4.5,
                    sigfrac=0.5,
                    objlim=1.,
                    niter=la_iter,
                    verbose='yes',
                    mode='al')
    old = time.time()
    pidds9 = subprocess.Popen(['ds9', pl, outname, '-zscale']).pid
    os.system('mv %s history/' % (name))
    return pidds9
コード例 #7
0
ptfsn2 = 'ptfsn2.fits'
ptfstar1 = 'ptfstar1.fits'
ptfstar2 = 'ptfstar2.fits'

#Cosmic Cleaned Version
ptfsn1cr = 'ptfsn1.cr'
ptfsn2cr = 'ptfsn2.cr'

#Cosmic Rejection
iraf.lacos_spec(input=ptfsn1,
                output=ptfsn1cr,
                outmask='ptfsn1.crmask',
                gain=1.0,
                readn=3.85,
                xorder=9,
                yorder=3,
                sigclip=4.5,
                sigfrac=0.5,
                objlim=1.0,
                niter=3,
                verbose=yes,
                mode='al')

iraf.lacos_spec(input=ptfsn2,
                output=ptfsn2cr,
                outmask='ptfsn2.crmask',
                gain=1.0,
                readn=3.85,
                xorder=9,
                yorder=3,
                sigclip=4.5,
コード例 #8
0
	print "Exiting!! CANT process files while output files already exist, delete these then re-run"        

## starting to process files
if outfile == 'false':
	print "Files to process: ", i 

	##EPAR settings for LACOS.SPEC
	iraf.lacos_spec.gain = 1.2
	iraf.lacos_spec.readn = 4.2
	iraf.lacos_spec.xorder = 3.0
	iraf.lacos_spec.yorder = 3.0
	iraf.lacos_spec.sigclip = 3.9
	iraf.lacos_spec.sigfrac = 2.0
	iraf.lacos_spec.objlim = 1.0
	iraf.lacos_spec.niter = 4
	iraf.lacos_spec.verbose = "n"
		
	#processing LACOS on each file
	start = time.time()
	n=0
	while n < i:
  		print "workin on file", inlist[n], "(", n+1, ")"
  		iraf.lacos_spec(inlist[n], outlist[n], 'temp.pl')
  		n +=1
  		os.remove('temp.pl')
  		time.sleep(5) #Needed as LACOS was slow at deleting LACOS files when it finishes
       
	end = time.time()
	print "Run Time: ", end - start
		
print 'Program finished'