PRO xss_from_unix, db_file, line_string ; - - - - - - - - - - - - - - - - - - - - - - - - - - ; The two strings above are the "input" from unix ; db_file = 'the full file specification for a .cal or .trw file' ; line_string = 'a string to specify what lines should be simulated' ; e.g.: line_string = '10' : line 10 (11th physical line) ; line_string = 'SF-2.001' : some piece of the TRW ID ; all matching IDs will be sim'ed ; MUST HAVE A "-" or "." in it! ; line_string = '1:93' : range of line numbers ; line_string = '1:10000' ; does all lines ; ; IDL commands to simulate XSS spectra and BND histogram ; Usage: ; on unix command line: idl simulate_xss.pro ; ; There are some IDL unix environment variables ; that need to be set up as well: ; setenv IDL_DEVICE X ; setenv IDL_DIR /apr/idl/idl_4 ; setenv IDL_PATH +/apr/idl/idl_4/lib: ; most important: ; setenv IDL_STARTUP xss_startup.pro ; ; The output is created by ~dd/idl/cmdb/xss_sim.pro ; ; PRO xss_sim, row_todo ; Generates an approximation to the XSS spectrum ; for a given CMDB file/line ; Requires that the CMDB file be loaded already ; (by ~dd/idl/cmdb/cmdb_load). ; Calling Sequence: ; ; xss_sim[, row] ; ; Arguments: ; ; row Integer row of the cmdb to be used, rows start ; with row 1. ; If no row_todo is specified then the internal ; values are used to model a source. Editing this ; file can change those "manual" inputs. ; ; Keywords: ; NONE (yet!) ; ; Output products: ; ; twr_id.spec Spectrum file in MARX format ; twr_id.spec.ps Plot of spectrum ; twr_id.BND.ps Plot of spectrum as seen by a BND in 1000 sec.s ; twr_id.BND.hist The BND simulation in two column format (E, counts) ; @cmdb_common print, '.....................................' print, ' Simulating XSS ...' ; Load the CMDB cmdb_file_path = '' ; cmdb_file has full path name cmdb_load, db_file ; and the cmdb column integers if cmdb_using_cal then begin @cmdb_cal_integers ; include file - can't indent end else begin @cmdb_trw_integers end ; Do the real work... ; Decode the line_string string ; and put line numbers in lines_todo array if STRPOS(line_string,':') GE 0 then begin ; range of lines pieces = STR_SEP(line_string, ':') if N_elements(pieces) NE 2 then begin print, ' * xss_simulate: invalid line_string ['+line_string+']' EXIT end else begin start = 0 stop = 0 READS, pieces(0), start READS, pieces(1), stop ; These input lines go from 1 to ... ; Change to internal lines 0 to ... lines_todo = start + indgen(1+stop-start) - 1 end end else begin if STRPOS(line_string,'-') GE 0 OR STRPOS(line_string,'.') GE 0 then begin ; match TRW id matches = where(STRPOS(cmdb_fields,line_string) GE 0, nmatch) if nmatch LE 0 then begin print, " * xss_simulate: couldn't match ["+line_string+']' EXIT end else begin lines_todo = matches end end else begin ; just a single line # lines_todo = 0 READS, line_string, lines_todo lines_todo = [lines_todo-1] end end ; Check the range if MIN(lines_todo) LT 0 then begin print, ' xss_from_unix: lines_todo LT 0' EXIT end ; Keep only lines to do that are less than the max in the ; CMDB keep = where(lines_todo LT n_elements(cmdb_lines),nkeep) if nkeep LE 0 then begin print, ' xss_from_unix: no valid lines to do?!' EXIT end lines_todo = lines_todo(keep) ; Let'em know what is going to be simmed print, '' print, '.....................................' print, 'Will simulate spectra from TRW IDs:' for il=0,n_elements(lines_todo)-1 do begin print, STRING(1+lines_todo(il)) + ' ' + cmdb_fields(lines_todo(il),c_id) end print, '.....................................' print, '' ; OK, do the simulations for il = 0, n_elements(lines_todo)-1 do begin xss_sim, lines_todo(il) print, '.....................................' end EXIT ; back to unix! RETURN END