PRO sim_all_acis, SIM=sim, COMPARABLE=comparable, SMALL_IMAGE=small_image, $ TABLE=table, FORM_DATA_STATS=form_data_stats ; This procedure runs through the ACIS-Grating data sets and ; calls xrcf_sim to simulate them. ; Other functions (SMALL_IMAGE and TABLE) were added to support ; displaying the data in a nice web table and with a web page ; per measurement created. The table and individual web pages ; look to ~dd/xrcf/TRW_IDS/ to see if a trw_id.notes.html ; file is present. If so the first paragraph (up to

) ; is included in the table and the full contents are added ; to the individual web page. ; Gotta use the CMDB @cmdb_common ; define the cmdb column integers, e.g., c_detector if cmdb_using_cal then begin @cmdb_cal_integers end else begin @cmdb_trw_integers end ; Some hard coded locations etc. ; - - - - - - - - - - - - - - - - - - - - - web_dir = '/nfs/spectra/d6/ACIS_anal/' acis_dat_dir = '/nfs/spectra/d6/ACIS_anal/' marx_sim_dir = '/nfs/spectra/d6/MARX/' notes_dir = '/nfs/wiwaxia/h1/dd/xrcf/TRW_IDS/' ; Find and report all the Grating-ACIS measurements ; - - - - - - - - - - - - - - - - - - - - - ; Skip two of them (no PSU data) ; trw_id NE 'H-HAS-SC-7.006' AND trw_id NE 'H-HAS-PI-1.013' gacis = where(cmdb_fields(*,c_grating) NE 'NONE' AND $ (STRPOS(cmdb_fields(*,c_detector),'ACIS,I' ) GE 0 OR $ STRPOS(cmdb_fields(*,c_detector),'ACIS,S' ) GE 0) AND $ (cmdb_fields(*,c_id) NE 'H-HAS-SC-7.006' AND $ cmdb_fields(*,c_id) NE 'H-HAS-PI-1.013') ) ; Report by making a cmdb_summary listing... cmdb_mini_list, gacis, FILE_OUT = web_dir+'grating_acis_cmdb.html' ; Create the web table if desired ; - - - - - - - - - - - - - - - - - - - - - if KEYWORD_SET(TABLE) then begin OPENW, web_unit, web_dir+'acis_analysis_table.html', /GET printf, web_unit, '' printf, web_unit, '' printf, web_unit, '' printf, web_unit, '' end if KEYWORD_SET(TABLE) OR KEYWORD_SET(SIM) then begin ; Read in the data stats for use in the table or simulation data_stats = rdb_read(acis_dat_dir+'acis_data_stats.rdb') end ; Create the acis_data_stats.rdb if desired ; - - - - - - - - - - - - - - - - - - - - - if KEYWORD_SET(FORM_DATA_STATS) then begin ; Define the rdb structure: one_stat = {trw_id:'', nevents:0L, n02346events:0L} data_stats = REPLICATE(one_stat, n_elements(gacis)) end ; Go through these data sets and do what is selected... for im=0, n_elements(gacis)-1 do begin trw_id = cmdb_fields(gacis(im), c_id) print, '' print, trw_id ; If requested, form statistics file on the data sets ; - - - - - - - - - - - - - - - - - - - - - if KEYWORD_SET(FORM_DATA_STATS) then begin ; Restore the data set and measure the stats... restore, acis_dat_dir+trw_id+'_l1.idlsav' data_stats(im).trw_id = trw_id ; total number of events: data_stats(im).nevents = n_elements(l1) ; number with GRADE = 0,2,3,4,6 sel = where(l1.GRADE EQ 0 OR $ l1.GRADE EQ 2 OR $ l1.GRADE EQ 3 OR $ l1.GRADE EQ 4 OR $ l1.GRADE EQ 6 ) data_stats(im).n02346events = n_elements(sel) end ; If requested, simulate the measurements... ; - - - - - - - - - - - - - - - - - - - - - if KEYWORD_SET(SIM) then begin ; Set up all the sim directories and do the i0 simulations including ; creating the mL1 idlsav file. ; Can comment the next line out - only need to do once... ; on the other hand it doesn't take much time so could be left in... ;;xrcf_sim, trw_id ; only simulate the first iteration for now iter=0 if KEYWORD_SET(COMPARABLE) then begin ; simulate with small number of events small_num = 50000L xrcf_sim, trw_id, ITER=iter, /RUN, /POST, NumRays=small_num, $ N_POST=n_sim_events ; Calculate new NumRays based on n_sim_events and number of ; iterations (and 1/50 if [H|L]AS-MC-3.) this_ds = where(data_stats.trw_id EQ trw_id) ids = this_ds(0) data_num = data_stats(ids).n02346events its_rdb = rdb_read(marx_sim_dir+trw_id+'/'+trw_id+'_iters.rdb') n_iters = n_elements(its_rdb) mc_factor = 1. if STRPOS(trw_id, 'HAS-MC-3.') GE 0 OR $ STRPOS(trw_id, 'LAS-MC-3.') GE 0 then mc_factor = 0.02 ; Reduce MC-20.001 also: if STRPOS(trw_id, 'HAS-MC-20.001') GE 0 then mc_factor = 0.5 new_num = LONG( mc_factor * small_num * data_num / $ (FLOAT(n_sim_events) * n_iters) ) print, '' print, ' Re-simulating with NumRays = ', new_num xrcf_sim, trw_id, ITER=iter, /RUN, /POST, /IMAGE, NumRays=new_num end else begin ; simulate with default number of rays xrcf_sim, trw_id, ITER=iter, /RUN, /POST, /IMAGE end end ; of simulation ; make a small image of the real data for web page ; probably doesn't have to be done again but left here ; for the record ; - - - - - - - - - - - - - - - - - - - - - ; keep it in the ACIS_anal directory if KEYWORD_SET(SMALL_IMAGE) AND $ (STRPOS(trw_id,'-MC-') LT 0) then begin ; use PSU_VIEW... all these images have the same color table ; so they can be on the same web page (unlike the xye_image ; created images.) psu_view, trw_id, /SAVE ; makes 'anal.gif and saves idlsav psu_view, trw_id, /SMALL ; makes 'small.gif end ; small images if KEYWORD_SET(TABLE) then begin ; add to the acis_analysis.html table ; - - - - - - - - - - - - - - - - - - - - - printf, web_unit, '' printf, web_unit, '' printf, web_unit, '' ; Create a page for this TRW_ID to show the XRCF/MARX ; comparison image and all the notes. ; - - - - - - - - - - - - - - - - - - - - - OPENW, meas_unit, web_dir+trw_id+'.html', /GET printf, meas_unit, '
Event Plot w/ energy color-coded
' + $ '(click image for more data-summary plots)
CMDB line
[ N_OK_events]' printf, web_unit, '
TRW ID
' + $ '(click for Data/MARX images
and detailed Notes)' printf, web_unit, '
Summary of Analysis
' ; Get the number of events from data_stats: dsline = where(data_stats.trw_id EQ trw_id) ids = dsline(0) printf, web_unit, ''+STRING(gacis(im)+1)+'

