function hsi_pmap2xy,polmap,r1,r2, XYOFFSET=xyoffset,$ BOX_SIZE=box_size, PIXEL_SIZE=pixel_size ;+ ; NAME hsi_pmap2xy ; ; PURPOSE: ; Finds the x,y points inside an annulus of radii r1, r2, converts ; to polar coordinates and uses interpolation to extract values from ; a polar map polmap of size (N_az,N_r) ; INPUTS: ; polmap: ; 1st index is azimuth (0 to 360 degrees) -- arbitrary size ; 2nd index of polmap is radius (asec) -- LT 960 and GT 1 ; r1,r2 = integer values of inner and outer radii covered by pol ; box_size -- defaults to 960 x 960 arcsec for a rectangular projection ; pixel_size -- defaults to 2 arcsec for a rectangular projection ; ; OUTPUT: ; a square map of size BOX_SIZE with PIXEL_SIZE arcsec pixels ; ; VERSION HISTORY: ; EJS - OCT 1999 Just a Q&D to view polar maps rectangularly ; RAS - DEC 2, 1999 Added xyoffset, box_size, and pixel_size ;- checkvar,pixel_size, 2.0 checkvar,box_size,960 xyoffset = fltarr(2) size_pm = (size(polmap))[1:2] az_offset= 0.0 az_scale = 2.*!pi / size_pm[0] ;radians per polar map step in first dim. if box_size * pixel_size lt 1920 and total(xyoffset^2) eq 0 then begin peak= max( polmap, imax) rt_peak = get_ij(imax, (size(polmap))[1]) az = rt_peak[0] * az_scale + az_offset xyoffset= (r1+rt_peak[1]) * [cos(-az), sin(-az)] endif xy = hsi_pixel_coord( box_size + fltarr(2))* pixel_size for i=0,1 do if xyoffset[i] ne 0.0 then xy[i,*]=xy[i,*] - xyoffset[i] ;x=findgen(960)#replicate(1,960) ;y=transpose(x) ;r=2.*sqrt((x-479.5)^2+(y-479.5)^2) r = reform( sqrt( total( xy^2,1)), box_size, box_size) n_az=n_elements(polmap(*,0)) i_radius=r-r1 ;j_azimuth=(n_az/2)*(1-atan((y-479.5),(x-479.5))/!pi) j_azimuth = reform((n_az/2) * (1- atan(xy[1,*],xy[0,*])/!pi)) ;j_azimuth=(n_az/2)*((2+atan((y-479.5),(x-479.5))/!pi) mod 2) polmap=float(polmap) d=interpolate(polmap,j_azimuth,i_radius,missing=0) return,reform(d,box_size,box_size) end