PRO eae_fill_from_cmdb, out_prefix ; This procedure uses the CMDB and outputs a giant file ; in the rdb eae data format (see xrcf_data.fmt) for ; HETG Effective Area / Efficiency measurements in the ; CMDB. ; ; Writes out files: out_prefix+'.rdb' and out_prefix+'.cmdb' ; ; 4/x/99 dd Only go through PHASE 1 and ACIS-2C Tests ; (Flight Detector analysis is carried out elsewhere.) ; ; 4/23/99 dd Add the HSI-with-grating measurements too... for use ; in HSI QE determination... @cmdb_common ; Data files needed and locations: ; . . . . . . . . . . . . . ; File with list of no-grating measurements to be included no_grats_file = !DDIDL+'/xrcf/eae_no_grats_meas.rdb' ; . . . . . . . . . . . . . ; Get cmdb integers if cmdb_using_cal then begin @cmdb_cal_integers end else begin @cmdb_trw_integers end ; Assume that the CMDB has already been read in. ; Define the rdb structure by reading in the default file rdb_struct = rdb_read(!DDIDL+'/xrcf/xrcf_data.default') ; Make it a single element: rdb_struct = rdb_struct(0) ; The last Phase F measurement is: F-I2C-PI-99.062 ; only use measurements up to this: last_line = where(cmdb_fields(*,c_id) EQ 'F-I2C-PI-99.062') last_line = last_line(0) ; Replicate the structure for as many lines as we'll check in the CMDB ; (not all of these will be used...) rdb_output = REPLICATE(rdb_struct, last_line+1) irdb = 0 ; point at the next rdb line to fill ; Keep track of the CMDB lines that are selected rdb_lines = 0 * indgen(last_line+1) ;Read in the list of direct-beam reference measurements to be included no_grats_rdb = rdb_read(no_grats_file) ; Go through the CMDB and select valid EA/Effic measurements for im=0, last_line do begin ; default: don't include it crit_ok = 0 if STRPOS(cmdb_fields(im,c_grating), 'HETG') GE 0 OR $ STRPOS(cmdb_fields(im,c_grating), 'LETG') GE 0 then begin ; Selection criteria with-Grating measurements: ; -Detector is FPC or SSD or ACIS(e.g., 2C) or HSI ; -NOT PSF in measurement type ; -NOT dF in measurement type ; -NOT MC, FC, SF, SC, BG in TRW ID ; -NOT monochromator scan ; - +1 or -1 or 0 order measured (concentrate on 0,1st orders for now) crit_ok = 1 if NOT( (STRPOS(cmdb_fields(im,c_detector),'FPC') GE 0) OR $ (STRPOS(cmdb_fields(im,c_detector),'SSD') GE 0) OR $ (STRPOS(cmdb_fields(im,c_detector),'HSI') GE 0) OR $ (STRPOS(cmdb_fields(im,c_detector),'ACIS') GE 0) )then crit_ok = 0 if STRPOS(cmdb_fields(im,c_type),'PSF') GE 0 then crit_ok = 0 if STRPOS(cmdb_fields(im,c_type),'dF') GE 0 then crit_ok = 0 if STRPOS(cmdb_fields(im,c_id),'-MC-') GE 0 then crit_ok = 0 if STRPOS(cmdb_fields(im,c_id),'-SF-') GE 0 then crit_ok = 0 if STRPOS(cmdb_fields(im,c_id),'-FC-') GE 0 then crit_ok = 0 if STRPOS(cmdb_fields(im,c_id),'-SC-') GE 0 then crit_ok = 0 if STRPOS(cmdb_fields(im,c_id),'-BG-') GE 0 then crit_ok = 0 if (STRPOS(cmdb_fields(im,c_source),'HIREF') GE 0 OR $ STRPOS(cmdb_fields(im,c_source),'DCM') GE 0) $ AND NOT( STRPOS(cmdb_fields(im,c_mono_range),'/') GE 0 OR $ cmdb_fields(im,c_mono_range) EQ '0' ) $ then crit_ok = 0 if TOTAL(abs(cmdb_data(im).order) EQ 1) + $ TOTAL(cmdb_data(im).order EQ 0) EQ 0 then crit_ok = 0 end ; ; no-grating measurements: if STRPOS(cmdb_fields(im,c_grating), 'NONE') GE 0 then begin ; also add in non-grating reference measurements ; (trickier to do automatically) ; - no HSI ; - submitted by has "MIT" or "HE/" or "ASC/HLM & HETG/DD" ; -NOT PSF in measurement type ; -NOT dF in measurement type ; -NOT SF in measurement ID ; -NOT -BG- in measurement ID ; -NOT monochromator scan ; - OR it is listed in the no_grats file crit_ok = 1 if NOT( (STRPOS(cmdb_fields(im,c_detector),'FPC') GE 0) OR $ (STRPOS(cmdb_fields(im,c_detector),'SSD') GE 0) OR $ (STRPOS(cmdb_fields(im,c_detector),'HRC') GE 0) OR $ (STRPOS(cmdb_fields(im,c_detector),'ACIS') GE 0) )then crit_ok = 0 if NOT(STRPOS(cmdb_fields(im,c_name),'MIT') GE 0 OR $ STRPOS(cmdb_fields(im,c_name),'HE/') GE 0 OR $ STRPOS(cmdb_fields(im,c_name),'ASC/HLM & HETG/DD') GE 0 ) $ then crit_ok = 0 if STRPOS(cmdb_fields(im,c_type),'PSF') GE 0 then crit_ok = 0 if STRPOS(cmdb_fields(im,c_type),'dF') GE 0 then crit_ok = 0 if STRPOS(cmdb_fields(im,c_id),'-SF-') GE 0 then crit_ok = 0 if STRPOS(cmdb_fields(im,c_id),'-BG-') GE 0 then crit_ok = 0 if (STRPOS(cmdb_fields(im,c_source),'HIREF') GE 0 OR $ STRPOS(cmdb_fields(im,c_source),'DCM') GE 0) $ AND NOT( STRPOS(cmdb_fields(im,c_mono_range),'/') GE 0 OR $ cmdb_fields(im,c_mono_range) EQ '0' ) $ then crit_ok = 0 nogs = where(no_grats_rdb.trw_id EQ cmdb_fields(im,c_id),n_nogs) if n_nogs GE 1 then crit_ok = 1 end ; ; now add in the measurement if selected if crit_ok then begin ; flag this cmdb line rdb_lines(im) = 1 ; print the ID to show progress... print, cmdb_fields(im,c_id) ; and load the data into the structure ; - - - - - rdb_struct.trw_id = cmdb_fields(im,c_id) rdb_struct.energy = cmdb_data(im).energy rdb_struct.wavelength = 12.3985/cmdb_data(im).energy ; ; Source info source_string = cmdb_fields(im,c_source) if STRPOS(source_string,'EIPS') GE 0 then begin source_string = cmdb_fields(im,c_target) end ; filter string filter_string = '' f1mat = cmdb_fields(im,c_filter_mat_1) f2mat = cmdb_fields(im,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 ; if filter_string NE '' then begin rdb_struct.source = source_string + ',' + filter_string end else begin rdb_struct.source = source_string end rdb_struct.shutters = cmdb_fields(im,c_shutters) rdb_struct.grating = cmdb_fields(im,c_grating) ; the grating from CMDB is HETG or LETG - change ; it to LEG, MEG, or HEG based on shutters too if rdb_struct.grating NE 'NONE' then begin if rdb_struct.grating EQ 'LETG' then rdb_struct.grating = 'LEG' if rdb_struct.grating EQ 'HETG' then begin if STRPOS(rdb_struct.shutters,'MEG') GE 0 then $ rdb_struct.grating = 'MEG' if STRPOS(rdb_struct.shutters,'HEG') GE 0 then $ rdb_struct.grating = 'HEG' end end ; Enter a single order even for multiple order meas.s ; Order 999 flags no-grating rdb_struct.order = cmdb_data(im).order(0) if rdb_struct.order GT 98 then rdb_struct.order = 999 rdb_struct.fp_detector = cmdb_fields(im,c_detector) ; modify the detector field: ; - remove ACIS from 2C name if STRPOS(rdb_struct.fp_detector,'2C') GE 0 then begin rdb_struct.fp_detector = STRMID(rdb_struct.fp_detector,5,80) end rdb_struct.iteration = '0' ; default ; Aperture size if STRPOS(cmdb_fields(im,c_detector),'SSD') GE 0 OR $ STRPOS(cmdb_fields(im,c_detector),'FPC') GE 0 then begin ; For the aperture, for SSD, FPC use the last pinhole, aplist = cmdb_fields(im,c_hxda_aplist) ; remove {}s aplist = STRMID(aplist,1,STRLEN(aplist)-2) ; divide it up by commas pieces = STR_SEP(aplist, ',') temp = 0.0 READS, pieces(n_elements(pieces)-1), temp rdb_struct.fp_aperture = temp ; Special case for some borrowed-from-HRMA-EE data ; where I select the 500 um aperture if STRPOS(rdb_struct.trw_id,'IXF-EE') GE 0 then begin rdb_struct.fp_aperture = 500.0 end end else begin ; For the other, imaging, detectors set an aperture... if STRPOS(cmdb_fields(im,c_detector),'HSI') GE 0 then begin ; Set aperture based on energy: if rdb_struct.energy LT 0.3 then begin rdb_struct.fp_aperture = 10000.0 end else begin rdb_struct.fp_aperture = 2000.0 end ; For HSI QE measurements set aperture to match FPC/SSD: if (rdb_struct.trw_id EQ 'D-LXH-3D-11.030') then $ rdb_struct.fp_aperture = 1000.0 if (rdb_struct.trw_id EQ 'D-HXH-3D-21.005') then $ rdb_struct.fp_aperture = 500.0 if (rdb_struct.trw_id EQ 'D-LXH-3D-22.028') then $ rdb_struct.fp_aperture = 1000.0 end if STRPOS(cmdb_fields(im,c_detector),'HRC,I') GE 0 then begin rdb_struct.fp_aperture = 90000.0 end if STRPOS(cmdb_fields(im,c_detector),'HRC,S') GE 0 then begin rdb_struct.fp_aperture = 20000.0 end if STRPOS(cmdb_fields(im,c_detector),'ACIS') GE 0 then begin rdb_struct.fp_aperture = 24000.0 end if STRPOS(cmdb_fields(im,c_detector),'2C') GE 0 then begin temp = 0.0 READS, cmdb_fields(im,c_acis_num_rows), temp rdb_struct.fp_aperture = temp*24.0 end end ; BND apertures bnd_info = cmdb_fields(im,c_hxda_bnd_status_code) ; remove leading { : bnd_info = STRMID(bnd_info, 1, 80) pieces = STR_SEP(bnd_info,',') p2 = STR_SEP(pieces(0),':') rdb_struct.ssd_5_aperture = p2(0) p2 = STR_SEP(pieces(1),':') rdb_struct.fpc_5_aperture = p2(0) p2 = STR_SEP(pieces(2),':') rdb_struct.fpc_hn_aperture = p2(0) ; - - - - - rdb_output(irdb) = rdb_struct irdb = irdb + 1 end end rdb_output = rdb_output(0:irdb-1) ; Default to current directory if n_elements(out_prefix) EQ 0 then out_prefix = 'eae_cmdb' ; Write the cmdb lines cmdb_write_lines, out_prefix+'.cmdb', $ where(rdb_lines NE 0) ; Output the rdb file rdb_write, out_prefix+'.rdb', rdb_output ; report on total... print, 'Found '+STRCOMPRESS(STRING(n_elements(rdb_output)))+' measurements' RETURN END