['+ $ STRING(LONG(data_stats(ids).n02346events),FORMAT='(I9)')+']' printf, web_unit, '
' printf, web_unit, 'click here!
' printf, web_unit, '|
' printf, web_unit,'\|/
' printf, web_unit,'
' printf, web_unit, '' printf, web_unit, trw_id+'' printf, web_unit, '
' ; Look for trw_id.notes.html in notes_dir notes_file = FINDFILE(notes_dir+trw_id+'.notes.html',COUNT=notesfound) if notesfound EQ 1 then begin notes_file = notes_file(0) print, ' Found notes file...['+notes_file+']' OPENR, note_unit, notes_file, /GET done = 0 while NOT(EOF(note_unit)) AND NOT(DONE) do begin line_in = '' readf, note_unit, line_in printf, web_unit, line_in ; only include up to and including the first

line. if STRPOS(line_in, '

') GE 0 then done = 1 end CLOSE, note_unit FREE_LUN, note_unit end else begin print, ' (no notes)' printf, web_unit, 'No specific notes for '+trw_id+', yet.' end ; if its an ENERGY scan include the list of energies its_rdb = rdb_read(marx_sim_dir+trw_id+'/'+trw_id+'_iters.rdb') n_iters = n_elements(its_rdb) if its_rdb(0).type EQ 'ENERGY' then begin printf, web_unit, '

' efmt = '(F8.3)' es_string = STRING(its_rdb(0).param, efmt) for iit=1,n_iters-1 do es_string = es_string + ', ' + $ STRING(its_rdb(iit).param, efmt) es_string = STRCOMPRESS(es_string) printf, web_unit, 'Energy scan: '+es_string printf, web_unit, '

' end printf, web_unit, '
' if im EQ 0 then begin prev_id_str = '(at top of table)' end else begin prev_id_str = 'back: '+ $ prev_id+'' end if im EQ n_elements(gacis)-1 then begin next_id_str = '(at end of table)' end else begin next_id = cmdb_fields(gacis(im+1), c_id) next_id_str = 'next: '+ $ next_id+'' end printf, meas_unit, '
'+prev_id_str printf, meas_unit, '' printf, meas_unit, 'back to Analysis Table' printf, meas_unit, ''+next_id_str printf, meas_unit, '
' printf, meas_unit, '' printf, meas_unit, '
'+trw_id+'' printf, meas_unit, '


' printf, meas_unit, 'XRCF Data (upper: all iterations) '+ $ 'and MARX Simulation (lower: first iteration only)' printf, meas_unit, '

' ; if its an ENERGY scan include the list of energies its_rdb = rdb_read(marx_sim_dir+trw_id+'/'+trw_id+'_iters.rdb') n_iters = n_elements(its_rdb) if its_rdb(0).type EQ 'ENERGY' then begin printf, meas_unit, '

' efmt = '(F8.3)' es_string = STRING(its_rdb(0).param, efmt) for iit=1,n_iters-1 do es_string = es_string + ', ' + $ STRING(its_rdb(iit).param, efmt) es_string = STRCOMPRESS(es_string) printf, meas_unit, 'Energy scan: '+es_string printf, meas_unit, '

' end printf, meas_unit, '' printf, meas_unit, ''+trw_id+' Notes' printf, meas_unit, '' ; Now add all the notes if notesfound EQ 1 then begin OPENR, note_unit, notes_file, /GET while NOT(EOF(note_unit)) do begin line_in = '' readf, note_unit, line_in printf, meas_unit, line_in end CLOSE, note_unit FREE_LUN, note_unit end else begin printf, meas_unit, '

No analysis results for '+trw_id+', yet.

' end CLOSE, meas_unit FREE_LUN, meas_unit ; prev_id = trw_id end end if KEYWORD_SET(TABLE) then begin printf, web_unit, '' CLOSE, web_unit FREE_LUN, web_unit end if KEYWORD_SET(FORM_DATA_STATS) then begin rdb_write, acis_dat_dir+'acis_data_stats.rdb', data_stats end RETURN END