;+ ; Project : SDAC ; ; Name : GRS_CLEAN_PHA ; ; Purpose : This procedure reads and cleans the GRS main pha data. ; ; Category : SMM, GRS ; ; Explanation : The GRS PHA can have errors in some records due to bad bits ; or overflow in an 8 bit register in the Sum Spectrum. They ; are cleaned by either the Jumper.pro algorithm or by looking ; for isolated bad data. ; ; Use : Clean_pha = GRS_CLEAN_PHA( [File] ) ; ; Inputs : File - full file name, optional if grs_extract already has ; read a datafile. ; ; Opt. Inputs : None ; ; Outputs : None ; ; Opt. Outputs: None ; ; Keywords : START_TIME- Accumulate from the Major Frame including this time, ANYTIM readable. ; END_TIME - Accumulate to the Major Frame including this time, ANYTIM readable. ; ALL_REC_TYPE - If set include all GRS record types, except low power. ; otherwise only Normal night and Normal day records. ; Record types ; 0, undef; 1, In-flight Cal day; 2, Normal night; 3, IFC night; ; $; 4, normal; 5, Not used; 6, Low Power SAA, short record! ; SING - Singles Spectra. ; SUM - Multiple Detectors Spectra. ; Calls : JUMPER, GRS_EXTRACT ; ; Common : None ; ; Restrictions: ; ; Side effects: None. ; ; Prev. Hist : ; ; Modified : Version 1, ras, 21-mar-1997 ; ;- ;============================================================================== function grs_clean_pha, file, start_time=start_time, end_time=end_time, $ all_rec_type=all_rec_type, sum=sum, sing=sing sum = grs_extract(file, /sum_spec, start_time=start_time, end_time=end_time, $ all_rec_type=all_rec_type) wover = where( sum ge 256, nover) if nover ge 1 then sum(wover) = 0 ;may need to set a livetime here for i=0,n_elements(sum(0,*))-1 do begin jumper, sum(100-indgen(94),i) *256l, reset, summed=nn, /single if total(nn) eq 0 or total(nn) eq 1 then sum(100-indgen(94),i) = reset/256l endfor sing = grs_extract( /sing_spec, start_time=start_time, end_time=end_time, $ all_rec_type=all_rec_type) wout = where( sing ge 1.6e4 or sing lt 0, nout) if nout ge 1 then sing(wout) = 0 ;may need to set a livetime here return, sing+sum end