PRO anal_driver_gen, first_file_name ; Generate the anal_drivers for data analysis. ; for MEG9 ; 7/27/95 dd ; 8/25/95 dd add first_file_name on command line option ; 9/5/95 dd MEG7 ; 9/7/95 dd Need to have different orders and parameters for ; HEG or MEG gratings. ; 10/1/95 dd MEG8 analysis: same as MEG7 (only change to MEG8 is ; addition of higher-order MgO data sets ; at 100 mm offset.) ; And F005M gratings are ~ 3700 A, 2300 A. ; 10/2/95 dd MEG8: exclude tilt test files from efficiency analysis ; ; 10/23/95 dd :MEG9 : No changes needed from MEG8 ; 10/26/95 dd Add test name to filenames in anal drivers - so ; instead of PSPC#1 would look for PSPC[]MEG9#1 ; to avoid START and SHUTD s etc ; 1/23/96 dd Modified to kludge data from test count [913] items #14 to #39 ; Suspicion is that PSPC gain changed somewhat for these and ; the X axis shifted by ~0.05 volt (~1.5 mm). @xrtf_common @fits_common ; Assume that list_fits has been run ; read in the first FITS file if n_elements(first_file_name) EQ 0 then first_file_name = ufn_useful_file(0) read_fits_headers, first_file_name gratA_name = STRCOMPRESS(fxpar(XGEF_HDR,'GRAT_A'),/REMOVE_ALL) gratB_name = STRCOMPRESS(fxpar(XGEF_HDR,'GRAT_B'),/REMOVE_ALL) test_name = STRCOMPRESS(fxpar(XGEF_HDR,'TESTCODE'),/REMOVE_ALL) print, ' anal_driver_gen: ', test_name, ' ',gratA_name, $ ' ', gratB_name ; These tilt test items should not be used for efficiency analysis ; tilt_test_min = 53 tilt_test_max = 108 TAB = STRING(9B) ; Loop through the gratings ; including the reference gratings for ig=0,3 do begin print, ' anal_driver_gen: ig = ', ig if ig LE 1 then begin ; grating under test: grat_params = ' 3700., 2300., 0.5, 1.0, 4000.' gratx_locs = [-8.,-4.,0.,4.,8.] slots_str = ' 0,1,1,1,1,0' grat_let = 'A' grat_name = gratA_name if ig EQ 1 then begin grat_let = 'B' grat_name = gratB_name end end else begin if ig EQ 2 then begin ; Reference grating, HX220 grat_params = ' 4000., 1350., 1.0, 1.0, 2000.' gratx_locs = [0.0] slots_str = ' 0,1,1,1,1,0' grat_let = 'HRef' grat_name = 'HX220' end else begin ; Reference grating, MX078 grat_params = ' 4400., 2460., 0.5, 1.0, 4000.' gratx_locs = [0.0] slots_str = ' 0,1,1,1,1,0' grat_let = 'MRef' grat_name = 'MX078' end end ; For all gratings create anal_drivers for each ; location FOR igl = 0, n_elements(gratx_locs)-1 do begin gratx_str = STRCOMPRESS(STRING(FIX(ABS(gratx_locs(igl))),FORMAT='(I2)'), $ /REMOVE_ALL) if gratx_locs(igl) LT 0.0 then begin gratx_str = 'm'+gratx_str end else begin gratx_str = 'p'+gratx_str end ; Create the anal driver name anal_file = test_name+'_'+grat_let+gratx_str+'_'+'pspc_anal_driver.txt' print, ' anal_driver_gen : creating ',anal_file OPENW, anal_unit, anal_file, /GET_LUN printf, anal_unit, '; Created by anal_driver_gen.pro, ' + SYSTIME() printf, anal_unit, '; Test code: '+ test_name printf, anal_unit, ";pspc data file TAB target TAB energy, order, X_width, "+ $ "Y_anodes, zero_loc, emin, emax, gthk, gline, gpoly, gplating, gperiod", $ FORMAT='(A)' anal_anodes = ['Mo','Cu','Ti','MgO','Al'] anal_energies = [2.293,0.93,4.511,1.254,1.486] for ia = 0, n_elements(anal_anodes)-1 do begin print, ' anal_driver_gen : anode = ',anal_anodes(ia) CASE anal_anodes(ia) OF 'Mo': BEGIN if STRPOS(grat_name,'M') GE 0 then begin orders = [99,1,-1,2,-2,0] elow = 0.8*[1.,1.,1.,1.,1.,1.] ehigh = 8.0*[1.,1.,1.,1.,1.,1.] width = 5.0*[1.,1.,1.,1.5,1.5,1.] end else begin orders = [99,1,-1,-2,0] elow = 0.8*[1.,1.,1.,1.,1.] ehigh = 8.0*[1.,1.,1.,1.,1.] width = 5.0*[1.,1.,1.,1.5,1.] end END 'Ti': BEGIN orders = [99,1,-1,2,-2,0] elow = 0.8*[1.,1.,1.,1.,1.,1.] ehigh = 8.0*[1.,1.,1.,1.,1.,1.] width = 5.0*[1.,1.,1.,1.5,1.5,1.] END 'MgO': BEGIN if STRPOS(grat_name,'M') GE 0 then begin orders = [99,1,-1,2,-2,0] elow = 0.5*[1.,1.,1.,1.,1.,1.] ehigh = 5.0*[1.,1.,1.,1.,1.,1.] width = 6.0*[1.,1.25,1.25,1.5,1.5,1.] end else begin orders = [99,1,-1,0] elow = 0.5*[1.,1.,1.,1.] ehigh = 5.0*[1.,1.,1.,1.] width = 6.0*[1.,1.25,1.25,1.] end END 'Cu': BEGIN if STRPOS(grat_name,'M') GE 0 then begin orders = [99,1,-1,0] elow = 0.3*[1.,1.,1.,1.] ehigh = 3.0*[1.,1.,1.,1.] width = 6.0*[1.,1.5,1.5,1.] end else begin orders = [99,-1,0] elow = 0.3*[1.,1.,1.] ehigh = 3.0*[1.,1.,1.] width = 6.0*[1.,1.5,1.] end END ; 'W': BEGIN ; orders = [99,1,-1,2,-2,0] ; elow = 0.8*[1.,1.,1.,1.,1.,1.] ; ehigh = 5.0*[1.,1.,1.,1.,1.,1.] ; width = 6.0*[1.,1.,1.,1.5,1.5,1.] ; END ; 'Fe': BEGIN ; orders = [99,1,-1,2,-2,0] ; elow = 0.8*[1.,1.,1.,1.,1.,1.] ; ehigh = 8.0*[1.,1.,1.,1.,1.,1.] ; width = 6.0*[1.,1.,1.,1.,1.,1.] ; END 'Al': BEGIN if STRPOS(grat_name,'M') GE 0 then begin orders = [99,1,-1,2,-2,0] elow = 0.8*[1.,1.,1.,1.,1.,1.] ehigh = 5.0*[1.,1.,1.,1.,1.,1.] width = 6.0*[1.,1.25,1.25,1.5,1.5,1.] end else begin orders = [99,1,-1,0] elow = 0.8*[1.,1.,1.,1.] ehigh = 5.0*[1.,1.,1.,1.] width = 6.0*[1.,1.25,1.25,1.] end END ELSE: ENDCASE for io=0,n_elements(orders)-1 do begin ; Find the filename that matches: ; test name ; PSPC file ; the anode ; the desired grating (or Direct beam if order=99) ; the grat_x location (0 if Direct) ; the item number is NOT in the tilt test range des_grat_name = grat_name des_grat_x = gratx_locs(igl) if (orders(io) EQ 99 ) then begin des_grat_name = 'Direct' des_grat_x = 0.0 end use_this = where( STRPOS(ufn_useful_file, ']'+test_name) GE 0 AND $ STRPOS(ufn_useful_file,'PSPC') EQ 0 AND $ STRPOS(ufn_useful_file,anal_anodes(ia)) GT 0 AND $ STRPOS(ufn_useful_file,des_grat_name) GT 0 AND $ approx_equal(ufn_grat_x+0.5,des_grat_x+0.5) EQ 1 AND $ (ufn_testitem LT tilt_test_min OR ufn_testitem GT tilt_test_max) ) detoffsets = ufn_det_xloc(use_this) one_to_use = use_this(0) ; use the "first" and usually only data file file_name = 'PSPC[]'+ test_name + '#' + $ STRCOMPRESS(STRING(ufn_testitem(one_to_use),FORMAT='(I4)'),$ /REMOVE_ALL) ; and get the detector offset for the grating detoffset = ufn_det_xloc(one_to_use) ; 1/23/96 Kludge for 960110 data if anal_anodes(ia) EQ 'MgO' or anal_anodes(ia) EQ 'Mo' then detoffset = detoffset+1.5 ; Write out the line printf, anal_unit, file_name + TAB + anal_anodes(ia) + TAB + $ STRING(anal_energies(ia),FORMAT='(F6.3)') + STRING(orders(io),FORMAT='(I5)') + $ STRING(width(io),FORMAT='(F4.1)') + $ slots_str + STRING(detoffset,FORMAT='(F7.1)') + STRING(elow(io),FORMAT='(F4.1)') + $ STRING(ehigh(io),FORMAT='(F4.1)') + $ grat_params, FORMAT='(A)' end printf, anal_unit, ';' end ; anodes CLOSE, anal_unit FREE_LUN, anal_unit end ; locations ; Create tilt test analysis anal_drivers here for the two test gratings if ig LE 1 then begin ; For all gratings create anal_drivers for each ; tilt location gratx_locs = [0.,8.] FOR igl = 0, n_elements(gratx_locs)-1 do begin gratx_str = STRCOMPRESS(STRING(FIX(ABS(gratx_locs(igl))),FORMAT='(I2)'), $ /REMOVE_ALL) if gratx_locs(igl) LT 0.0 then begin gratx_str = 'm'+gratx_str end else begin gratx_str = 'p'+gratx_str end ; Create the anal driver name anal_file = test_name+'_'+grat_let+gratx_str+'tilt_'+'pspc_anal_driver.txt' OPENW, anal_unit, anal_file, /GET_LUN printf, anal_unit, '; Created by anal_driver_gen.pro, ' + SYSTIME() printf, anal_unit, ";pspc data file TAB target TAB energy, order, X_width, "+ $ "Y_anodes, zero_loc, emin, emax, gthk, gline, gpoly, gplating, gperiod", $ FORMAT='(A)' anal_anodes = ['Al'] anal_energies = [1.486] for ia = 0, n_elements(anal_anodes)-1 do begin CASE anal_anodes(ia) OF 'Al': BEGIN orders = [1] elow = 0.8*[1.] ehigh = 5.0*[1.] width = 6.0*[1.25] END ELSE: ENDCASE for io=0,n_elements(orders)-1 do begin ; Find the filename that matches: ; test name ; PSPC file ; the anode ; the desired grating (or Direct beam if order=99) ; the grat_x location (don't care if Direct beam) ; test item is greater than 1 (1 is shutdown) des_grat_name = grat_name des_grat_x = gratx_locs(igl) if (orders(io) EQ 99 ) then begin des_grat_name = 'Direct' des_grat_x = 0.0 end use_this = where( STRPOS(ufn_useful_file, ']'+test_name) GE 0 AND $ STRPOS(ufn_useful_file,'PSPC') EQ 0 AND $ STRPOS(ufn_useful_file,anal_anodes(ia)) GT 0 AND $ STRPOS(ufn_useful_file,des_grat_name) GT 0 AND $ approx_equal(ufn_grat_x+0.5,des_grat_x+0.5) EQ 1 AND $ ufn_testitem GE 2, n_to_use ) if n_to_use GT 0 then begin for i_use=0, n_elements(use_this)-1 do begin file_name = 'PSPC[]'+ test_name + '#' + $ STRCOMPRESS(STRING(ufn_testitem(use_this(i_use)),FORMAT='(I4)'),$ /REMOVE_ALL) ; and get the detector offset for the grating detoffset = ufn_det_xloc(use_this(i_use)) ; Write out the line printf, anal_unit, file_name + TAB + anal_anodes(ia) + TAB + $ STRING(anal_energies(ia),FORMAT='(F6.3)') + STRING(orders(io),FORMAT='(I5)') + $ STRING(width(io),FORMAT='(F4.1)') + $ slots_str + STRING(detoffset,FORMAT='(F7.1)') + STRING(elow(io),FORMAT='(F4.1)') + $ STRING(ehigh(io),FORMAT='(F4.1)') + $ grat_params, FORMAT='(A)' ; Write out the line with the negative order printf, anal_unit, file_name + TAB + anal_anodes(ia) + TAB + $ STRING(anal_energies(ia),FORMAT='(F6.3)') + STRING(-1*orders(io),FORMAT='(I5)') + $ STRING(width(io),FORMAT='(F4.1)') + $ slots_str + STRING(detoffset,FORMAT='(F7.1)') + STRING(elow(io),FORMAT='(F4.1)') + $ STRING(ehigh(io),FORMAT='(F4.1)') + $ grat_params, FORMAT='(A)' end ; i_use end ; n_to_use end printf, anal_unit, ';' end ; anodes CLOSE, anal_unit FREE_LUN, anal_unit end ; tilt locations end ; check for test gratings for tilt end ; gratings RETURN END