pro coinc_corr, cps, ecps, sat, pterm = pterm,theory=theory, newcoi=newcoi, $ deadtimecorr = deadtimecorr, frametime=frametime,verbose=verbose, $ ratio = ratio ;+ ; INPUT-OUTPUT: ; cps - Net counts per second in a 5" radius aperture. This will be ; modified upon output to contain the co-I corrected flux. Scalar ; or vector ; ecps -Error value(s) associated with cps. Will be modified upon output ; to contain the co-I corrected error ; OPTIONAL OUTPUT ; sat - vector the same size as cps having a value of 1 if the source ; is saturated and 0 otherwise. ; OPTIONAL KEYWORDS: ; /Theory - if set then the theoretical co-I correction is applied without ; any empirical correction ; /NewCoi - If set, then use the new coefficients derived by Wayne Landsman ; in Oct 2006. Otherwise, the CALDB coefficents are used. ; /DEADTIMECORR - set this keyword, if the supplied cps has already been ; corrected for deadtime. ; /FRAMETIME - frametime in ms, set to 0.0110329 if not supplied ; REVISION HISTORY: ; Written Wayne Landsman December 2005 ;- if N_params() LT 2 then begin print,'Syntax - COINC_CORR, cps, [ ecps, sat, pterm= , /theory, /NewCoi ]' print,' frametime=, deadtimecorr=' return endif if N_elements(frametime) EQ 0 then frametime = 0.0110329 deadfrac = 6e-7*290/frametime deadcorr = 1-deadfrac framecounts = cps*frametime eframecounts = ecps*frametime if keyword_set(deadtimecorr) then begin framecounts = framecounts*deadcorr eframecounts = eframecounts*deadcorr endif if keyword_set(verbose) then print,'Framecounts:',framecounts bad = where(framecounts GT 1,Nbad) sat = bytarr(N_elements(cps)) if Nbad Gt 0 then sat[bad] = 1b ;First correct the total rate cts_corr = -alog(1-framecounts)/(frametime*deadcorr) ecps_corr = eframecounts/(1-framecounts)/(frametime*deadcorr) if not keyword_set(theory) then begin pp = [ 1.,0.0658568, -0.0907142,0.0285951,0.0308063 ] if N_elements(pterm) gt 1 then pp =[1.0, pterm] corrRatio = poly(framecounts,pp) cts_corr = cts_corr*corrRatio ecps_corr = ecps_corr*corrRatio endif ratio = cts_corr/cps cps = cts_corr ecps= ecps_corr return end