pro selroi common SELROI_BLOCK,index,draw,data,plot,progs,newdata,filename3,filename4,$ moments2 @varld.cb fitparams=fltarr(nx0,ny0,9) moment_params window,2,xsize=150,ysize=400,title='Color Bar' progs=fltarr(3) top=widget_base(/column,title='Examine ROI') draw=widget_draw(top,xsize=600,ysize=600,/button,/motion,uvalue=5) label=widget_text(top,value='Select a map for choosing ROI:') buttons=widget_base(top,/column) row1=widget_base(buttons,/row) TAb=widget_button(row1,value='Antenna Temperature',uvalue=10) vlsrb=widget_button(row1,value='Velocity Centroid',uvalue=11) vdispb=widget_button(row1,value='Est. Line Width',uvalue=12) noiseb=widget_button(row1,value='Noise',uvalue=14) s2nb=widget_button(row1,value='Signal to Noise',uvalue=18) select=widget_button(top,value='Select Region of Interest...',uvalue=2) bye=widget_button(top,value='Done.',uvalue=1) widget_control,/realize,top widget_control,get_value=index, draw wset,index xmanager, 'selroi', top end ;----------------------------- pro selroi_event,event @varld.cb common SELROI_BLOCK common GUI_BLOCK widget_control, event.id, get_uvalue=buttonpress if (buttonpress eq 1) then begin widget_control,event.top,/destroy wdelete,2 end if (buttonpress eq 2) then begin if progs(0) ne 1. then begin oops=widget_message('Please Choose a Map to Examine') goto,skipout1 endif if progs(1) eq 1. then begin selscrplot,fitparams,plot,index,2 endif subs=cw_defroi(draw) widget_control,/hourglass sz=size(data) sx=float(sz(1)) sy=float(sz(2)) asp=(sy/sx) if asp ge 1 then begin xmarg=1-0.8/asp pos=[xmarg/2,0.1, 1-xmarg/2,0.9] endif else begin ymarg=1-0.8*asp pos=[0.1,ymarg/2,0.9,1-ymarg/2] endelse corners=600*pos x=floor(((subs mod 600)-corners(0))*(sx/(corners(2)-corners(0)))) y=floor((long(subs)/600-corners(1))*(sy/(corners(3)-corners(1)))) inbounds=(x ge 0)*(x le sx-1)*(y ge 0)*(y le sy-1) if total(inbounds) eq 0 then begin gotcha=widget_message('No Data in ROI') goto,skipout1 endif x=x(where(inbounds eq 1)) y=y(where(inbounds eq 1)) num=size(x) x0=min(x) x1=max(x) y0=min(y) y1=max(y) newdata=fltarr(x1-x0+1,y1-y0+1,nv0) newfits=fitparams(x0:x1,y0:y1,*) newfits(*,*,5)=1. for i=long(0),num(1)-1 do begin newdata(x(i)-x0,y(i)-y0,*)=data0(x(i),y(i),*) newfits(x(i)-x0,y(i)-y0,5)=0. endfor r=(res-1) data0=fltarr(x1-x0+1+r,y1-y0+1+r,nv0) fitparams=fltarr(x1-x0+1+r,y1-y0+1+r,9) fitparams(*,*,5)=1. data0(r/2:x1-x0+r/2,r/2:y1-y0+r/2,*)=newdata fitparams(r/2:x1-x0+r/2,r/2:y1-y0+r/2,*)=newfits sz=size(data0) nx0=sz(1) ny0=sz(2) progs(1)=1. skipout1: endif if (buttonpress ge 10) and (buttonpress le 25) then begin plot=buttonpress-10 fcn=[8,10,9,0,12,0,0,0,13] if (total(fitparams(*,*,plot) ne 99999.0) eq 0) then begin wset,index erase xyouts,0.2,0.5,'No Valid Data to Plot',/normal,charsize=3. goto,skipout endif dat1=fltarr(nx0,ny0,16) dat1(*,*,fcn(plot))=fitparams(*,*,plot) selscrplot,dat1,fcn(plot),index,2 data=fitparams(*,*,plot) progs(1)=0. progs(0)=1. skipout: endif end