;+
; NAME:
;	KILL_WILD
;
;
; PURPOSE:
;	To set wild values to a predetermined value
;
;
; CATEGORY:
;	Utils
;
;
; CALLING SEQUENCE:
;	clean = kill_wild(dirty, minval, maxval, replace)
;
;
; INPUTS:
;	dirty	An array which may have wild points in it.
;	minval	The value below which a point is considered wild
;	maxval	The value above which a point is considered wild
;	replace	The value to use in place of the wild values.
;
;
; OUTPUTS:
;	clean	A copy of dirty with the bad values replaced.
;
;
; MODIFICATION HISTORY:
;	Original: 2/7/03; SJT
;-

function kill_wild, dirty, minval, maxval, replace

clean = dirty
locs = where(dirty gt maxval or dirty lt minval, nwild)

if nwild ne 0 then clean[locs] = replace

return, clean

end
