Exemplo n.º 1
0
def processdata(instrume, obsdate, propcode, median, function, order, rej_lo, rej_hi, niter, interp, logfile, verbose):
   """Clean and process the data"""

   #set up instrument specific naming
   if instrume=='rss':
      instrume_name='RSS'
      prefix='P'
   elif instrume=='scam':
      instrume_name='SALTICAM'
      prefix='S'

   rawpath = instrume+'/raw'
   prodpath = instrume+'/product'
   img_list=[]
   for img in glob.glob('%s/raw/%s*fits' % (instrume, prefix)):
        struct=pyfits.open(img)
        if struct[0].header['PROPID'].upper().strip() != 'JUNK':
           img_list.append(img)
   img_str=','.join(img_list)
   obslog = '%s/%s%sOBSLOG.fits' % (prodpath, prefix, obsdate)
   gaindb = iraf.osfn('pysalt$data/%s/%samps.dat' % (instrume, instrume_name))
   #gaindb = ''
   xtalkfile = iraf.osfn('pysalt$data/%s/%sxtalk.dat' % (instrume, instrume_name))
   geomfile = iraf.osfn('pysalt$data/%s/%sgeom.dat' % (instrume, instrume_name))
   if len(img_list)>0:
        saltclean(images=img_str,outpath=prodpath,obslogfile=obslog,gaindb=gaindb,
                       xtalkfile=xtalkfile,geomfile=geomfile,subover=True,trim=True,
                       median=median,function=function,order=order,rej_lo=rej_lo,
                       rej_hi=rej_hi,niter=niter,masbias=True,subbias=False,interp=interp,
                       clobber=True,logfile=logfile,verbose=verbose)

   rawsize = 0.
   rawnum = 0
   prodsize = 0.
   prodnum = 0
   if len(img_list)>0:
       files = glob.glob('%s/raw/%s*.fits' % (instrume, prefix))
       rawnum = len(files)
       for file in files:
           rawsize += os.stat(file).st_size
       files = glob.glob('%s/product/*%s*.fits' % (instrume, prefix))
       prodnum = len(files)
       for file in files:
           prodsize += os.stat(file).st_size

   # collate RSS data for individual PIs
   outpath = '.'
   if len(img_list):
       saltobsid(propcode=propcode,obslog=obslog,rawpath=rawpath,prodpath=prodpath, outpath=outpath,clobber=True,logfile=logfile,verbose=verbose)
     
   return  rawsize, rawnum, prodsize, prodnum
Exemplo n.º 2
0
def hrsprocess(instrume, obsdate,propcode, median, function, order, rej_lo, rej_hi, niter, interp,  logfile, verbose):
   """Clean and process HRS data"""
   from saltobslog import saltobslog

   prefix = 'H'
   rawpath = instrume+'/raw'
   prodpath = instrume+'/product'
   img_list=[]
   for img in glob.glob('%s/raw/%s*fits' % (instrume, 'H')):
        struct=pyfits.open(img)
        if struct[0].header['PROPID'].upper().strip() != 'JUNK':
           img_list.append(img)
   for img in glob.glob('%s/raw/%s*fits' % (instrume, 'R')):
        struct=pyfits.open(img)
        if struct[0].header['PROPID'].upper().strip() != 'JUNK':
           img_list.append(img)
   print 'HRS IMAGE LIST ',  len(img_list)
   if len(img_list)>0:
      img_str=','.join(img_list)
      obslog = '%s/%s%sOBSLOG.fits' % (prodpath, prefix, obsdate)
      hrsclean(images=img_str,outpath=prodpath,obslogfile=obslog,
               subover=True,trim=True, median=median,function=function,order=order,rej_lo=rej_lo,
               rej_hi=rej_hi,niter=niter,masbias=True,subbias=False,interp=interp,
               clobber=True,logfile=logfile,verbose=verbose)

   rawsize = 0.
   rawnum = 0
   prodsize = 0.
   prodnum = 0
   if len(img_list)>0:
       files = glob.glob('%s/raw/%s*.fits' % (instrume, prefix))
       rawnum = len(files)
       for infile in files:
           rawsize += os.stat(infile).st_size
       files = glob.glob('%s/product/*%s*.fits' % (instrume, prefix))
       prodnum = len(files)
       for infile in files:
           prodsize += os.stat(infile).st_size

   # collate HRS data for individual PIs
   outpath = '.'
   if len(img_list)>0:
       saltobsid(propcode=propcode,obslog=obslog,rawpath=rawpath,prodpath=prodpath, outpath=outpath, prefix='mbgph', fprefix='bgph',clobber=True,logfile=logfile,verbose=verbose)

   return  rawsize, rawnum, prodsize, prodnum