function map2vis,map,mapcenter,pixelsize,harm=harm,u=u,v=v
; PURPOSE: front end to hsi_vis_map2vis2.pro, slightly more user-friendly inputs

; INPUTS:
;   map is an nxy x nxy-element square array specifying the flux (photons/cm2/s) at nxy x nxy spatial points.
;   mapcenter is a 2-element vector specifying the E,N displacement of the map center
; OPTIONAL:
;   u and v are vectors specifying the u and v values [arcsec^-1] at which the visibilities
;       are to be calculated.  If not specified, a reasonable default is used
;   pixelsize = SCALAR size of pixels (arcsec)
;
nxy = n_elements(map(*,0))
default,pixelsize,1.0
default,harm,1

x = (findgen(nxy)-nxy/2.+0.5)*pixelsize + mapcenter[0]
y = (findgen(nxy)-nxy/2.+0.5)*pixelsize + mapcenter[1]
xy=fltarr(2,nxy)
xy(0,*)=x
xy(1,*)=y

if not keyword_set(u) then begin
  k = 1.0/(hsi_grid_parameters()).pitch ; 9 values, starting with the finet grid
  u=fltarr(32,9)
  V=U
  phi=findgen(32)*!pi/32  ; angles from 0 to pi radians in steps of pi/32 (6 deg)
  for j=0,8 do u(*,j)=k(j)*cos(phi)
  for j=0,8 do v(*,j)=k(j)*sin(phi)
  u=reform(u,32*9)
  v=reform(v,32*9)
endif
nu=n_elements(u)
uv=fltarr(2,nu)
uv(0,*)=u
uv(1,*)=v



vis = hsi_vis_map2vis(map,xy,uv)

return,vis
end

