function not_wild, x, nsd ; ; Returns 0-1 array (usable by the where function) indicating (with 1's) ; those elements of the input array x which are not "wild", which is ; defined as more than nsd estimated standard deviations from the median. ; The standard deviation is estimated as the 69.1 percentile minus the ; 30.9 percentile. If nsd is omitted, it defaults to 15 (rejecting very ; little if any data). ; ; B. Knapp, 1992-01-06, 1996-12-06 ; 1998-06-09, IDL v. 5 compliance ; 2001-10-09, refine std. deviation estimate ; ; Show usage? if n_params() eq 0 then begin print,'' message, 'usage: result = not_wild(x, [nsd])', /info return,'' endif ; if n_elements(x) eq 1 then begin ok = [1L] endif else begin s = x[sort(x)] p3 = percentile(s, 30.9) p5 = percentile(s, 50.0) p7 = percentile(s, 69.1) esd = (p7-p3) > 0. if n_elements(nsd) eq 0 then nsd=15. if (1.+esd) eq 1. then $ ok = lonarr(n_elements(x)) + 1 $ else $ ok = abs(x-p5) lt abs(nsd)*esd endelse return, ok end