function hsi_polar_mapper,det_index,ce,xy_offset,plot=plot ;+ ; NAME: hsi_polar_mapper ; ; PURPOSE: ; MAKES A POLAR MAP FROM A CALIBRATED EVENT LIST ; ; USAGE: ; 1. Make a model map and call hsi_calib_eventlist ; 2. Convert the counts to visibilities using calib_ev2vis ; 4. Get the aspect structure for the same time bins ; 5. Shift the visibility phases to sun center ; 6. Make the polar map with vis2pmap ; ; INPUTS: ; det_index = scalar, 0-27 ; ce = calibrated event list structure ; xy_offset = [x,y] vector of inertial coords of map center (arcsec) ; /plot Set this if you want plots and images ; ; OUTPUTS: ; dmap = radius and azimuth map ; dmap_xy = x,y projection (annulus) of dmap ; ; EXAMPLE: ;; 1. MAKE THE MODEL MAP ; model=fltarr(64,64) ; model(31,11)=1 ; ;; 2. CREATE THE CALIBRATED EVENT LIST for the selected det_index ; det_index=5 ; xy_offset=[650,200] ; sim_xy_offset=xy_offset+25 ; sim_photons=2000 ; det_mask=intarr(27) & det_mask(det_index)=1 ; bin_size=2L^12 ; microseconds (this is ok except for det_index=0) ; num_bins=(2L^22)/bin_size ; time_range=[0,4] ; If this is changed, hsi_polar_mapper won't work ; o = obj_new( 'hsi_calib_eventlist') ; timebindef = o->get( /time_bin_def ) ; get the default array ; timebindef(det_index)=bin_size ; ce = o->getcalibeventlist(det_index, SIM_TIME_range=time_range, $ ; TIME_RANGE=time_range, SIM_PHOT=sim_photons, $ ; A2D_INDEX_MASK=det_mask,TIME_BIN_DEF=timebindef,SIM_MODEL=model, $ ; SIM_XYOFFSET=sim_xy_offset, XYOFFSET=xy_offset) ;,/saszero ;; 3. Call the mapper: ; dmap=hsi_polar_mapper(det_index,ce,xy_offset,/plot) ; ; ; RESTRICTIONS: ; Works only for time_range=[0,4] and for a single subcollimator. ; If the map position is several pitches away from the flare centroid, ; the map will be poor. ; ; CALLS: ; hsi_grid_parameters ; hsi_calib_ev2vis, (converts counts to visibilities) ; hsi_ls_sin_cos ; hsi_ls_amp_pha_ctr ; hsi_vis2pmap, which makes a polar map calling: ; hsi_convl (the key to speed) ; hsi_pmap2xy (interpolates the polar map onto xy coordinates) ; ; VERSION HISTORY: ; VERS. 1 ; Revised to match compute_model_ce.pro Sept 17, 1999 ; VERS. 2 Sept. 27, 1999 -- EJS ; Various bugs squashed ; Forced visibility to be Hermitian ; VERS. 3 ; Replaced Bessel-fcn array with FFTs ; Added CONVL program for fast convolution (extends convolve.pro). ; Made to work with an externally-produced calib_eventlist ; Lots of bugs remain. Oct 26, 1999 -- EJS ; ; VERS 4 ; Found and squashed serious bug that caused improper location of ; mapped source (cause was applying phase shift in this prgm ; before applying roll_angle shift in CALIB_EV2VIS.) ; Moved the roll-angle shift to here. Nov 23, 1999 -- EJS ; ; NOTES: ; No general times yet: We extract only the first 1/2 of 1 ; rotation from an entire rotation. ;; There is something suspicious about the first dark ring in array ; dmap_xy -- what causes this? ; ; ; RESTRICTIONS: ; WORKS ONLY FOR TIMERANGE=[0,4] ; ;function hsi_polar_mapper,det_index,ce,xy_offset,plot=plot ;- pitch=((hsi_grid_parameters()).pitch)(det_index) grid_angle=((hsi_grid_parameters()).orient)(det_index) if keyword_set(plot) then begin window,/free,title='hsi_polar_mapper.pro' plot,ce.dx,ce.dy,tit='ASPECT VALUES' endif ; CONVERT THE COUNTS TO VISIBILITIES: cyc_fac=1 message,'Running hsi_calib_ev2vis without filter; cycle_factor='+ $ string(cyc_fac),/inform ; ; Report the time start_time = systime(1) vis0=hsi_calib_ev2vis(det_index,ce, cycle_factor=cyc_fac) ; best cycle_factor total_time = systime(1) - start_time message,/inform,'Time in hsi_calib_ev2vis: ' + string(total_time) ; GET THE PHASE FACTOR FOR MAP PHASE CENTER alpha=2*!pi*((ce.dx)*cos(grid_angle)+(ce.dy)*sin(grid_angle))/pitch ; SHIFT THE VISIBILITY PHASES TO SUN CENTER: i=complex(0,1) vis1=vis0*exp(-i*alpha) ; seems to be correct ; EJS Nov 23 Moved this from calib_ev2vis ashift=-n_elements(vis1)*grid_angle/(2*!pi) message,'Shifting visibility'+string(ashift),/inform vis_shifted=shift(vis1,ashift) if keyword_set(plot) then begin window,1 !p.multi=[0,1,2] plot,float(vis1),xsty=1,tit='Real Part of Pre-shifted Visibilities' plot,float(vis_shifted),xsty=1,tit='Real Part of Shifted Visibilities' !p.multi=0 endif ; HERMITIANIZE THE VISIBILITIES -- USE ONLY TIMERANGE=[0,2] SECONDS vis=vis_shifted ; EJS Nov 23 num_bins=n_elements(vis) vis(num_bins/2:num_bins-1)=conj(vis(0:num_bins/2-1)) ;if keyword_set(plot) then BEGIN !p.multi=[0,1,2] window,/free,xsize=1000,ysize=400,title='hsi_polar_mapper.pro' plot,ce.roll_angle,ce.count,xsty=1,Ysty=1,tit='COUNT RATE (det_index='+strcompress(det_index)+')',xtit='ROLL ANGLE (radians) plot,ce.roll_angle,vis0,tit='Visibility (vis0)',xsty=1,Ysty=1,xtit='ROLL ANGLE (radians) !p.multi=0 wset,0 ;endif ; THEN CREATE AN ANNULAR DIRTY MAP: mapHwidth=256 & r_outer=906 ; => r_inner=394 (394+906)/2=650 dmap_xy=1 message,'Calling hsi_vis2pmap...',/inform if keyword_set(plot) then begin message,'Calling hsi_vis2pmap with /plot set',/inform dmap=hsi_vis2pmap(vis,ce.roll_angle,det_index,mapHwidth,RSIZE=r_outer,dmap_xy,/plot) endif else begin message,'Calling hsi_vis2pmap with /plot NOT set',/inform dmap=hsi_vis2pmap(vis,ce.roll_angle,det_index,mapHwidth,RSIZE=r_outer,dmap_xy) help,'From hsi_vis2pmap ',dmap endelse return,dmap end