PRO heae_do_it_all, heae_out, eae_out ; ; This is a modified version of eae_do_it_all, designed for ; HSI QE analysis from HSI 1st order images... ; ; Needed common @cmdb_common ; Hardwired things: ; . . . . . . . . . . . . . . . . . . . . . . ; ; The CMDB is set by hetgcal_idl_start.pro and cmdb/cmdb_start.pro ; ; Set where to get and put eae analysis products ; Use the CALDB area: keep_em_dir = !DDHETGCAL+'/cmp/eae/' ; Start of first, processing, section ;---------------------------- ; select to do it or not... if 0 EQ 1 then begin ; . . . . . . . . . . . . . . . . . . . . . . ; First read in the whole starting cmdb ; This should have been done by hetgcal_idl_start ; Do not need to execute: cmdb_load ; ; get access to the CMDB column definition integers if cmdb_using_cal then begin @cmdb_cal_integers end else begin @cmdb_trw_integers end ; . . . . . . . . . . . . . . . . . . . . . . ; Now create initial rdb file based on this cmdb: ; (also creates a cmdb file of just the selected eae/heae measurements) eae_fill_from_cmdb, keep_em_dir+'eae_from_cmdb' ; The above is the full eae list with FPC, SSD, 2C, and HSI ; Get only the HSI portion that is first order: eae = rdb_read(keep_em_dir+'eae_from_cmdb.rdb') heae = eae(where(STRPOS(eae.fp_detector,'HSI') GE 0 and $ ABS(eae.order) EQ 1)) rdb_write, keep_em_dir+'heae_from_cmdb.rdb', heae ; . . . . . . . . . . . . . . . . . . . . . . ; Now go through this rdb file and add in the values of ; the MST date and run id eae_fill_runids, keep_em_dir+'heae_from_cmdb.rdb', $ keep_em_dir+'heae_wids.rdb' ; . . . . . . . . . . . . . . . . . . . . . . ; Make a listing of the heae file heae = rdb_read(keep_em_dir+'heae_wids.rdb') eae_list, heae, keep_em_dir+'heae_wids.summary' ;---------------------------- END ; of processing selection ; This next section fills in the HSI and BND data... ;------------------------------------------------------ ; HSI data: ; . . . . . . . . . . . . . . . . . . . . . . ; First time make the heae_whcounts.rdb file as a copy ; of heae_wids.rdb . ;;SPAWN, 'cp ' + keep_em_dir+'heae_wids.rdb' + ' ' + $ ;; keep_em_dir+'heae_whcounts.rdb' ; . . . . . . . . . . . . . . . . . . . . . . ; Then run hsi_do_source_spectra to fill the focal values ; from the HSI images... ; Can do all the HSI images (for source pruposes) ; ;;hsi_do_source_spectra,/ANAL, /WEB ; ; Or just the ones of QE interest: ; ;;heae = rdb_read(keep_em_dir+'heae_whcounts.rdb') ;;heae_qes, heae, INDICES=inds ;;for iid=0, n_elements(inds)-1 do begin ;; hsi_source_spectra, heae(inds(iid)).trw_id, /LPR, /COMPARE, /HEAE ;;end ;;heae = rdb_read(keep_em_dir+'heae_whcounts.rdb') ;;eae_list, heae(inds) ; ; The above run hsi_source_spectra.pro on HSI data sets with the ; HEAE_ANAL keyword set: ; - The /HEAE_ANAL keyword to hsi_source_spectra will ; have it read heae_whcounts.rdb, modify the appropriate line, ; by adding focal_counts, focal_err_plus, focal_err_minus, ; focal_time, focal_analysis=ROI,ALL , etc. ; and then write it back out. ;------------------------------------------------------ ; BND data: ; These values are added in the same way as for eae analysis ; and can be done manually in sections at a time (as shown here) ; . . . . . . . . . . . . . . . . . . . . . . ; Now do ROI analysis on the HXDS data ; Do just the HSI QE ones ; ;; heae = rdb_read(keep_em_dir+'heae_whcounts.rdb') ;; heae_qes, heae, INDICES=inds ;; eae_pha_anal, heae(inds), /VERBOSE, /IT0ONLY, $ ;; OUT_FILE= keep_em_dir+'heae_wcounts_qes.rdb' ; ; . . . . . . . . . . . . . . . . . . . . . . ; Combine them all into one heae_wcounts.rdb file ;;SPAWN, 'cp ' + keep_em_dir+'heae_wcounts_qes.rdb' + ' ' + $ ;; keep_em_dir+'heae_wcounts.rdb' ; Now we have counts,errors,time and iteration ; values... These could also have been filled in ; from someone's XSPEC analysis results. ;------------------------------------------------------ if 0 EQ 1 then begin ;---------------------------- ; . . . . . . . . . . . . . . . . . . . . . . ; Need to calculate the flux and effective ; area... heae = rdb_read(keep_em_dir+'heae_wcounts.rdb') eae_fill_order, heae eae_flux_anal, heae rdb_write, keep_em_dir+'heae_wflux.rdb', heae ;---------------------------- end ;--------------------------------------------------- ; Now get the heae and eae items to be used for HSI QE measurement: heae = rdb_read(keep_em_dir+'heae_wflux.rdb') heae_qes, heae, INDICES = h_inds heae = heae(h_inds) heae_out = heae eae = rdb_read(keep_em_dir+'eae_wflux.rdb') eae = eae(where(eae.iteration EQ '0')) ; get just the iteration=0 ones corresponding to above: heae_qes, eae, /EAE, INDICES = e_inds eae = eae(e_inds) eae_out = eae ; Look at these eae analyses... ;pre_print_portrait ;for im=0, n_elements(eae)-1 do begin ; eae_pha_anal, eae(im), /VERBOSE, $ ; IT0ONLY = 1, NOPLOTS = noplots ;end ;device, /close ;set_plot, 'X' ;!p.multi=0 ;--------------------------------------------------- ; Create the feature fraction for these measurements ; - Simulate the eae measurments w/MARX, by running: ; ;;to_do = [0,1,2,3,4,5,6] ;;eae_sim, heae(to_do), /SIM ;;eae_sim, eae(to_do), /SIM ; ; - Create and save the feature_fractions.rdb file (finally!): ;;eae_sim, eae(to_do), /ANAL ;;SPAWN, 'cp feature_fractions.rdb '+ keep_em_dir+'heae_eae_ffs.rdb' ;;eae_sim, heae(to_do), /ANAL ;;SPAWN, 'cp feature_fractions.rdb '+ keep_em_dir+'heae_heae_ffs.rdb' ; ; Get the fractions: eaeff = rdb_read(keep_em_dir+'heae_eae_ffs.rdb') heaeff = rdb_read(keep_em_dir+'heae_heae_ffs.rdb') ; and their errors (df/f): edff = feat_frac_err(eaeff) hdff = feat_frac_err(heaeff) ; ;--------------------------------------------------- ;--------------------------------------------------- ; Create and plot the measured QEs ; ; HSI feature counts per second per flux ; HSI QE = -------------------------------------- ; FPC feature photons per second per flux ; ; has unit of "counts per photon" ; ; Output array hsi_meas_qe = FLTARR(n_elements(heae)) hsi_meas_qe = ( (heaeff.fracnom * heae.focal_line / heae.flux ) / $ (eaeff.fracnom * eae.focal_line / eae.flux ) ) ; and the error on this: include the focal count errors, ignore ; the BND flux errors (more counts than focal generally?), and ; include the feature-fraction errors ; and finally a subjective error based on: ; Fe-L HV is different and lot of contamination lines... ; Mg-K is off-axis... hsi_meas_err = hsi_meas_qe * $ SQRT( (heae.focal_line_plus / heae.focal_line )^2 + $ (eae.focal_line_plus / eae.focal_line)^2 + $ (edff)^2 + $ (hdff)^2 + $ ([0.7, 0.15,0.,0.,0.,0.,0.])^2 ) ; Show where the meas come from print, '------------------------------------------------------------------' print, '' eae_list, heae eae_list, eae print, '' print, ' HSI meas QEs: ' for im=0,n_elements(heae)-1 do begin print, heae(im).energy, hsi_meas_qe(im), hsi_meas_err(im), $ ' HSI, FPC fracs: ', heaeff(im).fracnom, eaeff(im).fracnom, $ ' ',heae(im).fpc_ht_counts/heae(im).fpc_ht_time, $ ' ',eae(im).fpc_ht_counts/eae(im).fpc_ht_time end print, '' print, '' print, ' Comparing fluxes and HT rates: ' for im=0,n_elements(heae)-1 do begin print, heae(im).energy, $ ' ',heae(im).flux/eae(im).flux, $ ' ',( heae(im).fpc_ht_counts/heae(im).fpc_ht_time ) / $ (eae(im).fpc_ht_counts/eae(im).fpc_ht_time) end print, '' plot_oi, heae.energy, hsi_meas_qe, PSYM=4, $ XRANGE=[0.05,10.0], XSTYLE=1, YRANGE=[0.,0.25], $ TITLE='Measured HSI QE from Grating First-Orders' x_center = heae.energy y_low = hsi_meas_qe - hsi_meas_err y_high = hsi_meas_qe + hsi_meas_err plot_errors, x_center, x_center, x_center, y_low, y_high hsiqe = rdb_read(!DDHXDSDIR+'/hsi_qe_N19990530.rdb') oplot, hsiqe.energy, hsiqe.qe, LINESTYLE=2 RETURN END