Beispiel #1
0
def cleandata(filename, iminfo=None, prodir='.', interp='linear', cleanup=True, clobber=False, logfile='saltclean.log', display_image=False, verbose=True):
   """Start the process to reduce the data and produce a single mosaicked image"""
   print filename
   status=0
   #create the input file name
   infile=os.path.basename(filename)
   rawpath=os.path.dirname(filename)
   outpath='./'
   outfile=outpath+'mbxp'+infile
   print infile, rawpath, outpath

   #check to see if the data have detmode
   if iminfo is not None:
      detmode=iminfo[headerList.index('DETMODE')].strip().upper()
      print 'DETMODE:' detmode

   #If it is a bin file, pre-process the data
   if filename.count('.bin'):
       print "I can't handle this yet"


   #check to see if it exists and return if clobber is no
   if os.path.isfile(outfile) and not clobber: return

   #set up the files needed
   if infile[0]=='P':
     gaindb = '/iraf/extern/pysalt/data/rss/RSSamps.dat'
     xtalkfile = '/iraf/extern/pysalt/data/rss/RSSxtalk.dat'
     geomfile = '/iraf/extern/pysalt/data/rss/RSSgeom.dat'
     usedb=True
   elif infile[0]=='S':
     gaindb = '/iraf/extern/pysalt/data/scam/SALTICAMamps.dat'
     xtalkfile = '/iraf/extern/pysalt/data/scam/SALTICAMxtalk.dat'
     geomfile = '/iraf/extern/pysalt/data/scam/SALTICAMgeom.dat'
 
   #verify the file
   hdu=saltio.openfits(rawpath+'/'+infile)
   hdu.verify('exception')
   

   #reduce the file
   saltred.saltprepare(images=infile,rawpath=rawpath,outimages='',outpref=outpath+'p',  \
                    clobber=clobber,logfile=logfile,verbose=verbose,status=status)
   pinfile=outpath+'p'+infile
   saltred.saltslot(images=pinfile,outimages='',outpref=outpath+'bx',gaindb=gaindb,
                 xtalkfile=xtalkfile,usedb=True, clobber=clobber,logfile=logfile,verbose=verbose,
                 status=status)
   biasfile=outpath+'bxp'+infile
   saltred.saltmosaic(images=biasfile,
                   outimages='',outpref=outpath+'m',geomfile=geomfile,
                   interp=interp,cleanup=cleanup,fill=True, clobber=clobber,logfile=logfile,
                   verbose=verbose, status=status)
   profile=outpath+'mbxp'+infile

   #remove intermediate steps
   if cleanup:
      if os.path.isfile(pinfile): os.remove(pinfile)
      if os.path.isfile(biasfile): os.remove(biasfile)

       i=headerList.index('CCDSUM')
       ccdbin=int(iminfo[i].split()[0])
       pix_scale=0.14
       r_ap=1.5/(pix_scale*ccdbin)
       print pix_scale, ccdbin, r_ap

       profile=outpath+'mbxp'+infile
       outcat=profile.split('.fits')[0]+'.cat'
       sexfile='/home/ccd/tools/qred.sex'
       backfile = profile.strip().strip('.fits')+'_back.fits'
       cmd='sex %s -c %s -PIXEL_SCALE %f -CATALOG_NAME %s -PHOT_APERTURES %f ' % (profile.strip(),sexfile, pix_scale,outcat,r_ap)
       print "SALTFIRST--Performing photometry on %s" % profile
       if os.path.isfile(sexfile): os.system(cmd)
