Example #1
0
for i,filename in enumerate(arg_file_names):
    e2dsffb_fitsfilename={\
        'A': os.path.join(dir_data_reduc,arg_night_name,string.replace(filename,'.fits','_e2dsffb_A.fits')),\
            'B': os.path.join(dir_data_reduc,arg_night_name,string.replace(filename,'.fits','_e2dsffb_B.fits'))}
    
    if not (os.path.exists(e2dsffb_fitsfilename['A']) and os.path.exists(e2dsffb_fitsfilename['B']) ):
        cmd='obj_sub_POL_harps.py %s %s'%(arg_night_name,filename)
        WLOG('info',log_opt,'Running sub-script: %s'%cmd)
        err=os.system(cmd)
        if DEBUG: print 'Error code: %d'%err
        if err !=0:
            WLOG('error',log_opt,'Running obj_sub_POL_harps.py on %s failed!'%filename)
            exit(1)

    for fiber in ['A','B']:
        e2dsffb,fx,fy=hadmrFITS.read_data(e2dsffb_fitsfilename[fiber])
        if fiber=='A':
            # exclude order 46 from A, because it is not in B
            e2dsffb=concatenate((e2dsffb[:45,:],e2dsffb[46:,:]))
        data.append(e2dsffb.astype('double'))
        WLOG('info',log_opt,'re-read data from %s.'%e2dsffb_fitsfilename[fiber])

###
### Finished extraction
###
WLOG('info',log_opt,'Finished running obj_sub_POL_harps.py on all files.')

def ratio_single(data):
    """ IMPORTANT: This expects the list "data" to be sorted by angle, then fiber"""
    if len(data) != 4:
        WLOG('error',log_opt,'Function ratio_single expects 4 measurements')
execfile(ic_exec_kw_list)

try:
   _kw_out_=fitsio.read_keys(filename,kw)
except IOError:
   WLOG('error',log_opt,'I/O Error on file: '+filename)
   exit(1)

WLOG('info',log_opt,'Now processing Image TYPE: '+_kw_out_[kw_dprtype][0]+'  with '+process_running+' recipe')
dprtype=_kw_out_[kw_dprtype][0]

execfile(ic_exec_kw_allocate)
execfile(ic_exec_kw_display)


e2dsff[fiber],nx,ny=hadmrFITS.read_data(I_e2ds_fitsfilename)


blaze_file=os.path.join(dirfits,hadmrFITS.read_key(I_e2ds_fitsfilename,kw_BLAZE_FILE[0]))
if os.path.exists(blaze_file): 
    blaze[fiber],fx,fy=hadmrFITS.read_data(blaze_file)
else:
    WLOG('error',log_opt,'blaze file: '+blaze_file+' does not exist, FATAL!')
    exit(0)

kw=[kw_tarrv,kw_BERV[0],kw_BJD[0],kw_BERVMX[0],kw_snref,kw_DRIFT_VR_USED[0],kw_CCD_SIGDET[0]]
_kw_out_=fitsio.read_keys(I_e2ds_fitsfilename,kw,hdu=-1,verbose=0)
berv=_kw_out_[kw_BERV[0]][0]
berv_max=_kw_out_[kw_BERVMX[0]][0]
bjd=_kw_out_[kw_BJD[0]][0]
WLOG('info',log_opt,'Barycentric Earth RV correction: %9.5f km/s' %(berv))
Example #3
0
  if saturation: WLOG('warning',log_opt,'Saturation level reached')

  WLOG('info',log_opt,'On fiber '+fiber+\
		 ': S/N[%snm]= %.1f S/N[%snm]= %.1f S/N[%snm]= %.1f' %\
  (ic_sn_display_ll[fiber][0],S_N[ic_sn_display_o[fiber][0]],ic_sn_display_ll[fiber][1],S_N[ic_sn_display_o[fiber][1]],ic_sn_display_ll[fiber][2],S_N[ic_sn_display_o[fiber][2]])+\
  '	(%d cosmic removed)'%(sum(nbcos)))
  
#
# Do Flat Field correction  
#
  if dic_db.has_key('FLAT_'+fiber)==0:
     WLOG('error',log_opt,'No Flat-Field is defined in the calibDB for fiber: '+fiber)
     exit(3)

  flat_file=os.path.join(dirfits,dic_db['FLAT_'+fiber][1])
  flat,fx,fy=hadmrFITS.read_data(flat_file)
  WLOG('',log_opt,'Doing Flat-Field correction for fiber: '+fiber+' using '+dic_db['FLAT_'+fiber][1])

  e2dsff[fiber]=e2ds/flat



###############################
# Insert wavelength calibration  
###############################

  if dic_db.has_key('TH_'+fiber)==0:
    WLOG('error',log_opt,'No wavelength Calibration for fiber '+fiber+'  FATAL!')
    exit(3)

  th_file=os.path.join(dirfits,dic_db['TH_'+fiber][1])