pro smei_setup_roi, destroy=destroy ;+ ; NAME: ; smei_setup_roi ; PURPOSE: ; Fill common block with ROI information ; CATEGORY: ; camera/idl ; CALLING SEQUENCE: ; smei_setup_roi ; INPUTS: ; (from text file smei_roi.txt) ; OPTIONAL INPUTS: ; /destroy destroys ROI heap variables ; OUTPUTS: ; CALLS: ; InitVar, IsType, MagnifyArray, who_am_i, destroyvar, txt_read, ArrayLocation ; INCLUDE: @compile_opt.pro ; On error, return to caller ; @smei_roi_mask.pro ; PROCEDURE: ; Sets up pointers to list of array indices into SMEI frames for each of the modes ; For i=0,1,2 (three different modes): ; *roi_siz[i] 2-element array with image dimension ; *roi_frm[i] list of pixels included in the SMEI roi ; *roi_fov[i] list of pixels inside the field of view (incl. *roi_bad[i]) ; *roi_drk[i] list of pixels in dark current columns ; *roi_sqr[i] list of pixels in two squares outside fov arc ; *roi_pix[i] list of pixels in center square inside fov arc ; *roi_ped[i] list of pixels in pedestal columns ; *roi_col[i] list of pixels in pedestal and dark current columns ; *roi_bad[i] list of pixels with partially covered pixels ; (i.e. the column to the right of the dark columns on the left, and ; the column to the left of the dark columns on the right of the frame) ; MODIFICATION HISTORY: ; APR-2003, Paul Hick (UCSD/CASS; pphick@ucsd.edu) ;- InitVar, destroy, /key ; THIS MUST STAY BEFORE THE INCLUDE FILE !!! case destroy of 0: begin @smei_roi_mask.pro ; ROI common block (DO NOT MOVE THIS OUT OF THE CASE BLOCK !!) if IsType(roi_siz, /undefined) then begin if not txt_read(filepath(root=who_am_i(/dir),'smei_roi.txt'), mask, silent=2) then $ message, 'no ROI mask avaible' mask = byte(mask)-(byte('0'))[0] roi_siz = ptrarr(3, /allocate_heap) roi_frm = ptrarr(3, /allocate_heap) roi_fov = ptrarr(3, /allocate_heap) roi_drk = ptrarr(3, /allocate_heap) roi_sqr = ptrarr(3, /allocate_heap) roi_pix = ptrarr(3, /allocate_heap) roi_ped = ptrarr(3, /allocate_heap) roi_col = ptrarr(3, /allocate_heap) roi_bad = ptrarr(3, /allocate_heap) for i=2,0,-1 do begin ; Loop over all three modes if i ne 2 then mask = MagnifyArray(mask,2) *roi_siz[i] = size(mask,/dim) *roi_frm[i] = where(mask ne 0) *roi_fov[i] = where(mask eq 1) *roi_drk[i] = where(mask eq 2) *roi_sqr[i] = where(mask eq 3) *roi_pix[i] = where(mask eq 4) *roi_ped[i] = where(mask eq 5) *roi_col[i] = where(mask eq 5 or mask eq 2) p = ArrayLocation(*roi_fov[i], dim=*roi_siz[i]) pmin = min( p[0,*], max=pmax ) ; Min/max column in fov p = p[*,where( p[0,*] eq pmin or p[0,*] eq pmax )] *roi_bad[i] = ArrayLocation(p, dim=*roi_siz[i], /onedim) endfor endif end 1: begin if IsType(roi_siz, /defined) then begin ptr_free , roi_siz, roi_frm, roi_fov, roi_drk, roi_sqr, roi_pix, roi_ped, roi_col, roi_bad destroyvar, roi_siz, roi_frm, roi_fov, roi_drk destroyvar, roi_sqr, roi_pix, roi_ped, roi_col, roi_bad endif end endcase return & end