PRO eae_pha_anal, eae_rdb, VERBOSE = verbose, $ IT0ONLY = it0only, OUT_FILE = out_file, NOPLOTS = noplots ; Procedure to do PHA analysis on the tests specificed by the eae_rdb ; lines given. ; . . . . . . . . . . . . . . . . . . ; Where to find raw HXDS data! : ; Following MST directory tree from DDHXDSDATA: dates_low = ['960807','961206','970212','970612'] dates_high = ['961205','970211','970518','970626'] hxds_dirs = ['do not have this data ?', $ !DDHXDSDATA+'/phase1/data/', $ !DDHXDSDATA+'/phase2/data/', $ !DDHXDSDATA+'/phase3/data/'] ; . . . . . . . . . . . . . . . . . . ; Loop over all input eae lines (rows) for ir = 0, n_elements(eae_rdb)-1 do begin ; Find the PHA data files which = where(dates_low LE eae_rdb(ir).mst_date AND $ dates_high GE eae_rdb(ir).mst_date, nwhich) if nwhich NE 1 then begin ; Problem finding the date code... print, '* eae_pha_anal: problem with date code for ' + $ eae_rdb(ir).trw_id end else begin ; found the date code so ... dat_dir = hxds_dirs(which(0))+eae_rdb(ir).mst_date+'/' if KEYWORD_SET(VERBOSE) then begin print, '' print, eae_rdb(ir).trw_id print, ' ... looking in '+ dat_dir end pha_files = FINDFILE(dat_dir+'acq'+eae_rdb(ir).run_id+ $ '*.pha', COUNT=nfound) if nfound GE 1 then begin if KEYWORD_SET(VERBOSE) then begin for ii=0,n_elements(pha_files)-1 do print, ' '+pha_files(ii) end ; Loop over the iterations it = 0 it_str = STRCOMPRESS(STRING(it),/REMOVE_ALL) its = where(STRPOS(pha_files,'i'+ it_str + '.pha') GT 0, nits) ; catch 106720 which has FPC_X1 active?!? if nits EQ 9 then nits = 8 while nits GT 0 do begin if KEYWORD_SET(VERBOSE) then begin print, 'Iteration '+it_str end ; Determine the ROIs ; Lots of experience stored in this routine! eae_roi, eae_rdb(ir).run_id, det_names, roi_lows, roi_highs ; Four plots only for SPIE figure purposes... ;;if nits GT 4 then nits = 4 if NOT(KEYWORD_SET(NOPLOTS)) then begin ; set up to plot the files CASE nits OF 1: !p.multi = 0 2: !p.multi = [0,1,2] 3: !p.multi = [0,2,2] 4: !p.multi = [0,2,2] 5: !p.multi = [0,2,3] 6: !p.multi = [0,2,3] 7: !p.multi = [0,2,4] 8: !p.multi = [0,2,4] ELSE: !p.multi = 0 ENDCASE end ; if we're outputing a file of results, create ; a copy of the present line to fill with counts etc ; and append to output array... if KEYWORD_SET(OUT_FILE) then begin this_eae = eae_rdb(ir) this_tags = TAG_NAMES(this_eae) ; include the iteration number this_eae.iteration = it_str ; include "analysis" strings this_eae.analyst = 'dd/idl/xrcf/eae_pha_anal.pro' this_eae.analysis_date = SYSTIME() this_eae.fpc_analysis='ROI,' + $ STRCOMPRESS(STRING(roi_lows(2)),/REMOVE) + $ '-'+ $ STRCOMPRESS(STRING(roi_highs(2)),/REMOVE) + $ ','+ $ STRCOMPRESS(STRING(roi_lows(2)),/REMOVE) + $ '-'+ $ STRCOMPRESS(STRING(roi_highs(2)),/REMOVE) this_eae.ssd_5_analysis='ROI,' + $ STRCOMPRESS(STRING(roi_lows(6)),/REMOVE) + $ '-'+ $ STRCOMPRESS(STRING(roi_highs(6)),/REMOVE) if STRPOS(this_eae.fp_detector,'FPC') GE 0 then begin this_eae.focal_analysis='ROI,' + $ STRCOMPRESS(STRING(roi_lows(0)),/REMOVE) + $ '-'+ $ STRCOMPRESS(STRING(roi_highs(0)),/REMOVE) end if STRPOS(this_eae.fp_detector,'SSD') GE 0 then begin this_eae.focal_analysis='ROI,' + $ STRCOMPRESS(STRING(roi_lows(7)),/REMOVE) + $ '-'+ $ STRCOMPRESS(STRING(roi_highs(7)),/REMOVE) end end ; loop over the detectors for this iteration for id = 0, nits-1 do begin if KEYWORD_SET(VERBOSE) then begin this_pha = rdb_read(pha_files(its(id)),/PHA) end else begin this_pha = rdb_read(pha_files(its(id)),/PHA,/SILENT) end this_time_str = rdb_param(pha_files(its(id)),'iveTime') this_time = 0.0 READS, this_time_str, this_time det_name = tag_names(this_pha) det_name = det_name(0) if det_name EQ 'FPC_X1' then det_name='FPC_X2' ; Find the ROI for this detector roi_ind = where(det_names EQ det_name) roi_ind = roi_ind(0) ; and counts in the ROI this_counts = TOTAL( FLOAT( this_pha(roi_lows(roi_ind)-1 : $ roi_highs(roi_ind)-1).(0) ) ) if KEYWORD_SET(OUT_FILE) then begin ; OK, add this detector's info to the line if STRPOS(det_name,'FPC_H') GE 0 OR $ STRPOS(det_name,'_5') GE 0 then begin count_col = where(this_tags EQ det_name+'_COUNTS') this_eae.(count_col(0)) = this_counts err_col = where(this_tags EQ det_name+'_ERR') this_eae.(err_col(0)) = SQRT(this_counts) time_col = where(this_tags EQ det_name+'_TIME') this_eae.(time_col(0)) = this_time end else begin ; focal detector count_col = where(this_tags EQ 'FOCAL_COUNTS') this_eae.(count_col(0)) = this_counts err_col = where(this_tags EQ 'FOCAL_ERR_PLUS') this_eae.(err_col(0)) = SQRT(this_counts) this_eae.(err_col(0)+1) = SQRT(this_counts) time_col = where(this_tags EQ 'FOCAL_TIME') this_eae.(time_col(0)) = this_time end end if NOT(KEYWORD_SET(NOPLOTS)) then begin ; . . . . . . plot stuff : . . . ; now cute plotting stuff... ; set some titles this_title = det_name if id EQ 0 then this_title = det_name+', '+eae_rdb(ir).trw_id if id EQ 1 then this_title = det_name+', '+eae_rdb(ir).mst_date+ $ '/'+eae_rdb(ir).run_id + 'i'+it_str ; x range depends on detector type xmax = 500. ; Include up to ~ 12 keV in SSD: if STRPOS(det_name,'SSD') GE 0 then xmax = 2300. chans = 1+indgen(n_elements(this_pha)) plot_io, chans, this_pha.(0), $ TITLE = this_title, $ CHARSIZE = 1.2, $ XTITLE = 'Bin', YTITLE = 'Counts/bin', $ XRANGE = [0.,xmax], XSTYLE=1, $ YRANGE = [1.,(MAX(this_pha.(0)) > 1.E4)], PSYM=3 xyouts, 0.5*xmax, 3000., STRING(this_time,FORMAT='(F7.2)')+' s' ; Highlight the ROI oplot, chans(roi_lows(roi_ind)-1:roi_highs(roi_ind)-1), $ this_pha(roi_lows(roi_ind)-1:roi_highs(roi_ind)-1).(0), $ PSYM=10 oplot, roi_lows(roi_ind)*[1.,1.], [1.,1.E4], LINESTYLE = 2 oplot, roi_highs(roi_ind)*[1.,1.], [1.,1.E4], LINESTYLE = 2 xyouts, 0.5*xmax, 1000., STRING(this_counts,FORMAT='(F9.0)') ; . . . . . . end plot stuff . . . end ; of plot stuff end ; loop over detector ; save the filled-in eae line if writing output file if KEYWORD_SET(OUT_FILE) then begin if n_elements(eae_going_out) EQ 0 then begin ; create the output array eae_going_out = [this_eae] end else begin ; append to it eae_going_out = [ eae_going_out, this_eae ] end end ; next iteration it = it + 1 it_str = STRCOMPRESS(STRING(it),/REMOVE_ALL) its = where(STRPOS(pha_files,'i'+ it_str + '.pha') GT 0, nits) ; catch 106720 which has FPC_X1 active?!? if nits EQ 9 then nits = 8 ; do only iteration 0 if requested if KEYWORD_SET(IT0ONLY) then nits = 0 end ; of while ; write out the file... if KEYWORD_SET(OUT_FILE) then begin if n_elements(eae_going_out) GE 1 then begin if KEYWORD_SET(VERBOSE) then begin rdb_write, out_file, eae_going_out end else begin rdb_write, out_file, eae_going_out, /SILENT end end end end else begin print, '* eae_pha_anal: found no files for ' + $ eae_rdb(ir).trw_id end end end RETURN END