; ;****************************************************************************** ; ; ----------------------------Support procedures------------------------------ ; ;****************************************************************************** ; pro xeqwidth_initcommon common xeqwidth_state, state ; Build three structures which will hold important info. ; w - contains info pertaining to widget operations. ; r - contains info pertaining to the reduction process. ; d - contains all of the data. w = {lineid_fld:[0L,0L],$ momentlog:0L,$ rwave_fld:[0L,0L],$ ewxmax_fld:[0L,0L],$ ewxmin_fld:[0L,0L],$ ewymax_fld:[0L,0L],$ ewymin_fld:[0L,0L],$ keyboard:0L,$ message:0L,$ plotwin:0,$ xeqwidth_base:0L,$ xmin_fld:[0L,0L],$ xmax_fld:[0L,0L],$ ymin_fld:[0L,0L],$ ymax_fld:[0L,0L]} r = {cursormode:'None',$ buffer:'O',$ ewrange:[!values.f_nan,!values.f_nan],$ normdegree:1,$ lineidx:0} d = {wflux:ptr_new(fltarr(2)),$ lineinfo:replicate({ID:' ',rwave:0.0,wmin:0.0,wmax:0.0,A_cont:0.0,$ A_tot:0.0,C_tot:0.0,RV_tot:0.0,W_tot:0.0,A_net:0.0,$ C_net:0.0,RV_net:0.0,W_net:0.0,EW:0.0},20),$ wwave:ptr_new(fltarr(2)),$ normgoodbad:ptr_new(2)} p = {activespec:1,$ buffer:[0.,0.],$ cursor:0,$ pixmap_wid:0L,$ plotwin_wid:0L,$ plotxrange:[0.,0.],$ plotyrange:[0.,0.],$ plotsize:[700,490],$ pscale:!p,$ xscale:!x,$ xtitle:'',$ yscale:!y,$ ytitle:'',$ reg:[[!values.f_nan,!values.f_nan],$ [!values.f_nan,!values.f_nan]]} ; Load the three structures in the state structure. state = {w:w,r:r,d:d,p:p} end ; ;****************************************************************************** ; pro xeqwidth_cleanup,xeqwidth_base common xeqwidth_state widget_control, xeqwidth_base, GET_UVALUE = state, /NO_COPY if n_elements(state) ne 0 then begin endif end ; ;****************************************************************************** ; pro xeqwidth_linenumber common xeqwidth_state result = fltarr(10) for i = 4,13 do result[i-4] = state.d.lineinfo[state.r.lineidx].(i) result = strtrim(result,2) widget_control, state.w.momentlog,set_value=[result[0],' ',result[1:4],$ ' ',result[5:8],' ',result[9]] widget_control, state.w.lineid_fld[1], $ set_value = state.d.lineinfo[state.r.lineidx].(0) widget_control, state.w.rwave_fld[1], $ set_value = strtrim(state.d.lineinfo[state.r.lineidx].(1),2) widget_control, state.w.ewxmax_fld[1], $ set_value = strtrim(state.d.lineinfo[state.r.lineidx].(2),2) widget_control, state.w.ewxmin_fld[1], $ set_value = strtrim(state.d.lineinfo[state.r.lineidx].(3),2) end ; ;****************************************************************************** ; pro xeqwidth_moments common xeqwidth_state z = where(finite(state.r.ewrange) eq 1,count) if count ne 2 then goto, cont range = state.r.ewrange[sort(state.r.ewrange)] rwave = cfld(state.w.rwave_fld,4,/EMPTY,CANCEL=cancel) if cancel then return lineid = cfld(state.w.lineid_fld,7,CANCEL=cancel) if cancel then return result = linemoments(*state.d.wwave,*state.d.wflux,range[0],range[1],rwave,$ *state.d.normgoodbad,state.r.normdegree) state.d.lineinfo[state.r.lineidx].ID = lineid state.d.lineinfo[state.r.lineidx].rwave = rwave state.d.lineinfo[state.r.lineidx].wmin = range[0] state.d.lineinfo[state.r.lineidx].wmax = range[1] for i = 4, 13 do state.d.lineinfo[state.r.lineidx].(i) = result[i-4] ;result = strtrim(result,2) ;widget_control, state.w.momentlog,set_value=[result[0],' ',result[1:4],$ ; ' ',result[5:8],' ',result[9]] ;wset, state.p.plotwin_wid ;xeqwidth_plotlinecen ;wset, state.p.pixmap_wid ;xeqwidth_plotlinecen cont: end ; ;****************************************************************************** ; pro xeqwidth_help common xeqwidth_state textfont = '-adobe-helvetica-medium-r-normal--0-0-75-75-p-0-iso8859-1' buttonfont = '-adobe-helvetica-bold-r-normal--14-140-75-75-p-82-iso8859-1' if not xregistered('xeqwidth_help') then begin help_base = widget_base(group_leader = state.w.xeqwidth_base, $ /column, $ title ='Xeqwidth Help') last = strpos(!path,'Spantool') first = strpos(!path,':',last,/REVERSE_SEARCH) result = strmid(!path,first+1,last-first+7) openr, lun,result+'/xeqwidth_helpfile.txt',/get_lun nlines = numlines(result+'/xeqwidth_helpfile.txt') h = strarr(nlines) readf, lun, h free_lun, lun help_text = widget_text(help_base, $ /scroll, $ value = h, $ xsize = 70, $ ysize = 24) quit = widget_button(help_base,$ value='Quit',$ font=buttonfont,$ uvalue='Quit') centertlb,help_base widget_control, help_base, /Realize ; Start the Event Loop. This will be a non-blocking program. XManager, 'xeqwidth_help', $ help_base, $ /No_Block,$ event_handler='xeqwidth_event' endif end ; ;****************************************************************************** ; pro xeqwidth_plotline,PS=ps common xeqwidth_state z = where(finite(state.r.ewrange) eq 1,count) case count of 1: begin plots,[state.r.ewrange[0],state.r.ewrange[0]],!y.crange,$ linestyle=1,color=5 end 2: begin plots,[state.r.ewrange[0],state.r.ewrange[0]],!y.crange,$ linestyle=1,color=5 plots,[state.r.ewrange[1],state.r.ewrange[1]],!y.crange,$ linestyle=1,color=5 z = where(*state.d.normgoodbad eq 1,count) if count eq 0 then begin tabinv,*state.d.wwave,state.r.ewrange,idx ridx = round(idx) coeff=poly_fit([(*state.d.wwave)[ridx[0]],$ (*state.d.wwave)[ridx[1]]],$ [(*state.d.wflux)[ridx[0]],$ (*state.d.wflux)[ridx[1]]],1,/DOUBLE) oplot,(*state.d.wwave)[ridx[0]:ridx[1]],$ poly((*state.d.wwave)[ridx[0]:ridx[1]],coeff),color=3,psym=10 endif end else: endcase end ; ;****************************************************************************** ; pro xeqwidth_plotlinecen common xeqwidth_state if state.d.lineinfo[state.r.lineidx].C_net ne 0 then begin plots,[state.d.lineinfo[state.r.lineidx].C_net,$ state.d.lineinfo[state.r.lineidx].C_net],!y.crange,linestyle=1,$ color=5 endif end ; ;****************************************************************************** ; pro xeqwidth_plotnorm,PS=ps common xeqwidth_state goodbad = *state.d.normgoodbad z = where(goodbad eq 1,count_good) if count_good eq 0 then goto, cont n = n_elements(goodbad) x = [goodbad-goodbad[1:*],goodbad[n-1]] y = [goodbad[0],goodbad[1:*]-goodbad] x[where( x lt 0)] = 0 y[where( y lt 0)] = 0 sum = x+y z = where(sum eq 1,count) for i = 0, count/2-1 do begin idx1 = z[i*2] idx2 = z[i*2+1] wmin = (*state.d.wwave)[idx1] wmax = (*state.d.wwave)[idx2] fmin = state.p.plotyrange[0]+0.1*(state.p.plotyrange[1]-$ state.p.plotyrange[0]) dmin = (*state.d.wflux)[idx1] dmax = (*state.d.wflux)[idx2] plots,[wmin,wmin],[fmin,dmin], linestyle=2, color=7 plots,[wmax,wmax],[fmin,dmax], linestyle=2, color=7 oplot,[wmin,wmax],[fmin,fmin], color=7 endfor if count_good gt state.r.normdegree then begin coeffs = poly_fit1d(*state.d.wwave,*state.d.wflux,state.r.normdegree,$ /GAUSSJ,GOODBAD=*state.d.normgoodbad,/SILENT) ffit = poly(*state.d.wwave,coeffs) fnorm = *state.d.wflux/ffit oplot,*state.d.wwave,poly(*state.d.wwave,coeffs),color=3 endif cont: end ; ;****************************************************************************** ; pro xeqwidth_plotspec common xeqwidth_state plot,*state.d.wwave,*state.d.wflux,/xsty,/ysty,yrange=state.p.plotyrange,$ xrange=state.p.plotxrange,psym=10,xtitle=state.p.xtitle,ytitle=state.p.ytitle state.p.xscale = !x state.p.yscale = !y state.p.pscale = !p state.p.cursor = 1 end ; ;****************************************************************************** ; pro xeqwidth_setminmax common xeqwidth_state widget_control, state.w.xmin_fld[1],set_value=strtrim(state.p.plotxrange[0],2) widget_control, state.w.xmax_fld[1],set_value=strtrim(state.p.plotxrange[1],2) widget_control, state.w.ymin_fld[1],set_value=strtrim(state.p.plotyrange[0],2) widget_control, state.w.ymax_fld[1],set_value=strtrim(state.p.plotyrange[1],2) end ; ;****************************************************************************** ; pro xeqwidth_startup common xeqwidth_state ; Build the widget. buttonfont = '-adobe-helvetica-bold-r-normal--14-140-75-75-p-82-iso8859-1' textfont = '-adobe-helvetica-medium-r-normal--0-0-75-75-p-0-iso8859-1' state.w.xeqwidth_base = widget_base(title='X Equivalent Width', $ /column,$ /tlb_size_events) quit_button = widget_button(state.w.xeqwidth_base,$ font=buttonfont,$ event_pro='xeqwidth_event',$ value='Quit',$ uvalue='Quit') state.w.keyboard = widget_text(state.w.xeqwidth_base, $ /all_events, $ scr_xsize = 1, $ scr_ysize = 1, $ uvalue = 'Keyboard', $ event_pro='xeqwidth_event',$ value = '') row = widget_base(state.w.xeqwidth_base,$ /row) col1_base = widget_base(row,$ ; frame=1,$ /column) line_info = widget_base(col1_base,$ frame=1,$ /column,$ /base_align_right) value = ['1','2','3','4','5','6','7','8','9','10','11','12',$ '13','14','15','16','17','18','19','20'] line_dl = widget_droplist(line_info,$ font=buttonfont,$ event_pro = 'xeqwidth_event',$ title='Line Number:',$ value=value,$ uvalue='Line Number') line_id = coyote_field2(line_info,$ labelfont=buttonfont,$ fieldfont=textfont,$ title='Line ID:',$ uvalue='EW Line ID',$ xsize=10,$ textID=textid) state.w.lineid_fld = [line_id,textid] wave = coyote_field2(line_info,$ labelfont=buttonfont,$ fieldfont=textfont,$ title='Rest Wave:',$ uvalue='Rest Wavelength',$ xsize=10,$ textID=textid) state.w.rwave_fld = [wave,textid] cont_info = widget_base(col1_base,$ frame=1,$ /column) value = ['1','2','3','4','5','6','7','8','9','10','11','12'] fitorder_dl = widget_droplist(cont_info,$ font=buttonfont,$ title='Fit Degree:',$ value=value,$ event_pro = 'xeqwidth_event',$ uvalue='Normalization Fit Degree') clearcont = widget_button(cont_info,$ font=buttonfont,$ value='Clear Cont Fit',$ event_pro = 'xeqwidth_event',$ uvalue='Clear Cont Fit') range_info = widget_base(col1_base,$ frame=1,$ /column) xmin = coyote_field2(range_info,$ labelfont=buttonfont,$ fieldfont=textfont,$ title='Wave Min:',$ event_pro = 'xeqwidth_event',$ uvalue='EW Wave Min',$ xsize=10,$ /cr_only,$ textID=textid) state.w.ewxmin_fld = [xmin,textid] xmax = coyote_field2(range_info,$ labelfont=buttonfont,$ fieldfont=textfont,$ title='Wave Max:',$ event_pro = 'xeqwidth_event',$ uvalue='EW Wave Max',$ xsize=10,$ /cr_only,$ textID=textid) state.w.ewxmax_fld = [xmax,textid] compute = widget_button(range_info,$ font=buttonfont,$ event_pro = 'xeqwidth_event',$ value='Compute Moments',$ uvalue='Compute Moments') report_row = widget_base(col1_base,$ /row) label = widget_text(report_row,$ xsize=6,$ ysize=13, $ value=['A_cont',' ','A_tot','C_tot','RV_tot',$ 'W_tot',' ','A_net','C_net','RV_net',$ 'W_net',' ','EW']) state.w.momentlog = widget_text(report_row,$ xsize=15,$ ysize=14) write = widget_button(col1_base,$ font=buttonfont,$ event_pro = 'xeqwidth_event',$ value='Write Results',$ uvalue='Write Results') col2_base = widget_base(row,$ frame=1,$ /column) state.w.message = widget_text(col2_base, $ YSIZE=1) state.w.plotwin = widget_draw(col2_base,$ xsize=state.p.plotsize[0],$ ysize=state.p.plotsize[1],$ /TRACKING_EVENTS,$ /button_events,$ /motion_events,$ event_pro='xeqwidth_plotwinevent',$ uvalue='Plot Window 1') row_base = widget_base(col2_base,$ /row) xmin = coyote_field2(row_base,$ labelfont=buttonfont,$ fieldfont=textfont,$ title='X Min:',$ uval = 'X Min',$ xsize=12,$ event_pro = 'xeqwidth_minmax',$ /cr_only,$ textid=textid) state.w.xmin_fld = [xmin,textid] xmax = coyote_field2(row_base,$ labelfont=buttonfont,$ fieldfont=textfont,$ title='X Max:',$ uval = 'X Max',$ xsize=12,$ event_pro = 'xeqwidth_minmax',$ /cr_only,$ textid=textid) state.w.xmax_fld = [xmax,textid] ymin = coyote_field2(row_base,$ labelfont=buttonfont,$ fieldfont=textfont,$ title='Y Min:',$ uval = 'Y Min',$ xsize=12,$ event_pro = 'xeqwidth_minmax',$ /cr_only,$ textid=textid) state.w.ymin_fld = [ymin,textid] ymax = coyote_field2(row_base,$ labelfont=buttonfont,$ fieldfont=textfont,$ title='Y Max:',$ uval = 'Y Max',$ xsize=12,$ event_pro = 'xeqwidth_minmax',$ /cr_only,$ textid=textid) state.w.ymax_fld = [ymax,textid] ; Get things running. Center the widget using the Fanning routine. centertlb,state.w.xeqwidth_base widget_control, state.w.xeqwidth_base, /realize mkct ; Get plotwin ids widget_control, state.w.plotwin, get_value = x state.p.plotwin_wid = x window, /free, /pixmap,xsize=state.p.plotsize[0],ysize=state.p.plotsize[1] state.p.pixmap_wid = !d.window ; Get sizes for things. widget_geom = widget_info(state.w.xeqwidth_base, /geometry) state.p.buffer[0]=widget_geom.xsize-state.p.plotsize[0] state.p.buffer[1]=widget_geom.ysize-state.p.plotsize[1] ; Start the Event Loop. This will be a non-blocking program. XManager, 'xeqwidth', $ state.w.xeqwidth_base, $ /No_Block,$ event_handler='xeqwidth_resize',$ cleanup = 'xeqwidth_cleanup' end ; ;****************************************************************************** ; pro xeqwidth_plotupdate,PS=ps common xeqwidth_state if keyword_set(PS) then begin xeqwidth_plotspec xeqwidth_plotnorm xeqwidth_plotline endif else begin wset, state.p.plotwin_wid erase xeqwidth_plotspec xeqwidth_plotnorm xeqwidth_plotline wset, state.p.pixmap_wid erase xeqwidth_plotspec xeqwidth_plotnorm xeqwidth_plotline endelse end ; ;****************************************************************************** ; ; ------------------------------Event Handlers-------------------------------- ; ;****************************************************************************** ; pro xeqwidth_event, event common xeqwidth_state widget_control, event.id, GET_UVALUE = uvalue case uvalue of 'Clear Cont Fit': begin *state.d.normgoodbad = intarr(n_elements(*state.d.wwave)) xeqwidth_plotupdate end 'Compute Moments': xeqwidth_moments 'EW Wave Min': begin xmin = cfld(state.w.ewxmin_fld,4,CANCEL=cancel) if cancel then begin widget_control, state.w.ewxmin_fld[0],set_value=state.r.ewrange[0] return endif else state.r.ewrange[0] = xmin xeqwidth_plotupdate end 'EW Wave Max': begin xmax = cfld(state.w.ewxmax_fld,4,CANCEL=cancel) if cancel then begin widget_control, state.w.ewxmax_fld[0],set_value=state.r.ewrange[1] return endif else state.r.ewrange[1] = xmax xeqwidth_plotupdate end 'Keyboard': begin case strtrim(event.ch,2) of 'c': begin state.r.cursormode = 'None' *state.d.normgoodbad = intarr(n_elements(*state.d.wwave)) state.p.reg = [[!values.f_nan,!values.f_nan],$ [!values.f_nan,!values.f_nan]] widget_control, state.w.ewxmin_fld[1],set_value=' ' widget_control, state.w.ewxmax_fld[1],set_value=' ' state.r.ewrange = [!values.f_nan,!values.f_nan] widget_control, state.w.momentlog,set_value=strarr(10) xeqwidth_plotupdate end 'h': xeqwidth_help 'n': begin state.r.cursormode = 'Norm' state.p.reg = [[!values.f_nan,!values.f_nan],$ [!values.f_nan,!values.f_nan]] end 'p': begin forminfo = CMPS_FORM(/INITIALIZE,$ SELECT='Full Landscape (color)') formInfo = CMPS_FORM(Cancel=canceled, $ defaults=forminfo,$ button_names = ['Create PS File'],$ Parent=state.w.xeqwidth_base) IF NOT canceled THEN BEGIN thisDevice = !D.Name Set_Plot, "PS" Device, _Extra=formInfo xeqwidth_plotupdate,/PS Device, /Close Set_Plot, thisdevice !p.background=0 ENDIF end 's': begin widget_control, state.w.ewxmin_fld[1],set_value=' ' widget_control, state.w.ewxmax_fld[1],set_value=' ' state.r.ewrange = [!values.f_nan,!values.f_nan] widget_control, state.w.momentlog,set_value=strarr(10) xeqwidth_plotupdate state.r.cursormode = 'Select' end 'w': begin state.p.plotxrange = [min(*state.d.wwave,MAX=xmax),xmax] state.p.plotyrange = [0.,max(*state.d.wflux,/NAN)] xeqwidth_plotupdate xeqwidth_setminmax end 'z': begin state.r.cursormode = 'Zoom' state.p.reg = [[!values.f_nan,!values.f_nan],$ [!values.f_nan,!values.f_nan]] end else: endcase end 'Line Number': begin state.r.lineidx = event.index xeqwidth_linenumber end 'Normalization Fit Degree': begin x = ['1','2','3','4','5','6','7','8','9','10','11','12'] state.r.normdegree = x[event.index] xeqwidth_plotupdate end 'Quit': widget_control, event.top, /DESTROY 'Write Results': begin path = dialog_pickfile(DIALOG_PARENT=state.w.xeqwidth_base,$ file='idl.dat') if path eq '' then goto, cont z = where(state.d.lineinfo.rwave ne 0.0,count) print_struct,state.d.lineinfo[z],trange=[0,14],file=path end endcase cont: end ; ;****************************************************************************** ; pro xeqwidth_plotwinevent, event common xeqwidth_state widget_control, event.id, GET_UVALUE = uvalue ; Check to see if it is a TRACKING event. if strtrim(tag_names(event,/STRUCTURE_NAME),2) eq 'WIDGET_TRACKING' then begin if event.enter eq 0 then widget_control, state.w.keyboard, SENSITIVE=0 goto, cont endif ; If not, set the keyboard focus and active window. widget_control, state.w.keyboard, /INPUT_FOCUS, /SENSITIVE !p = state.p.pscale !x = state.p.xscale !y = state.p.yscale x = event.x/float(state.p.plotsize[0]) y = event.y/float(state.p.plotsize[1]) xy = convert_coord(x,y,/NORMAL,/TO_DATA) if event.type eq 1 then begin case state.r.cursormode of 'Select': begin z = where(finite(state.r.ewrange) eq 1,count) if count eq 0 then begin state.r.ewrange[0] = xy[0] widget_control, state.w.ewxmin_fld[1],$ set_value=strtrim(xy[0],2) xeqwidth_plotupdate endif else begin state.r.ewrange[1] = xy[0] widget_control, state.w.ewxmax_fld[1],$ set_value=strtrim(xy[0],2) xeqwidth_plotupdate state.r.cursormode = 'None' endelse end 'Norm': begin z = where(finite(state.p.reg) eq 1,count) if count eq 0 then state.p.reg[*,0] = xy[0:1] if count eq 2 then begin state.p.reg[*,1] = xy[0:1] tabinv,*state.d.wwave,state.p.reg[0,*],range (*state.d.normgoodbad)[range[0]:range[1]] = 1 xeqwidth_plotupdate state.p.reg = [[!values.f_nan,!values.f_nan],$ [!values.f_nan,!values.f_nan]] endif end 'Zoom': begin z = where(finite(state.p.reg) eq 1,count) if count eq 0 then state.p.reg[*,0] = xy[0:1] else begin state.p.reg[*,1] = xy[0:1] state.p.plotxrange = [min(state.p.reg[0,*],max=max),max] state.p.plotyrange = [min(state.p.reg[1,*],max=max),max] xeqwidth_plotupdate state.r.cursormode = 'None' state.p.reg = [[!values.f_nan,!values.f_nan],$ [!values.f_nan,!values.f_nan]] xeqwidth_setminmax endelse end else: endcase endif ; Copy the pixmaps and draw the lines. wset, state.p.plotwin_wid device, copy=[0,0,state.p.plotsize[0],state.p.plotsize[1],0,0,$ state.p.pixmap_wid] plots, [event.x,event.x],[0,state.p.plotsize[1]],color=2,/DEVICE plots, [0,state.p.plotsize[0]],[event.y,event.y],color=2,/DEVICE if state.r.cursormode eq 'Zoom' then begin xy = convert_coord(event.x,event.y,/DEVICE,/TO_DATA) plots,[state.p.reg[0,0],state.p.reg[0,0]],[state.p.reg[1,0],xy[1]],$ linestyle=2,color=2 plots, [state.p.reg[0,0],xy[0]],[state.p.reg[1,0],state.p.reg[1,0]],$ linestyle=2,color=2 endif ; Update cursor position. if state.p.cursor then begin tabinv, *state.d.wwave,xy[0],idx idx = round(idx) label = 'Cursor X: '+strtrim(xy[0],2)+', Y:'+strtrim(xy[1],2) label = label+' Spectrum X: '+strtrim( (*state.d.wwave)[idx],2)+$ ', Y:'+strtrim( (*state.d.wflux)[idx],2) widget_control,state.w.message,set_value=label endif cont: end ; ;****************************************************************************** ; pro xeqwidth_minmax,event common xeqwidth_state xmin = cfld(state.w.xmin_fld,4,/EMPTY,CANCEL=cancel) if cancel then return xmin2 = crange(xmin,state.p.plotxrange[1],'X Min',/KLT,$ WIDGET_ID=state.w.xeqwidth_base,CANCEL=cancel) if cancel then begin widget_control, state.w.xmin_fld[0],set_value=state.p.plotxrange[0] return endif else state.p.plotxrange[0] = xmin2 xmax = cfld(state.w.xmax_fld,4,/EMPTY,CANCEL=cancel) if cancel then return xmax2 = crange(xmax,state.p.plotxrange[0],'X Max',/KGT,$ WIDGET_ID=state.w.xeqwidth_base,CANCEL=cancel) if cancel then begin widget_control, state.w.xmax_fld[0],set_value=state.p.plotxrange[1] return endif else state.p.plotxrange[1] = xmax2 ymin = cfld(state.w.ymin_fld,4,/EMPTY,CANCEL=cancel) if cancel then return ymin2 = crange(ymin,state.p.plotyrange[1],'Y Min',/KLT,$ WIDGET_ID=state.w.xeqwidth_base,CANCEL=cancel) if cancel then begin widget_control, state.w.ymin_fld[0],set_value=state.p.plotyrange[0] return endif else state.p.plotyrange[0] = ymin2 ymax = cfld(state.w.ymax_fld,4,/EMPTY,CANCEL=cancel) if cancel then return ymax2 = crange(ymax,state.p.plotyrange[0],'Y Max',/KGT,$ WIDGET_ID=state.w.xeqwidth_base,CANCEL=cancel) if cancel then begin widget_control, state.w.ymax_fld[0],set_value=state.p.plotyrange[1] return endif else state.p.plotyrange[1] = ymax2 xeqwidth_plotupdate end ; ;****************************************************************************** ; pro xeqwidth_resize, event common xeqwidth_state widget_control, state.w.xeqwidth_base, tlb_get_size = size state.p.plotsize[0]=size[0]-state.p.buffer[0] state.p.plotsize[1]=size[1]-state.p.buffer[1] widget_control, state.w.plotwin, draw_xsize=state.p.plotsize[0] widget_control, state.w.plotwin, draw_ysize=state.p.plotsize[1] wdelete,state.p.pixmap_wid window, /free, /pixmap,xsize=state.p.plotsize[0],ysize=state.p.plotsize[1] state.p.pixmap_wid = !d.window wset, state.p.plotwin_wid device, copy=[0,0,state.p.plotsize[0],state.p.plotsize[1],0,0,$ state.p.pixmap_wid] xeqwidth_plotupdate end ; ;****************************************************************************** ; ; ------------------------------Main Program-------------------------------- ; ;****************************************************************************** ; ; ;****************************************************************************** ; pro xeqwidth,wave,flux,YTITLE=ytitle,XTITLE=xtitle common xeqwidth_state zparcheck, 'xeqwidth', wave, 1, [2,3,4,5], 1, 'Wave' zparcheck, 'xeqwidth', flux, 2, [2,3,4,5], 1, 'Flux' if n_params() ne 2 then begin print, 'Syntax - xeqwidth,wave,flux,YTITLE=ytitle,XTITLE=xtitle' return endif if not xregistered('xeqwidth') then begin xeqwidth_initcommon xeqwidth_startup endif xmin = min(wave,MAX=xmax) ymax = max(flux,/NAN) state.p.ytitle = (n_elements(YTITLE) ne 0) ? ytitle:'' state.p.xtitle = (n_elements(XTITLE) ne 0) ? xtitle:'' *state.d.wwave= wave *state.d.wflux= flux state.p.plotxrange= [xmin,xmax] state.p.plotyrange= [0.,ymax] *state.d.normgoodbad = intarr(n_elements(wave)) xeqwidth_plotupdate xeqwidth_setminmax end