Beispiel #2
0
def quickclean(filename, interp='linear', cleanup=True, clobber=False, logfile='saltclean.log', verbose=True):
   """Start the process to reduce the data and produce a single mosaicked image"""
   print filename

   #create the input file name
   status=0
   infile=os.path.basename(filename)
   rawpath=os.path.dirname(filename)
   outpath='./'
   outfile=outpath+'mbxp'+infile
   print infile, rawpath, outpath

   #check to see if it exists and return if clobber is no
   if os.path.isfile(outfile) and not clobber: return

   #set up the files needed
   if infile[0]=='P':
     gaindb = iraf.osfn('pysalt$data/rss/RSSamps.dat')
     xtalkfile = iraf.osfn('pysalt$data/rss/RSSxtalk.dat')
     geomfile = iraf.osfn('pysalt$data/rss/RSSgeom.dat')
   elif infile[0]=='S':
     gaindb = iraf.osfn('pysalt$data/scam/SALTICAMamps.dat')
     xtalkfile = iraf.osfn('pysalt$data/scam/SALTICAMxtalk.dat')
     geomfile = iraf.osfn('pysalt$data/scam/SALTICAMgeom.dat')
 
   #verify the file
   hdu=saltio.openfits(rawpath+'/'+infile)
   hdu.verify('exception')
   
   #check to see if detmode is there
   if not saltkey.found('DETMODE', hdu[0]): 
      return 
 
   #reduce the file
   saltred.saltprepare(images=filename,outimages='',outpref=outpath+'p',  \
                    createvar=False, badpixelimage=None, clobber=clobber,logfile=logfile,verbose=verbose)
   pinfile=outpath+'p'+infile
   saltred.saltgain(pinfile, outimages=pinfile, outpref='', gaindb=gaindb,usedb=False, 
                    mult=True,clobber=True, logfile=logfile, verbose=verbose)
   saltred.saltxtalk(pinfile,outimages='',outpref='x',xtalkfile=xtalkfile,clobber=clobber,
                     logfile=logfile,verbose=verbose)
   #saltred.saltslot(images=pinfile,outimages='',outpref=outpath+'bx',gaindb=gaindb,
   #              xtalkfile=xtalkfile,clobber=clobber,logfile=logfile,verbose=verbose,
   #              status=0)
   xinfile=outpath+'xp'+infile
   saltred.saltbias(images=xinfile,outimages='',outpref='b',subover=True,trim=True,subbias=False, 
                    masterbias='', median=False,function='polynomial',order=5,rej_lo=3,rej_hi=3,niter=10,
                    plotover=False,turbo=False,logfile=logfile, clobber=clobber, verbose=verbose)
   biasfile=outpath+'bxp'+infile

   if hdu[0].header['CCDTYPE']=='OBJECT' and hdu[0].header['EXPTIME']>90:
       saltcrclean(images=biasfile, outimages=biasfile, outpref='', crtype='median',thresh=5,mbox=5,         \
                bthresh=3, flux_ratio=0.2, bbox=25, gain=1, rdnoise=5, fthresh=5,\
                bfactor=2, gbox=0, maxiter=5, multithread=True, clobber=True,          \
                logfile='salt.log', verbose=True)

   saltred.saltmosaic(images=biasfile,
                   outimages='',outpref=outpath+'m',geomfile=geomfile,
                   interp=interp,cleanup=cleanup,clobber=clobber,logfile=logfile,
                   verbose=verbose)
   profile=outpath+'mbxp'+infile

   #remove intermediate steps
   if cleanup:
      if os.path.isfile(pinfile): os.remove(pinfile)
      if os.path.isfile(xinfile): os.remove(xinfile)
      if os.path.isfile(biasfile): os.remove(biasfile)

   return
Beispiel #3
0
def quickclean(filename, interp='linear', cleanup=True, clobber=False, logfile='saltclean.log', verbose=True):
   """Start the process to reduce the data and produce a single mosaicked image"""
   print filename

   #create the input file name
   status=0
   infile=os.path.basename(filename)
   rawpath=os.path.dirname(filename)
   outpath='./'
   outfile=outpath+'mbxp'+infile
   print infile, rawpath, outpath

   #check to see if it exists and return if clobber is no
   if os.path.isfile(outfile) and not clobber: return

   #set up the files needed
   if infile[0]=='P':
     gaindb = iraf.osfn('pysalt$data/rss/RSSamps.dat')
     xtalkfile = iraf.osfn('pysalt$data/rss/RSSxtalk.dat')
     geomfile = iraf.osfn('pysalt$data/rss/RSSgeom.dat')
   elif infile[0]=='S':
     gaindb = iraf.osfn('pysalt$data/scam/SALTICAMamps.dat')
     xtalkfile = iraf.osfn('pysalt$data/scam/SALTICAMxtalk.dat')
     geomfile = iraf.osfn('pysalt$data/scam/SALTICAMgeom.dat')
 
   #verify the file
   struct=saltio.openfits(rawpath+'/'+infile)
   struct.verify('exception')
   
   #check to see if detmode is there
   if not saltkey.found('DETMODE', struct[0]): 
      return 
 
   #reduce the file
   struct=prepare(struct, createvar=False, badpixelstruct=None)
 
      #reset the names in the structures
   for i in range(1,len(struct)):
       struct[i].name=struct[i].header['EXTNAME']


   #gain correct the files
   usedb=True
   dblist= saltio.readgaindb(gaindb)
   log=open(logfile, 'a')
   ampccd = struct[0].header['NAMPS'] / struct[0].header['NCCDS']
   struct=gain(struct, mult=True,usedb=usedb, dblist=dblist, ampccd=ampccd, log=None, verbose=verbose)

   struct=bias(struct, subover=True,trim=True,subbias=False, 
                    median=False,function='polynomial',order=5,rej_lo=3,rej_hi=3,niter=10,
                    plotover=False,log=None, verbose=verbose)

   if struct[0].header['CCDTYPE']=='OBJECT' and struct[0].header['EXPTIME']>90:
      struct = multicrclean(struct, crtype='median', thresh=5, mbox=5, bbox=25, bthresh=5, flux_ratio=0.2, \
                          gain=1, rdnoise=5, bfactor=2, fthresh=5, gbox=0, maxiter=5, log=None, verbose=verbose)

   pinfile=outpath+'bxp'+infile
   saltio.writefits(struct, pinfile, clobber)

   saltred.saltmosaic(images=pinfile,
                   outimages='',outpref=outpath+'m',geomfile=geomfile, fill=True,
                   interp=interp,cleanup=cleanup,clobber=clobber,logfile=logfile,
                   verbose=verbose)
   profile=outpath+'mbxp'+infile

   #remove intermediate steps
   if cleanup:
      if os.path.isfile(pinfile): os.remove(pinfile)

   return
