;The function meanbadval finds the mean of a collection of points excluding ;any points equal to -999. ;Use is as follows: ; m=meanbadval(variable) ;Where ; input | variable = a vector to be averaged excluding -999. points ; ; output | m = the average of variable excluding badval ; ;Note: If there are no good points the average is returned as -999. ; meanbadval2.pro is similar to this function but the value of the ; badval can be chosen to be anything. ; ;Written by BWBerger 1999(?) ;DMRicciuto 7/29/03: added silent keyword function meanbadval,variable, silent=silent badval=-999. g=where(variable ne badval,gc) if gc ge 1 then begin if gc ge 2 then begin mn=mean(variable(g)) endif else begin mn=variable(g) mn=mn(0) ;Assures that mn is not an array as output. ;This can really wreak havoc in codes using this routine. IF NOT keyword_set(silent) THEN BEGIN print,'Only one good val for meanbadval. mn=variable(g).' ENDIF endelse endif else begin mn=-999. ; print,'No good vals for meanbadval. mn=-999.' endelse return,mn end