PRO qView_PlotSeries, state, event, wid_send=wid_send, send_event=send_event ;+ ; NAME: ; qView_PlotSeries ; PURPOSE: ; Calculate a 'time series' through a sequence of images for a specified image area ; and display it using the qLine widget ; CATEGORY: ; Widget qView ; CALLING SEQUENCE: ; qView_PlotSeries, state ; INPUTS: ; state array[1]; type: structure ; qView state structure ; OUTPUTS: ; (to qLine widget) ; INCLUDE: @compile_opt.pro ; On error, return to caller ; CALLS: ; qView_SetInfo, qView_GetInfo, qView_ImageInfo, qImage_TriggerSend, qView_TMO_tracksky ; qImage_cw_BoxCosine, qImage_cw_Wedge, TimeSet, qLine ; Inside_Wedge, gridgen, SuperArray, IsTime ; PROCEDURE: ; The last information send back from the qImage widget is used to decide what image area ; to use. Two time series are displayed: the average and the standard deviation for ; the image area as a function of image number. ; If time information is available from the state.wid_time widget then ; a time axis is plotted instead of the image number. ; STATE INFO USED: ; widget_control, state.wid_data, get_uvalue=data, /no_copy ; widget_control, state.wid_time , get_uvalue=trange ; STATE INFO MODIFIED: ; widget_control, state.wid_data, set_uvalue=data, /no_copy ; MODIFICATION HISTORY: ; FEB-2000, Paul Hick (UCSD/CASS; pphick@ucsd.edu) ;- status = qImage_TriggerSend(event, state.wid_view, state.wid_series, wid_send, send_event) CASE status OF 0B: ; No qImage widget exists (yet) 1B: RETURN ; Return to event handler to send 'send_event' to 'wid_send' 2B: qView_SetInfo, state, event ; Process QIMAGE_SEND event ENDCASE IF NOT qView_GetInfo(state, box=box, dim=dim, offset=offset, subdim=subdim, qimage_cw=qimage_cw_state, $ cosine=cosine, smei=smei, center=center, p_axis=p_axis, p_box=p_box, prorate=prorate) THEN RETURN x = qView_ImageInfo(state, /number_images, /list) nimg = x[0] x = x[1:*] z = fltarr(3,nimg) 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 CASE smei OF 1: BEGIN cntr = center-offset ; Relative to lowerleft corner of subimage in memory b_box = qImage_cw_Wedge(0L, p_box, /noupdate, img_center=cntr) ; Relative to lowerleft corner of subimage b_box = (b_box > 0) < (subdim-1)#[1,1] cntr = cntr-b_box[0:1] ; Relative to lowerleft corner of b_box nx = b_box[2]-b_box[0]+1 ny = b_box[3]-b_box[1]+1 r_center = gridgen([nx,ny],origin=cntr) center_inside = Inside_Wedge(p_box, cv_coord(from_rect=r_center, /to_polar)) center_inside = reform(center_inside, nx, ny, /overwrite) r_corner = gridgen([nx,ny]+1,origin=cntr+0.5) corner_inside = Inside_Wedge(p_box, cv_coord(from_rect=r_corner, /to_polar)) corner_inside = reform(corner_inside, nx+1, ny+1, /overwrite) ; clear_inside=1B: whole pixel inside or outside p_box ; clear_inside=0B: pixels straddles boundary of p_box clear_inside = center_inside EQ corner_inside[0:nx-1,0:ny-1] AND $ center_inside EQ corner_inside[1:nx ,0:ny-1] AND $ center_inside EQ corner_inside[0:nx-1,1:ny ] AND $ center_inside EQ corner_inside[1:nx ,1:ny ] ; Pick up pixels straddling boundary, and pixels completely inside p_box clear_across = where(clear_inside EQ 0B, n_across) clear_inside = where(clear_inside EQ 1B AND center_inside EQ 1B, n_inside) n_across = prorate[2]*n_across frac = fltarr(nx*ny) IF n_inside GT 0 THEN frac[clear_inside] = 1. IF n_across GT 0 THEN BEGIN ; The prorating is done by dividing each pixel on the boundary ; in a group of 10x10 subpixels mx = prorate[0] my = prorate[1] ; x,y coordinates of subpixels between -0.5,+0.5 r = [mx,my] r_small = gridgen( r, range=(0.5*[-1,1])#((r-1.0)/r) ) ; x,y coordinate relative to origin of pixels to be prorated r = r_center[*,clear_across] ; Set up an mx x my x n_across array for all subpixels in all pixels to be prorated r = SuperArray(r, mx*my, after=1)+SuperArray(r_small,n_across,/trail) r = reform(r, 2, mx*my*n_across, /overwrite) ; Convert the subpixel centers to polar coordinates ; Determine which subpixels lie inside the wedge r = Inside_Wedge(p_box, cv_coord(from_rect=r, /to_polar)) r = reform(r, mx*my, n_across, /overwrite) r = total(r,1)/(mx*my) ; Fraction of subpixels lying inside the wedge frac[clear_across] = r ENDIF widget_control, state.wid_tmo , get_uvalue=tmo_track widget_control, state.wid_data, get_uvalue=data, /no_copy CASE tmo_track OF 1: box_data = qView_TMO_tracksky(state, data, b_box, b_box[0:1]+cntr, p_axis, pfov=pfov) 0: box_data = data[b_box[0]:b_box[2],b_box[1]:b_box[3],*] ENDCASE widget_control, state.wid_data, set_uvalue=data, /no_copy widget_control, state.wid_diff, get_uvalue=dtype ;i = qView_ImageInfo(state, /active) ;i = qView_ImageInfo(state, file=i, /first, /last, /incr) CASE dtype.value OF 0: 1: box_data = box_data-SuperArray(box_data[*,*, 0],nimg,/trail); Difference with first image 2: box_data = box_data-SuperArray(box_data[*,*,nimg-1],nimg,/trail); Difference with last image 3: box_data = box_data-shift(box_data,0,0, 1) ; Difference with previous image 4: box_data = box_data-shift(box_data,0,0,-1) ; Difference with next image ENDCASE IF cosine THEN box_data = qImage_cw_BoxCosine(qimage_cw_state, box_data, b_box, pfov=pfov, nimg=nimg) box_data = reform(box_data, nx*ny, nimg, /overwrite) zpix = total(frac) IF zpix GT 0 THEN BEGIN r = where(frac ne 0) FOR i=0,nimg-1 DO z[1,i] = stddev(box_data[r,i], /nan) FOR i=0,nimg-1 DO z[2,i] = min (box_data[r,i], /nan) frac = frac/zpix z[0,*] = total( SuperArray(frac, nimg, /trail)*box_data, 1, /nan) ENDIF ytitle = 'P['+strjoin(strcompress(p_box[[0,2]]*!radeg,/rem),',')+'] '+$ 'R['+strjoin(strcompress(p_box[[1,3]] ,/rem),',')+']' ytitle = ['','Std. Dev. ','Minimum ']+ytitle p_box = reform(p_box,4, /overwrite) str = [ 'dim = ['+strjoin(strcompress(dim ),',')+']', $ 'cntr = ['+strjoin(strcompress(center),',')+']', $ 'p_box = ['+strjoin(strcompress(p_box),',')+']', $ 'b_box = qImage_cw_Wedge(0L, p_box, /noupdate, img_center=cntr, wedge=wedge)',$ 'e = (convert_coord(!x.crange[1],!y.crange[1],/data,/to_normal))[0:1]' , $ 'aspect = float(!d.y_size)/!d.x_size' , $ 'd = 0.1' , $ 'b = e-d*[dim[0],dim[1]/aspect]/dim[0]' , $ 'plots, /normal, [b[0],e[0],e[0],b[0],b[0]],[b[1],b[1],e[1],e[1],b[1]]' , $ 'e = b+d*[b_box[2],b_box[3]/aspect]/dim[0]' , $ 'c = b+d*[b_box[0],b_box[1]/aspect]/dim[0]' , $ 'plots, /normal, [c[0],e[0],e[0],c[0],c[0]],[c[1],c[1],e[1],e[1],c[1]],linestyle=2', $ 'nwedge = n_elements(wedge)/2' , $ 'polyfill, /normal, b#replicate(1,nwedge)+d*[wedge[0,*],wedge[1,*]/aspect]/dim[0]' ] END 0: BEGIN npix = (box[2]-box[0]+1L)*(box[3]-box[1]+1L) CASE npix OF 1L : ytitle = 'pixel X['+strcompress(box[0],/rem)+'],'+ $ ' Y['+strcompress(box[1],/rem)+']' ELSE: ytitle = 'pixels X['+strjoin(strcompress(box[[0,2]],/rem),',')+'],'+ $ ' Y['+strjoin(strcompress(box[[1,3]],/rem),',')+']' ENDCASE ytitle = ['','Std. Dev. ','Minimum ']+ytitle box = box-offset#[1,1] ; These probably need to become dialog boxes IF box[0] GE subdim[0] OR box[2] LT 0 OR $ box[1] GE subdim[1] OR box[3] LT 0 THEN BEGIN print, ytitle[0] print, 'no data in memory for this box' RETURN ENDIF IF box[2] GE subdim[0] OR box[0] LT 0 OR $ box[3] GE subdim[1] OR box[1] LT 0 THEN BEGIN print, ytitle[0] print, 'no data in memory for part of this box.' print, 'only available part of box used.' ;RETURN ENDIF widget_control, state.wid_data, get_uvalue=data, /no_copy box_data = data[box[0]:box[2],box[1]:box[3],*] widget_control, state.wid_data, set_uvalue=data, /no_copy ; Averages and standard deviations z[0,*] = total(total(box_data,1),1)/n_elements(box_data[*,*,0]) IF npix GT 1 THEN FOR i=0,nimg-1 DO z[1,i] = stddev(box_data[*,*,i]) IF npix GT 1 THEN FOR i=0,nimg-1 DO z[2,i] = min (box_data[*,*,i]) IF npix LT long(dim[0])*dim[1] THEN BEGIN str = strarr(16) box = reform(box+offset#[1,1] ,4) sbox = reform(offset#[1,1]+subdim#[0,1] ,4) ; Define a few variables str = [ ' dim = ['+strjoin(strcompress( dim),',')+']' , $ ' box = ['+strjoin(strcompress( box),',')+']' , $ 'sbox = ['+strjoin(strcompress(sbox),',')+']' , $ ; Draw frame border in upper right corner of plot 'e = (convert_coord(!x.crange[1],!y.crange[1],/data,/to_normal))[0:1]', $ 'aspect = float(!d.y_size)/!d.x_size' , $ 'd = 0.1' , $ 'b = e-d*[dim[0],dim[1]/aspect]/dim[0]' , $ 'plots, /normal, [b[0],e[0],e[0],b[0],b[0]],[b[1],b[1],e[1],e[1],b[1]]' ] ; Draw shaded area for area of frame currently loaded (if not full frame) IF (where(subdim NE dim))[0] NE -1 THEN str = [str, $ , $ 'e = b+d*[sbox[2],sbox[3]/aspect]/dim[0]' , $ 'c = b+d*[sbox[0],sbox[1]/aspect]/dim[0]' , $ ;'plots, /normal, [c[0],e[0],e[0],c[0],c[0]],[c[1],c[1],e[1],e[1],c[1]]' , $ 'polyfill, /normal, [c[0],e[0],e[0],c[0],c[0]],[c[1],c[1],e[1],e[1],c[1]], color=200'] ; Draw black area for current box selection str = [str, 'e = b+d*[box[2],box[3]/aspect]/dim[0]' , $ 'c = b+d*[box[0],box[1]/aspect]/dim[0]' , $ ;'plots, /normal, [c[0],e[0],e[0],c[0],c[0]],[c[1],c[1],e[1],e[1],c[1]]' , $ 'polyfill, /normal, [c[0],e[0],e[0],c[0],c[0]],[c[1],c[1],e[1],e[1],c[1]]' ] ENDIF END ENDCASE qLine, group=state.wid_series, x, z, time=t, $ xmargin = [9,20], $ title ='qView series', $ ytitle = ['frame number',ytitle], $ skip = [0,0,1], $ newyaxis = [0,1,1], $ ynozero = [0,1,1], $ linestyle = [0,0,1], $ sigma_index = [0,1,-1], $ plotstr = str RETURN & END