Beispiel #4
0
def quickclean(filename,
               interp='linear',
               cleanup=True,
               clobber=False,
               logfile='saltclean.log',
               verbose=True):
    """Start the process to reduce the data and produce a single mosaicked image"""
    print filename

    #create the input file name
    status = 0
    infile = os.path.basename(filename)
    rawpath = os.path.dirname(filename)
    outpath = './'
    outfile = outpath + 'mbxp' + infile
    print infile, rawpath, outpath

    #check to see if it exists and return if clobber is no
    if os.path.isfile(outfile) and not clobber: return

    #set up the files needed
    if infile[0] == 'P':
        gaindb = iraf.osfn('pysalt$data/rss/RSSamps.dat')
        xtalkfile = iraf.osfn('pysalt$data/rss/RSSxtalk.dat')
        geomfile = iraf.osfn('pysalt$data/rss/RSSgeom.dat')
    elif infile[0] == 'S':
        gaindb = iraf.osfn('pysalt$data/scam/SALTICAMamps.dat')
        xtalkfile = iraf.osfn('pysalt$data/scam/SALTICAMxtalk.dat')
        geomfile = iraf.osfn('pysalt$data/scam/SALTICAMgeom.dat')

    #verify the file
    struct = saltio.openfits(rawpath + '/' + infile)
    struct.verify('exception')

    #check to see if detmode is there
    if not saltkey.found('DETMODE', struct[0]):
        return

    #reduce the file
    struct = prepare(struct, createvar=False, badpixelstruct=None)

    #reset the names in the structures
    for i in range(1, len(struct)):
        struct[i].name = struct[i].header['EXTNAME']

    #gain correct the files
    usedb = True
    dblist = saltio.readgaindb(gaindb)
    log = open(logfile, 'a')
    ampccd = struct[0].header['NAMPS'] / struct[0].header['NCCDS']
    struct = gain(struct,
                  mult=True,
                  usedb=usedb,
                  dblist=dblist,
                  ampccd=ampccd,
                  log=None,
                  verbose=verbose)

    struct = bias(struct,
                  subover=True,
                  trim=True,
                  subbias=False,
                  median=False,
                  function='polynomial',
                  order=5,
                  rej_lo=3,
                  rej_hi=3,
                  niter=10,
                  plotover=False,
                  log=None,
                  verbose=verbose)

    if struct[0].header[
            'CCDTYPE'] == 'OBJECT' and struct[0].header['EXPTIME'] > 90:
        struct = multicrclean(struct, crtype='median', thresh=5, mbox=5, bbox=25, bthresh=5, flux_ratio=0.2, \
                            gain=1, rdnoise=5, bfactor=2, fthresh=5, gbox=0, maxiter=5, log=None, verbose=verbose)

    pinfile = outpath + 'bxp' + infile
    saltio.writefits(struct, pinfile, clobber)

    saltred.saltmosaic(images=pinfile,
                       outimages='',
                       outpref=outpath + 'm',
                       geomfile=geomfile,
                       fill=True,
                       interp=interp,
                       cleanup=cleanup,
                       clobber=clobber,
                       logfile=logfile,
                       verbose=verbose)
    profile = outpath + 'mbxp' + infile

    #remove intermediate steps
    if cleanup:
        if os.path.isfile(pinfile): os.remove(pinfile)

    return