function stddevs,imgs,help=help, skymode = skymode, masks = masks,nan=nan ;+ ; NAME: meds ; PURPOSE: ; return the standard deviations for a stack of images ; USAGE: ; function meds,imgs,help=help, skymode = skymode, masks = masks ; ; INPUTS: ; imgs a stack of images ; KEYWORDS: ; masks Bad pixel mask. 0=bad, 1=good ; skymode uses skymode.pro to find stddevs; disabled, not sure why ; RETURNS: ; an array containing the stddev for each image in the stack. ; That is, it computes the stddev for each image individually and ; returns all of those, rather than stddevning across images. ; ; HISTORY: ; 2004-10-6 split from meds.pro MDP ;- if n_params() lt 1 or keyword_set(help) then begin message,'function meds(imgs,/help,/skymode,[masks=])' endif sz = size(imgs) if sz[0] lt 3 then $ message,"First arguement to meds must be a 3D array." mm = fltarr(sz(3)) if keyword_set(masks) then begin szm = size(masks) if total(sz(0:3)-szm(0:3)) ne 0 then begin message, 'images & masks do not match!', /info help, imgs, masks stop endif endif for i=0,sz(3)-1 do begin ; if keyword_set(skymode) then $ ; mm(i) = skymode(imgs(*, *, i), /plot) $ ; else $ ; mm(i) = stddev(imgs(*,*,i)) if keyword_set(masks) then begin wg = where(masks(*, *, i) eq 1, ng) if (ng gt 0) then mm[i] = stddev((imgs[*, *, i])[wg], /nan) $ else message, 'no good pixels for image '+strc(i), /info endif else $ mm[i] = stddev(imgs[*,*,i],/nan) endfor return,mm end