;+ ; NAME: ; qGlitch ; PURPOSE: ; Search and (optionally) remove glitches from an image cube ; CATEGORY: ; Widget qGlitch ; CALLING SEQUENCE: ; qGlitch, group=group, frames, wid_frames=wid_frames, img_offset=img_offset, $ ; img_id=img_id, mask_smei_fov=mask_smei_fov ; INPUTS: ; group=group scalar; type: long integer ; group leader passed to XMANAGER ; frames array[n,m,k]; type: any ; image cube of k images of n x m pixels ; OPTIONAL INPUT PARAMETERS: ; wid_frames=wid_frames ; scalar; type: long integer ; if this is the widget ID of a valid ID then the user value ; of this widget should be an image cube. ; This image cube is used instead of the 'frames' argument. ; img_offset=img_offset ; array[2]; type: integer ; offset of images in cube; the offset is added to all pixel ; coordinates displayed in the qImage_cw compound widget. ; img_id=img_id array[k]; type: integer ; by default images are numbered 0..k in the display made ; by qGlitch_Show. If img_id is specified then img_id[0,,k] ; is used instead ; /mask_smei_fov if set the SMEI fov is not searched for glitches ; OUTPUTS: ; (to widgets) ; CALLS: ; qGlitch_Run, qImage_cw ; PROCEDURE: ; The state structure is as follows: ; ; state = {STATE_QGLITCH, $ ; wid_done : 0L, $ 'Done' button ; user value: img_id; argument to qGlitch ; wid_run : 0L, $ 'Run' button ; user value: frames array; only if 'frames' is specified ; as argument to qGlitch instead of 'wid_frames' ; wid_sum : 0L, $ cw_field ; user value: none ; wid_spot : 0L, $ cw_field ; user value: none ; wid_sigma : 0L, $ cw_field ; user value: Loc array; output from Find2DGlitch ; wid_min : 0L, $ cw_field ; user value: none ; wid_exclude : 0L, $ non-exclusive button ; user value: on/off status ; wid_remove : 0L, $ non-exclusive button ; user value: on/off status ; wid_qimage_cw : 0L, $ widget ID of qImage_cw compound widget ; user value: mask_smei_fov; keyword to qGlitch ; wid_frames : 0L $ widget ID of widget with the 'frames' array as user value. ; This may be state.wid_run (if the 'frames' array was ; passed as argument to qGlitch) or it may be the ID ; of some external widget (e.g, the wid_data widget ; from qView) if keyword 'wid_frames' was used. ; } ; MODIFICATION HISTORY: ; FEB-2000, Paul Hick (UCSD/CASS; pphick@ucsd.edu) ;- pro qGlitch_Event, event @compile_opt.pro ; On error, return to caller widget_control, event.top, get_uvalue=state, /no_copy case event.id of ; ID of widget that generated the message event.top : widget_control, event.top, /destroy ; WIDGET_KILL_REQUEST from top level widget state.wid_done : widget_control, event.top, /destroy state.wid_run : qGlitch_Run, state, event state.wid_exclude: widget_control, state.wid_exclude, set_uvalue=event.select state.wid_remove : widget_control, state.wid_remove , set_uvalue=event.select else: begin event_name = tag_names(event, /structure_name) if event_name ne 'QIMAGE_CW_UPDATE' then print, event_name, event end endcase if widget_info(event.top, /valid_id) then $ widget_control, event.top, set_uvalue=state, /no_copy return & end pro qGlitch, group=group, frames, wid_frames=wid_frames, img_offset=img_offset, $ img_id=img_id, mask_smei_fov=mask_smei_fov, block=block @compile_opt.pro ; On error, return to caller no_block = 1-keyword_set(block) state = {STATE_QGLITCH, $ wid_done : 0L, $ wid_run : 0L, $ wid_sum : 0L, $ wid_spot : 0L, $ wid_sigma : 0L, $ wid_min : 0L, $ wid_exclude : 0L, $ wid_remove : 0L, $ wid_qimage_cw : 0L, $ wid_frames : 0L $ } sz = size(frames) if n_elements(wid_frames) ne 0 then begin if widget_info(wid_frames, /valid) then begin widget_control, wid_frames, get_uvalue=frames, /no_copy sz = size(frames) widget_control, wid_frames, set_uvalue=frames, /no_copy state.wid_frames = wid_frames endif endif if sz[sz[0]+2] eq 0 then begin tmp = dialog_message('No data cube specified for deglitching', dialog_parent=group) return endif ;if sz[0] ne 3 then begin ; tmp = dialog_message('Data cube must be a 3D array', dialog_parent=group) ; return ;endif ;if sz[3] le 1 then begin ; tmp = dialog_message('Data cube must consist of more than one frame', dialog_parent=group) ; return ;endif if sz[0] eq 3 then sum_width = 1 else sum_width = 3 wid_base = widget_base(title='qGlitch', /column, /tlb_kill_request) dummy = widget_base(wid_base, /row) state.wid_done = widget_button(dummy, value=filepath(root=getenv('SSW_SMEI_UCSD'),subdir='image','done.ico'),/bitmap) state.wid_run = widget_button(dummy, value='Run', /no_copy ) dummy1 = widget_base(dummy, /nonexclusive, /row) state.wid_exclude = widget_button(dummy1, value='Exclude glitch' , uvalue=0B) state.wid_remove = widget_button(dummy1, value='Remove glitches', uvalue=0B) ; widget_control, state.wid_exclude, /set_button, set_uvalue=1B xsize = 5 state.wid_sum = cw_field(dummy, value=sum_width, /integer , title='Sum Area' , /row, xsize=xsize) state.wid_spot = cw_field(dummy, value= 1, /integer , title='Clean Spot' , /row, xsize=xsize) state.wid_sigma = cw_field(dummy, value= 4, /floating, title='Thresholds: Sigma', /row, xsize=xsize) state.wid_min = cw_field(dummy, value=30, /floating, title='Minimum' , /row, xsize=xsize) state.wid_qimage_cw = qImage_cw(wid_base, uvalue=mask_smei_fov) if state.wid_frames eq 0 then begin state.wid_frames = state.wid_run widget_control, state.wid_frames, set_uvalue=frames endif if n_elements(img_id) ne 0 then widget_control, state.wid_done, set_uvalue=img_id widget_control, wid_base, set_uvalue=state, /no_copy widget_control, wid_base, /realize xmanager, 'qGlitch', wid_base, group=group, no_block=no_block, event_handler='qGlitch_Event' if no_block then begin widget_control, wid_base, get_uvalue=state, /no_copy ;if n_elements(frames) eq 0 then img_offset = [0,0] if n_elements(img_offset) ne 0 then begin wid_child = widget_info(state.wid_qimage_cw, /child) widget_control, wid_child, get_uvalue=qimage_cw_state, /no_copy qimage_cw_state.img_offset = img_offset widget_control, wid_child, set_uvalue=qimage_cw_state, /no_copy endif widget_control, wid_base, set_uvalue=state, /no_copy endif return & end