PRO cmdb_list, HTML = html, NOPAGES = nopages, NOLINKS = nolinks ; Outputs the cmdb fields that have been read into common ; by cmdb_load. ; Does lots of smart formating to make it human readable and dense ; Output optimized for Phase 2 rehearsal ; 10/2/96 add /html output option to create html version with ; simulation links! ; 10/25/96 modify to use .trw file too @cmdb_common ; Define the column integers if cmdb_using_cal then begin @cmdb_cal_integers end else begin @cmdb_trw_integers end ; output file if KEYWORD_SET(HTML) then begin openw, html_unit, 'cmdb_list.html',/GET printf, html_unit, '
' printf, html_unit, ''
printf, html_unit, ''
printf, html_unit, ' '+$
'About the simulations'
printf, html_unit, ''
printf, html_unit, ' cmdb_list from file: '+cmdb_file_path+cmdb_file
printf, html_unit, ' '+SYSTIME()
printf, html_unit, ''
web_dir = 'http://space.mit.edu/HETG/phase1real_sim/'
end
print, ''
print, ' cmdb_list from file: '+cmdb_file_path+cmdb_file
print, ' '+SYSTIME()
print, ''
; Label the columns
column_def_string = 'line TRW ID Pri' + $
' Meas.Type Source Energy V Filter '+$
' Flux HRMA Grat Ord Shutters '+ $
' Yoff Zoff Defoc Detector ... ' +$
'FP.rate Int.time line#'
; Calculate total integration time while at it
hetg_time = 0.0
letg_time = 0.0
none_time = 0.0
; and watch source changes
last_source = ''
source_changes = 0
; save the generic detector names
det_name = STRARR(n_elements(cmdb_lines))
for ir=0,n_elements(cmdb_lines)-1 do begin
; print the column headings
if ir EQ 0 then begin
if KEYWORD_SET(HTML) then printf, html_unit, column_def_string
print, column_def_string
end else begin
; print the columns every time the suite changes
; This is too busy for TOGA, might be useful for real cal
if cmdb_fields(ir,c_suite) NE cmdb_fields(ir-1,c_suite) then begin
print, ' '
print, column_def_string
if KEYWORD_SET(HTML) then begin
printf, html_unit, ' '
printf, html_unit, column_def_string
end
end
end
; Source info
source_string = cmdb_fields(ir,c_source)
if STRPOS(source_string,'EIPS') GE 0 then begin
size_string = 'o' ; Not small and not N/A
if STRPOS(cmdb_fields(ir,c_spot_size),'SMALL') GE 0 $
then size_string = '.'
if STRPOS(cmdb_fields(ir,c_spot_size),'N/A') GE 0 $
then size_string = ' '
source_string = $
size_string+cmdb_fields(ir,c_target)
end
scanchar = ' '
if (STRPOS(cmdb_fields(ir,c_source),'HIREF') GE 0 OR $
STRPOS(cmdb_fields(ir,c_source),'DCM') GE 0) $
AND STRPOS(cmdb_fields(ir,c_mono_range),'.') GE 0 $
then scanchar = '*'
source_string = strpad(source_string + scanchar, 9)
; count source changes
if source_string NE last_source then begin
source_changes = source_changes + 1
last_source = source_string
end
; put the source voltage and filters together
filter_string = STRPAD(cmdb_fields(ir,c_voltage),3,/CLIP)+' '
f1mat = cmdb_fields(ir,c_filter_mat_1)
f2mat = cmdb_fields(ir,c_filter_mat_2)
mfp = 0.0
if NOT( strpos(f1mat,'N/A') GE 0 OR strpos(f1mat,'NONE') GE 0 ) $
then begin
filter_string = filter_string + f1mat
mfp = 2.0
; filter 1 is added to string
end else begin
; no filter 1
end
if NOT( strpos(f2mat,'N/A') GE 0 OR strpos(f2mat,'NONE') GE 0 ) $
then begin
; there is a filter 2
; if it is the same as the first add 4. to the mfp and finish string
if f2mat EQ f1mat then begin
mfp = mfp + 4.0
filter_string = filter_string + 'x'+STRING(FIX(mfp),FORMAT='(I1)')
end else begin
; different from first
if mfp GT 1.0 then begin
; first was valid, output its mfp
filter_string = filter_string + 'x'+STRING(FIX(mfp),FORMAT='(I1)')
; and output the second filter
filter_string = filter_string + ','+f2mat
mfp = 4.0
filter_string = filter_string + 'x'+STRING(FIX(mfp),FORMAT='(I1)')
end else begin
; first was not valid - output second
filter_string = filter_string + f2mat
mfp = 4.0
filter_string = filter_string + 'x'+STRING(FIX(mfp),FORMAT='(I1)')
end
end
end else begin
; no filter 2
; if mfp GT 1.0 then add it to string
if mfp GT 1.0 then filter_string = filter_string + 'x'+STRING(FIX(mfp),FORMAT='(I1)')
end
; Make HRMA string
if cmdb_using_cal then begin
hrma_str = cmdb_fields(ir, c_hrma_polar)+','+cmdb_fields(ir, c_hrma_az)
hrma_str = STRPAD(hrma_str,9)
end else begin
hrma_str = cmdb_fields(ir, c_hrma_pitch)+','+cmdb_fields(ir, c_hrma_yaw)
hrma_str = STRPAD(hrma_str,9)
end
; Make grating info string
grat_string = cmdb_fields(ir,c_grating)
if STRPOS(cmdb_fields(ir,c_grating),'TOGA') GE 0 then begin
if cmdb_using_cal then begin
grat_string = cmdb_fields(ir,c_hetg_subset)
end
end
grat_string = STRCOMPRESS(grat_string,/REMOVE_ALL)
if cmdb_using_cal then begin
ord_str = STRPAD(cmdb_fields(ir, c_order),3)
end else begin
ord_str = ' '
end
; Make shutter info
shut_db_string = STRCOMPRESS(cmdb_fields(ir,c_shutter),/REMOVE_ALL)
shut_string = shut_db_string ; default if nothing picked up below
; If it is not DISCRETE just remove the {}s
if STRPOS(shut_db_string,'DISCRETE') LT 0 $
then shut_string = STRMID(shut_db_string, 1, $
STRLEN(shut_db_string)-2)
; Decode the Discrete for TOGA
if STRPOS(cmdb_fields(ir,c_shutter),'DISCRETE') GE 0 then begin
; decode the yucky discrete string
; hard coded for Rehearsal now...
pieces = str_sep(cmdb_fields(ir,c_shutter),',')
open_shutters=where(STRPOS(pieces,'6') GE 0 OR STRPOS(pieces,'1') GE 0)
shutter_names = ['-','T','N','B','S']
shut_string = ''
for is=0,n_elements(open_shutters)-1 do shut_string = $
shut_string + shutter_names(open_shutters(is))
end
det_string = cmdb_fields(ir,c_detector)
det_name(ir) = ''
if STRPOS(det_string,'2C') GE 1 then begin
det_name(ir) = '2C'
;assemble a useful '2C string
det_string = '2C'+':'+cmdb_fields(ir,c_acis_frametime)
det_string = STRPAD(STRCOMPRESS(det_string, /REMOVE_ALL),8)
det_string = det_string + ' ' + $
STRPAD(cmdb_fields(ir,c_acis_proc_mode),8)
end else begin
if STRPOS(det_string,'HSI') GE 0 then begin
det_string = STRPAD(det_string,17) ; that's all the info...
det_name(ir) = 'HSI'
end else begin
det_string = STRPAD(det_string,6)
; other detectors have apertures
; look to the hxda_aplist for the aperture information
aplist = cmdb_fields(ir,c_hxda_aplist)
; remove {}s
aplist = STRMID(aplist,1,STRLEN(aplist)-2)
; divide it up by commas
pieces = STR_SEP(aplist, ',')
; if it is more than one then say "aplist"
if n_elements(pieces) GT 1 then begin
det_string = det_string+'aplist'
end else begin
det_string = det_string+pieces(0)
end
; add -B if beam center is specified
bstr = cmdb_fields(ir,c_beam_center)
; remove {}s
bstr = STRMID(bstr,1,STRLEN(bstr)-2)
if NOT(bstr EQ 'N/A' OR bstr EQ 'NO') then begin
det_string = det_string+'-B'
end
det_string = STRPAD(det_string,17)
if STRPOS(det_string,'SSD') GE 0 then det_name(ir) = 'SSD' else $
det_name(ir) = 'FPC'
end ; HSI?
end ; 2C?
time_string = cmdb_fields(ir, c_integ_time)
; if cmdb_using_cal then begin
; mincnt = cmdb_fields(ir,c_min_fp_counts)
; if NOT(STRPOS(mincnt,'APT') GE 0 OR STRPOS(mincnt,'N/A') GE 0) $
; then time_string = time_string+',min'
; end
if STRPOS(time_string, 'NaN') LT 0 then begin
; keep track of total time
READS, time_string, ftime
CASE grat_string OF
'HETG': hetg_time = hetg_time + FLOAT(ftime)
'LETG': letg_time = letg_time + FLOAT(ftime)
ELSE: none_time = none_time + FLOAT(ftime)
ENDCASE
end
mult_string = STRCOMPRESS(cmdb_fields(ir,c_multiplicity),/REMOVE_ALL)
if mult_string NE '1' then time_string = time_string + '(' + $
mult_string+')'
; bnd_string = ' - '
; if cmdb_using_cal then begin
; bnd_counts = STRCOMPRESS(cmdb_fields(ir,c_min_bnd_counts),/REMOVE_ALL)
; if (STRPOS(bnd_counts,'0') NE 0 AND $
; STRPOS(bnd_counts,'N/A') LT 0) AND $
; STRPOS(cmdb_fields(ir,c_bnd_h_stat),'Y') GE 0 then begin
; bnd_string = ' Y '
; end
; if (STRPOS(bnd_counts,'0') EQ 0 OR $
; STRPOS(bnd_counts,'N/A') GE 0) AND $
; STRPOS(cmdb_fields(ir,c_bnd_h_stat),'N') GE 0 then begin
; bnd_string = ' '
; end
; end
; parse out the line number and first 8 file characters only
if cmdb_using_cal then begin
pieces = STR_SEP(cmdb_fields(ir,c_comment), ',')
end else begin
pieces = STR_SEP(cmdb_fields(ir,c_Suite_file_address), ',')
end
line_number = pieces(1)
; Y, Z, and defocus
if cmdb_using_cal then begin
YZd_str = strpad(cmdb_fields(ir,c_offset_y),5,/CLIP) + ' ' +$
strpad(cmdb_fields(ir,c_offset_z),5,/CLIP) + ' ' +$
strpad(cmdb_fields(ir,c_defocus),5,/CLIP) + ' '
end else begin
if STRPOS(cmdb_fields(ir,c_measurement_config),'HXDA') GE 0 then begin
YZd_str = strpad(cmdb_fields(ir,c_HXDA_Y),5,/CLIP) + ' ' +$
strpad(cmdb_fields(ir,c_HXDA_Z),5,/CLIP) + ' ' +$
strpad(cmdb_fields(ir,c_HXDA_defocus),5,/CLIP) + ' '
end else begin
end
end
if cmdb_using_cal then begin
fp_rate_str = strpad(cmdb_fields(ir,c_est_fp_rate),7) + ' '
end else begin
fp_rate_str = strpad(' -',7) + ' '
end
;
; Finally form and print the line!
line_summary1 = strpad(STRING(ir+1,FORMAT='(I3)'),5)
line_summary2 = strpad(cmdb_fields(ir,c_id),16)
line_summary3 = strpad(cmdb_fields(ir,c_priority),3) + $
strpad(cmdb_fields(ir,c_type), 10, /CLIP) + ' ' + $
source_string + ' ' + $
strpad(cmdb_fields(ir,c_energy),6,/CLIP) + ' ' + $
strpad(filter_string,12) +$
strpad(cmdb_fields(ir,c_flux),10) + $
hrma_str + $
strpad(grat_string,5) + $
ord_str + ' ' + $
strpad(shut_string,10) + $
YZd_str + $
det_string + $
fp_rate_str + $
strpad(time_string,10) + $
; bnd_string + $
line_number
print, line_summary1 + line_summary2 + line_summary3
; Add the line to the cmdb_list.html file if desired
if KEYWORD_SET(HTML) then begin
id = cmdb_fields(ir,c_id)
; references the ID.html
if KEYWORD_SET(NOLINKS) then begin
printf, html_unit,line_summary1+$
''+line_summary2+''+ $
line_summary3
end else begin
printf, html_unit,line_summary1+$
''+line_summary2+''+ $
line_summary3
end
if NOT(KEYWORD_SET(NOPAGES)) then begin
; ---------------------
; create ID.html (leave it in local dir just like cmdb_list.html)
OPENW, id_unit, id+'.html', /GET
printf, id_unit, ''+id+' Simulation '
printf, id_unit, ''
if ir NE 0 then begin
prev_id = cmdb_fields(ir-1,c_id)
prev_str = '[ Prev: '+prev_id+' ]'
end else begin
prev_str = '[ . . . . . . . . . . ]'
end
if ir NE n_elements(cmdb_lines)-1 then begin
next_id = cmdb_fields(ir+1,c_id)
next_str = '[ Next: '+next_id+' ]'
end else begin
next_str = '[ . . . . . . . . . . ]'
end
cmdb_str = '[ to CMDB list ]'
; Now make the page body
; Put the images first
printf, id_unit, ' +'_events.gif'+ $
')
+'_e_hist.gif)
'
printf, id_unit, ' . . . . . . . . . . . . Events hitting the '+det_name(ir)+$
' . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . '+ $
'and their Energy Histogram . . . . . .
'
printf, id_unit, ''+id+'
'
printf, id_unit, '
'
printf, id_unit, ''
printf, id_unit, next_str+' . . . . '+prev_str+' . . . . '+cmdb_str
printf, id_unit, '
if det_name(ir) EQ '2C' OR det_name(ir) EQ 'HSI' then begin
printf, id_unit, ' +'_y.gif'+ $
')

