;+ ; Get scan information structure from the appropriate I/O object. ; ;

This uses !g.line to determine which I/O object to get the ; information from, unless keep is set, in which case it gets it from ; the keep file. ; ;

Note that this may return more than one structure (an array of ; structures would be returned). This can happen if the same scan ; number appears in the data with more than one timestamp. The ; instance and timestamp keywords of the various data retrieval ; procedures (getscan, get, getnod, getps, etc) can be used to ; differentiate between these duplicate scans. The instance keyword ; in those cases corresponds to the element number of the array ; returned by scan_info. The timestamp keyword corresponds to the ; timestamp field in the scan_info structure. ; ;

The data corresponding to a given instance are always found in ; consecutive records. The index_start and nrecords fields can be ; used to get just the data associated with a specific instance. See ; the examples. ; ; The fields in the returned structure are: ;

; ; @param scan {in}{required}{type=integer} Scan number to get ; information on. ; ; @param file {in}{optional}{type=string} Limit the search for ; matching scans to a specific file. If omitted, scans are found in ; all files currently opened through filein (a single file) or dirin ; (possibly multiple files). ; ; @keyword keep {in}{optional}{type=boolean} If set, the scan ; information comes from the keep file. ; ; @keyword quiet {in}{optional}{type=boolean} When set, suppress most ; error messages. Useful when being used within another procedure. ; ; @keyword count {in}{optional}{type=integer} Returns the number of ; elements of the returned array of scan_info structures. ; ; @returns Scan information structure. Returns -1 on error. ; ; @examples ; Get all of the data associated with one scan. ;
;    a = scan_info(65)
;    indx = lindgen(a.nrecords) + a.index_start
;    d65 = getchunk(index=indx)
;    ... do stuff with d65, but don't forget to free it when done
;    data_free, d65
; 
;

; Find paired scan's and their info structure (e.g. position switched) ;

;    a = scan_info(65)
;    b = find_paired_info(a)
; 
; ; @version $Id$ ;- FUNCTION scan_info, scan, file, keep=keep, quiet=quiet, count=count compile_opt idl2 count = 0 if (n_elements(scan) eq 0) then begin usage,'scan_info' return, -1 endif result = -1 count = 0 if (keyword_set(keep)) then begin if (!g.lineoutio->is_data_loaded()) then begin result = !g.lineoutio->get_scan_info(scan,file,count=count,quiet=quiet) endif else begin if not keyword_set(quiet) then message, 'There is no data in the keep file',/info endelse endif else begin if (!g.line) then begin if (!g.lineio->is_data_loaded()) then begin result = !g.lineio->get_scan_info(scan,file,count=count,quiet=quiet) endif else begin if not keyword_set(quiet) then message, 'There is no data in the line file', /info endelse endif else begin if (!g.contio->is_data_loaded()) then begin result = !g.contio->get_scan_info(scan,file,count=count,quiet=quiet) endif else begin if not keyword_set(quiet) then message, 'There is no data in the continuum file', /info endelse endelse endelse if count le 0 and not keyword_set(quiet) then message,'That scan was not found',/info return, result END