;The function sumbadval finds the sum of the non-badval elements of a vector. ;Use is as follows: ; sum=sumbadval,variable ;Where ; input variable = vector with possible badvals ; ; output sum = sum of good elements of variable ; ;Note: badval is assumed to be -999. ; If no goodvals present sum=-999. ; ;Written by BWBerger 3/17/00 function sumbadval,variable badval=-999. g=where(variable ne badval,gc) if gc ge 1 then begin sum=total(variable(g)) endif else begin sum=-999. ; print,'No good vals for sumbadval. sum=-999.' endelse return,sum end