'
printf, id_unit, ' . . . . . . . . . . . Energy vs Y Scatter Plot for the '+ $
det_name(ir)+$
' . . . . . . . . . . . . . . . . . . . . . . . . . '+ $
'and the Source Spectrum . . . . . .
'
printf, id_unit, ''+id+'
'
printf, id_unit, '
'
printf, id_unit, ''
printf, id_unit, next_str+' . . . . '+prev_str+' . . . . '+cmdb_str
printf, id_unit, '
printf, id_unit, ' 

'
printf, id_unit, ' . . . . . . . . . . . . ' + $
'All events in Facility Coords including '+det_name(ir)+$
' outline . . . . . . . . . . . . . . . . . . . . . '+ $
'and the BND Spectrum . . . . . .
'
printf, id_unit, ''+id+'
'
printf, id_unit, '
'
printf, id_unit, ''
printf, id_unit, next_str+' . . . . '+prev_str+' . . . . '+cmdb_str
printf, id_unit, '
printf, id_unit, ' 
'
printf, id_unit, ' . . . . . . . . . . . '+ $
' . . . . Energy-Y Scatter Plot for all events in Facility Coords . . . .
'
printf, id_unit, ''+id+'
'
printf, id_unit, '
'
printf, id_unit, ''
printf, id_unit, next_str+' . . . . '+prev_str+' . . . . '+cmdb_str
printf, id_unit, '
end else begin
printf, id_unit, ' 

