;+
; PROJECT:
;   HESSI
;
; NAME:
;   hsi_vis_shift_mapcenter
;
; PURPOSE:
;   Revises an array of visibilitiy structures, adjusting visibility phases to conform to a new phasecenter location.
;
; CATEGORY:
;   hessi/idl/image/visibility/gh
;
; CALLING SEQUENCE:
;   visout = hsi_vis_shift_mapcenter(visin, xyoffset_new)
;
; CALLS:
;   none
;
; INPUTS:
;   visin is an array of visibiltity structures.
;   xyoffset_new is a 2-element vector containing the new map center [arcsecs heliocentric W,N of Sun center);
;   xyoffset tags in input structure do not have to be the same.
;
; OPTIONAL INPUTS:
;   none
;
; OUTPUTS:
;  A revised visibibility structure, identical to visin, except with revised values of obsvis and xyoffset.
;
; OPTIONAL OUTPUTS:
;   none
;
; KEYWORDS:
;   none
;
; COMMON BLOCKS:
;   none
;
; SIDE EFFECTS:
;   none
;
; RESTRICTIONS:
;   Solar rotation is neglected.
;   Since xyoffset_new is specified with respect to sun center, this version is not well suited to shifting to
;       inertial coordinates.
;
; MODIFICATION HISTORY:
;   12-April-2007     Initial version (ghurford@ssl.berkeley.edu)
;
;-
FUNCTION hsi_vis_shift_mapcenter, visin, xyoffset_new
;
TWOPI           = 2 * !PI
visout          = visin
dx              = xyoffset_new[0] - visin.xyoffset[0]               ; nvis-element real array
dy              = xyoffset_new[1] - visin.xyoffset[1]               ; nvis-element real array
duxdvy          = -TWOPI * (dx*visin.u + dy*visin.v)                ; nvis-element real array -- note sign!
visout.obsvis   = visin.obsvis * COMPLEX(COS(duxdvy), SIN(duxdvy))  ; product of two nvis-element complex arrays
visout.xyoffset = xyoffset_new
RETURN, visout
END

