pro qView_PlotTrack, state, event, old, display=display, add=add, $ init=init, destroy=destroy ;+ ; NAME: ; qView_PlotTrack ; PURPOSE: ; Accumulate results from tracking of peak by qView_TrackPeak, and ; display final result using qLine. ; CATEGORY: ; Widget qView ; CALLING SEQUENCE: ; qView_PlotTrack, state, event, old, display=display, add=add ; INPUTS: ; state array[1]; type: structure ; qView state structure ; event array[1]; type: structure ; event from state.wid_track button, or from qImage widget ; old scalar; type: integer ; file index for the image to which the tracking information ; in 'event' applies (this is passes to qLine as x-axis) ; OPTIONAL INPUT PARAMETERS: ; /display if set, then qLine is called to display the tracking results ; (this keyword is used by qView_TrackPeak after the last image has ; been processed). ; /add if set, then the information from 'event' is added to tracking ; info alread stored ; /destroy destroys variables stored in common block; then returns ; without any further action. ; OUTPUTS: ; (to qLine widget) ; INCLUDE: @compile_opt.pro ; On error, return to caller ; CALLS: ; InitVar, TimeSet, qLine, destroyvar, qView_PlotTrack ; IsTime ; COMMON BLOCKS: ; common qView_PlotTrack_Save, npeaks, x, y ; stores the tracking information ; PROCEDURE: ; The 'event' structure is set up and dispatched by the procedure qImage_TrackPeak. ; It contains the x and y coordinates of the centroid among other quantities. ; MODIFICATION HISTORY: ; FEB-2000, Paul Hick (UCSD/CASS; pphick@ucsd.edu) ;- common qView_PlotTrack_Save, boxes, smei_set, smei_center, npeaks, x, y, t InitVar, display, /key InitVar, destroy, /key InitVar, init , /key InitVar, add , /key ; Destroy variables stored in common block if destroy then begin destroyvar, boxes, smei_set, smei_center, npeaks destroyvar, x, y, t return endif if init then begin npeaks = 0 endif else if add and npeaks eq 0 then begin npeaks = npeaks+1 x = old y = [event.centroid, event.zval[2], event.zback, event.zpix] endif else if add then begin npeaks = npeaks+1 x = [x, old] y = [ [y], [event.centroid, event.zval[2], event.zback, event.zpix] ] endif if display and npeaks gt 0 then begin widget_control, state.wid_time , get_uvalue=trange if IsTime(trange) then begin widget_control, state.wid_pick, get_uvalue=allfiles t = allfiles[x,2] widget_control, state.wid_pick, set_uvalue=allfiles t = TimeSet(t) endif ytitle = ['x-coordinate','y-coordinate','pixel value','background','# pixels','# pixels in background'] lsq = dialog_message(/question, 'Subtract linear fit from centroid ?', dialog_parent=state.wid_track) eq 'Yes' ; lsq = dialog_message(/question, 'Subtract linear fit from centroid ?', dialog_parent=event.handler) eq 'Yes' if lsq then begin fit = linfit(x,y[0,*], chisq=chisqx) y = [[y], y[0,*]-(fit[0]+fit[1]*x)] fit = linfit(x,y[1,*], chisq=chisqy) y = [[y], y[1,*]-(fit[0]+fit[1]*x)] y[6:7,*] = y[6:7,*]*1000 chi = sqrt( total(y[6:7,*]*y[6:7,*],2)/n_elements(x) ) ytitle = [ytitle,'d(x) (mpix): '+strcompress(chi[0],/rem), $ 'd(y) (mpix): '+strcompress(chi[1],/rem)] endif qLine, group=event.handler, x, y, time=t, $ xmargin = [12,20], $ title = 'Track Series', $ ytitle = ['frame number',ytitle], $ skip = [0,0,0,1,1,1,1], $ newyaxis = [0,1,1,1,0,1,0], $ linestyle = [0,0,2,1,3,4,5], $ ynozero = [0,1,1,1,1,1,1] if smei_set then begin ytitle = ['azimuth+90 (deg)','radius (pix)','pixel value','background','# pixels','# pixels in background'] y[0:1,*] = cv_coord(from_rect=y[0:1,*]-smei_center#replicate(1,npeaks), /to_polar, /degrees) y[0,*] = y[0,*]+90 if lsq then begin fit = linfit(x,y[0,*]) y[6,*] = y[0,*]-(fit[0]+fit[1]*x) fit = linfit(x,y[1,*]) y[7,*] = y[1,*]-(fit[0]+fit[1]*x) y[6,*] = y[6,*]/!radeg*mean(y[1,*]) y[6:7,*] = y[6:7,*]*1000 chi = sqrt( total(y[6:7,*]*y[6:7,*],2)/n_elements(x) ) ytitle = [ytitle,'d(azimuth) (mpix): '+strcompress(chi[0],/rem), $ 'd(radius) (mpix): ' +strcompress(chi[1],/rem)] endif qLine, group=event.handler, x, y, time=t, $ xmargin = [12,20], $ xtitle = 'Track Series', $ ytitle = ['frame number',ytitle], $ skip = [0,0,0,1,1,1,1], $ newyaxis = [0,1,1,1,0,1,0], $ linestyle = [0,0,2,1,3,4,5], $ ynozero = [0,1,1,1,1,1,1] endif qView_PlotTrack, /destroy endif return & end