;+ ;nplot,x,y,ston,_EXTRA=ex ;a little pro to calculate the noise in an area of continuum interactively ;use this just like plot, with all the same keywords, except add one if you want to save the signal to noise ; then follow the instructions prompted ;a little pro to calculate the noise in an area of continuum interactively ;by Conor Laver 06/11/2006 ;written during the World Cup '06 ;- FUNCTION noise,x,y,usermin,usermax,_extra=ex max=min(where(x ge usermax)) min=max(where(x le usermin)) xrang=x[min:max] region=y[min:max] coeff=poly_fit(xrang,region,2,yfit=cont) rect=region-cont ;print,'The standard deviation is(meaningless if there is a slope): ' + string(stddev(region)) print,'The mean is: ' + string(mean(region)) print,'The standard deviation of the straightened region(real): ' +string(stddev(rect)) print,'The mean of the straightened region is(hopefully close to zero): ' + string(mean(rect)) print,'The average signal to noise is: ' + string(mean(region)/stddev(rect)) !p.multi=[0,1,2] plot,x,y,_extra=ex,title='Region picked' ver,usermin,linestyle=2 ver,usermax,linestyle=2 items=['Mean of Selected Region is: ' + strtrim(mean(region),2),'Std Dev of the flattened region is: '+strtrim(stddev(rect),2),'The Signal to Noise is: '+ string(mean(region)/stddev(rect))] plot,xrang,region,title='2nd Order fit' oplot,xrang,cont legend,items,/bottom !p.multi=[0,1,1] ston=mean(region)/stddev(rect) return,ston end PRO nplot,x,y,ston,_EXTRA=ex ;window,8,title='Evaluate noise',xsize=700,ysize=500 plot,x,y,_extra=ex print,'Click on the minimum x range' cursor,xmin,ydata,/data,/down ver,xmin,linestyle=2 print,'Click on the maximum x range' cursor,xmax,ydata,/data,/down ver,xmax,linestyle=2 ston=noise(x,y,xmin,xmax,_extra=ex) end