/usr/share/gnudatalanguage/astrolib/meanclip.pro is in gdl-astrolib 2018.02.16+dfsg-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | PRO MEANCLIP, Image, Mean, Sigma, CLIPSIG=clipsig, MAXITER=maxiter, $
CONVERGE_NUM=converge_num, VERBOSE=verbose, SUBS=subs,DOUBLE=double
;+
; NAME:
; MEANCLIP
;
; PURPOSE:
; Computes an iteratively sigma-clipped mean on a data set
; EXPLANATION:
; Clipping is done about median, but mean is returned.
; Called by SKYADJ_CUBE
;
; CATEGORY:
; Statistics
;
; CALLING SEQUENCE:
; MEANCLIP, Data, Mean, [ Sigma, SUBS =
; CLIPSIG=, MAXITER=, CONVERGE_NUM=, /VERBOSE, /DOUBLE ]
;
; INPUT POSITIONAL PARAMETERS:
; Data: Input data, any numeric array
;
; OUTPUT POSITIONAL PARAMETERS:
; Mean: N-sigma clipped mean.
; Sigma: Standard deviation of remaining pixels.
;
; INPUT KEYWORD PARAMETERS:
; CLIPSIG: Number of sigma at which to clip. Default=3
; MAXITER: Ceiling on number of clipping iterations. Default=5
; CONVERGE_NUM: If the proportion of rejected pixels is less
; than this fraction, the iterations stop. Default=0.02, i.e.,
; iteration stops if fewer than 2% of pixels excluded.
; /VERBOSE: Set this flag to get messages.
; /DOUBLE - if set then perform all computations in double precision.
; Otherwise double precision is used only if the input
; data is double
; OUTPUT KEYWORD PARAMETER:
; SUBS: Subscript array for pixels finally used.
;
;
; MODIFICATION HISTORY:
; Written by: RSH, RITSS, 21 Oct 98
; 20 Jan 99 - Added SUBS, fixed misplaced paren on float call,
; improved doc. RSH
; Nov 2005 Added /DOUBLE keyword, check if all pixels are removed
; by clipping W. Landsman
;-
IF N_params() LT 1 THEN BEGIN
print, 'CALLING SEQUENCE: MEANCLIP, Image, Mean, Sigma'
print, 'KEYWORD PARAMETERS: CLIPSIG[=3], MAXITER[=5], CONVERGE_NUM[=0.02], ' $
+ '/VERBOSE, SUBS, /DOUBLE'
RETURN
ENDIF
prf = 'MEANCLIP: '
verbose = keyword_set(verbose)
IF n_elements(maxiter) LT 1 THEN maxiter = 5
IF n_elements(clipsig) LT 1 THEN clipsig = 3
IF n_elements(converge_num) LT 1 THEN converge_num = 0.02
subs = where(finite(image),ct)
iter=0
REPEAT BEGIN
skpix = image[subs]
iter = iter + 1
lastct = ct
medval = median(skpix)
mom = moment(skpix,max=2,double=double)
sig = sqrt(mom[1])
wsm = where(abs(skpix-medval) LT clipsig*sig,ct)
IF ct GT 0 THEN subs = subs[wsm]
ENDREP UNTIL (float(abs(ct-lastct))/lastct LE converge_num) $
OR (iter GT maxiter) or (ct EQ 0)
mom = moment(image[subs],double=double,max=2)
mean = mom[0]
sigma = sqrt(mom[1])
IF verbose THEN BEGIN
print, prf+strn(clipsig)+'-sigma clipped mean'
print, prf+'Mean computed in ',iter,' iterations'
print, prf+'Mean = ',mean,', sigma = ',sigma
ENDIF
RETURN
END
|