;+ ; NAME ; RD_TGRS_SPEX ; PURPOSE ; Read in spectral accumulation files produced by the ; TGRS Data Analysis Software (TDAAS). ; Suitable for reading ANY TGRS data produced ; by the routine COUNT in TDAS. ; ; INPUTS ; ; OUTPUTS ; ; KEYWORDS ; FLUX - count rate in counts/sec/cm2/keV ; EFLUX - Poisson uncertainty on Flux ; EDGES - energy edges 2xNumber_of_channels ; UT- Start and end time in seconds from 1 jan 1979 ; UNITS - Units of flux ; AREA - Nominal detector geometric area, 35 cm2 ; LTIME - Sample live time ; TITLE - WIND/TGRS + DATE ; DET_ID- 1 ; FILES - CONTAINS the file with the .SPC files to use. ; ERROR- If spectrum is not read properly, error will be set to 1. ; CATEGORY ; TGRS, SPEX ; RESTRICTIONS - ; For use as a SPEX reader only ; HISTORY ; RAS, 23 - JULY - 1996, ADAPTED FROM RD_SPEC.PRO ; Version 2, 4-dec-1996, Use RD_TEXT, not RD_ASCII ; Version 3, 9-dec-1996, used wchan to limit number of channels! ;- pro rd_tgrs_spex, files=files, ut=ut, flux=flux, eflux=eflux,edges=edges, $ units=units, area=area, ltime=ltime, title=title, det_id=det_id, $ error=error, btype=btype, wchan=wchan, _extra=_extra error = 0 checkvar, wchan, indgen(2400), indgen(8192) f = findfile(files,count=count) if count eq 0 then goto, error_exit area = 35.0 det_id=1 units = ' s!u-1!n cm!u-2!n keV!u-1!n' f = rd_text(f(0)) count = n_elements(f) rd_tgrs_spec,f(0), uti, edges, fluxi, efluxi, btype=btypei ut = dblarr( 2, count) ut(0,0) = uti flux = reform(fluxi(wchan)) #(fltarr(count)+1.) eflux = reform(efluxi(wchan)) #(fltarr(count)+1.) btype = intarr(count)+btypei for i=0,count-1 do begin rd_tgrs_spec,f(i), uti, edges, fluxi, efluxi, btype=btypei, error=error if error then goto, error_exit ut(0,i) = uti flux(0,i) = (reform(fluxi))(wchan) eflux(0,i) = (reform(reform(efluxi)))(wchan) btype(i) = btypei endfor ;Check the order!! ord = sort(ut(0,*)) ut = ut(*, ord) flux = flux(*, ord) eflux = eflux(*, ord) btype = btype( ord) de = avg( edges(1,200:2000)-edges(0,200:2000)) dt = reform( ut(1,*)- ut(0,*), 1, count) live = reform( tgrs_livetime( flux * 35.0 * de ),1,count) for i=0,count-1 do begin flux(*,i) = flux(*,i) / live(i) eflux(*,i) = eflux(*,i) / live(i) endfor ltime = rebin( dt*live, n_elements(wchan), count) edges = edges(*,wchan ) wchan = where( edges(0,*) gt 30.0) wchan = wchan( where( wchan lt 8000) ) return error_exit: error = 1 print,'% RD_SPEC>> Error in reading ',filename end