'
printf, id_unit, ' . . . . All Events in Facility Coords including '+ $
det_name(ir)+$
' outline . . . . . . . . . . . . . . . . . . . . . . '+ $
'and the Source Spectrum . . . . .
'
printf, id_unit, ''+id+'
'
printf, id_unit, '
'
printf, id_unit, ''
printf, id_unit, next_str+' . . . . '+prev_str+' . . . . '+cmdb_str
printf, id_unit, '
printf, id_unit, ' 

'
printf, id_unit, ' Energy-Y Scatter Plot for all Events in Facility Coords . . . . . . . . . . . . . . . . and the BND Spectrum
'
printf, id_unit, ''+id+'
'
printf, id_unit, '
'
printf, id_unit, ''
printf, id_unit, next_str+' . . . . '+prev_str+' . . . . '+cmdb_str
printf, id_unit, '
end
printf, id_unit, ''
printf, id_unit, ''
close, id_unit
free_lun, id_unit
; ---------------------
end
end
end
print, ''
print, ' Notes:'
print, ' - spot_size for EIPS is indicated by:'
print, ' . spot_size = SMALL'
print, ' spot_size = N/A'
print, ' o spot_size = (other)'
print, ' - * indicates monochromator is scanned'
print, ' - Beam centering is indicated with a -B after aperture size'
print, ' - multiplicity is shown in ()s after Integ.time'
;print, ' - specification of min_fp_counts is shown by "min" after Integ.time'
;print, ' - BND = Y indicates that bnd_h_stat = YES; min_bnd_counts should'
;print, ' then be non-zero.
;print, ' BND = ? is set if the values of bnd_h_stat and min_bnd_counts'
;print, ' are conflicting (YES and no counts, or NO and counts).
print, ' '
print, ' - HETG Integ.time = ' + $
STRING(hetg_time/(3600.*24.), $
FORMAT='(F6.2)') + ' days'
print, ' - LETG Integ.time = ' + $
STRING(letg_time/(3600.*24.), $
FORMAT='(F6.2)') + ' days'
print, ' - No-grat Int.time = ' + $
STRING(none_time/(3600.*24.), $
FORMAT='(F6.2)') + ' days'
print, ' - Total source changes = '+ $
STRING(source_changes,FORMAT='(I4)')
if KEYWORD_SET(HTML) then begin
; same as prints above but with print, --> printf, html_unit,
; - - - - - - - -
printf, html_unit, ''
printf, html_unit, ' Notes:'
printf, html_unit, ' - spot_size for EIPS is indicated by:'
printf, html_unit, ' . spot_size = SMALL'
printf, html_unit, ' spot_size = N/A'
printf, html_unit, ' o spot_size = (other)'
printf, html_unit, ' - * indicates monochromator is scanned'
printf, html_unit, ' - Beam centering is indicated with a -B after aperture size'
printf, html_unit, ' - multiplicity is shown in ()s after Integ.time'
;printf, html_unit, ' - specification of min_fp_counts is shown by "min" after Integ.time'
;printf, html_unit, ' - BND = Y indicates that bnd_h_stat = YES; min_bnd_counts should'
;printf, html_unit, ' then be non-zero.
;printf, html_unit, ' BND = ? is set if the values of bnd_h_stat and min_bnd_counts'
;printf, html_unit, ' are conflicting (YES and no counts, or NO and counts).
printf, html_unit, ' '
printf, html_unit, ' - HETG Integ.time = ' + $
STRING(hetg_time/(3600.*24.), $
FORMAT='(F6.2)') + ' days'
printf, html_unit, ' - LETG Integ.time = ' + $
STRING(letg_time/(3600.*24.), $
FORMAT='(F6.2)') + ' days'
printf, html_unit, ' - No-grat Int.time = ' + $
STRING(none_time/(3600.*24.), $
FORMAT='(F6.2)') + ' days'
printf, html_unit, ' - Total source changes = '+ $
STRING(source_changes,FORMAT='(I4)')
; - - - - - - - -
end
if KEYWORD_SET(HTML) then begin
printf, html_unit, ''
printf, html_unit, ''
close, html_unit
free_lun, html_unit
end
RETURN
END