function evennoise,plhold;incube,fitparams,thresh,tol ;------------------------------ ; Adds noise to achive a uniform signal to noise. ;------------------------------ @varld.cb incube=data0 thresh=s2n sz=size(incube) sx=sz(1) sy=sz(2) sv=sz(3) data=fltarr(sx*sy) count=-1 outcube=incube fitparam=fitparams reject=fitparam(*,*,5) for i=0,sx-1 do begin for j=0,sy-1 do begin if reject(i,j) ne 0 then goto,endloop counta=0 tryagain: counta=counta+1 noiseamp=sqrt((fitparam(i,j,0)/thresh)^2-fitparam(i,j,4)^2) oldat=reform(incube(i,j,*)) newdat=oldat+randomn(seed,sv)*noiseamp vpeakpt=fitparam(i,j,6) vdisppt=fitparam(i,j,7) sn2new=fitparam(i,j,0)/noise(newdat,vpeakpt,vdisppt,4,0) trial=abs((sn2new - thresh)/thresh) if counta ge 50 then begin print,'Could not add noise, Rejecting:',i,j fitparams(i,j,5)=16. goto,endloop endif if trial ge tol then goto,tryagain outcube(i,j,*)=newdat fitparams(i,j,8)=sn2new fitparams(i,j,4)=noiseamp count=count+1 data(count)=sn2new if finite(sn2new) ne 1 then stop endloop: endfor endfor data=data(0:count) print,moment(data) return,outcube end