;;; Reduce MagE data ; Read in object and calibration file names templ = { $ version: 1.0, $ datastart: 0, $ delimiter: ' ', $ missingvalue: -99.0, $ commentsymbol: '#', $ fieldcount: 16, $ fieldtypes: [7,7,3,3,3,3,3,7,7,7,7,7,7,7,7,7], $ fieldnames: ['root','type','reduce_lo','reduce_hi','fit_lo',$ 'fit_hi','fiducial','arc','refarc','orderlist',$ 'slit','wave','xe_flat','xe_flatvar','dome_flat',$ 'dome_flatvar'], $ fieldlocations: [0,14,25,28,36,39,45,55,66,77,98,118,139,166,$ 196,222], $ fieldgroups: [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15] $ } data = read_ascii('reduce_info.dat',template=templ) rootname = data.root exptype = data.type reduce_order_lo = data.reduce_lo reduce_order_hi = data.reduce_hi fit_order_lo = data.fit_lo fit_order_hi = data.fit_hi fiducial_order = data.fiducial arcfile = data.arc refarcfile = data.refarc orderlist = data.orderlist slitfile = data.slit wavefile = data.wave xe_flatfile = data.xe_flat xe_flatvarfile = data.xe_flatvar dome_flatfile = data.dome_flat dome_flatvarfile = data.dome_flatvar n_exposures = n_elements(rootname) ;;; Change the next three lines to reflect the correct directories on ;;; your system. ;rawdir = './' rawdir = '~mr/aobs/data/lco/feb12/mage/ut120219/' ;caldir = '~gdb/redux_packages/mage_reduce/calib/' caldir = '~mr/aobs/data/lco/sep11/mage/mage_reduce/calib/' ;reduxdir = 'mage_data/redux/' reduxdir = '~mr/aobs/data/lco/feb12/mage/redux/' ;;; ;;; Loop through and reduce each frame ;;; for i=0,n_exposures-1 do begin & $ root = rootname(i) & $ raw = rawdir+root+'.fits' & $ type = exptype(i) & $ arc = rawdir+arcfile(i)+'.fits' & $ refarc = caldir+refarcfile(i)+'.fits' & $ list = caldir+orderlist(i)+'.dat' & $ wave = caldir+wavefile(i)+'.fits' & $ slit = caldir+slitfile(i)+'.fits' & $ xe_flat = reduxdir+xe_flatfile(i)+'.fits' & $ xe_flatvar = reduxdir+xe_flatvarfile(i)+'.fits' & $ dome_flat = reduxdir+dome_flatfile(i)+'.fits' & $ dome_flatvar = reduxdir+dome_flatvarfile(i)+'.fits' & $ output = reduxdir+root & $ if (arcfile(i) eq '0') then arc=0 & $ if (refarcfile(i) eq '0') then refarc=0 & $ if (dome_flatfile(i) eq '0') then dome_flat=0 & $ if (dome_flatvarfile(i) eq '0') then dome_flatvar=0 & $ case type of & $ 'BRIGHT': begin & $ spline_profile = 1 & $ trace_obj = 1 & $ end & $ 'MEDIUM': begin & $ spline_profile = 0 & $ trace_obj = 1 & $ end & $ 'FAINT': begin & $ spline_profile = 0 & $ trace_obj = 0 & $ end & $ endcase & $ n_to_reduce = reduce_order_hi(i) - reduce_order_lo(i) + 1 & $ orders_to_reduce = reduce_order_lo(i) + lindgen(n_to_reduce) & $ n_to_fit = fit_order_hi(i) - fit_order_lo(i) + 1 & $ orders_to_fit = fit_order_lo(i) + lindgen(n_to_fit) & $ fiducial = fiducial_order(i) & $ if (!journal ne 0) then journal & $ journal,output+'.log' & $ mage_reduce,raw,wave,slit,list,skyref=refarc,skyframe=arc,$ flatfield=xe_flat,flatvar=xe_flatvar,$ redflatfield=dome_flat,redflatvar=dome_flatvar,$ output=output,fiducial=fiducial,maxiter=10,noshow=1,$ order=orders_to_reduce,fit=orders_to_fit,$ sprofile=spline_profile,/faint,$ fid_xy=[1060.3,419.91],fid_fwhm=8.,/notrace & $ journal & $ close,/all & $ ; Uncomment the following line if you want to automatically ; gzip the reduced files. ;spawn,'gzip -f '+reduxdir+'*.fits' & $ endfor