%N cocvtv %F $MIR/src/subs/co.for
%D Convert coordinates - with validation.
%P rjs
%: coordinates
%B
      subroutine coCvtv(lu,in,x1,out,x2,valid)

      integer lu
      character in*(*),out*(*)
      double precision x1(*),x2(*)
      logical valid
  ---------------------------------------------------------------------
  Convert coordinates from one coordinate system to another.  Input and
  output coordinates can be either "pixel" or "world" coordinates, and
  either "absolute" or "offset".

  "World" coordinates are the normal physical coordinates.  They are
  given in radians (for astronomical positions), GHz (frequencies),
  km/s (velocities) and lambda (U-V axes).

  Pixel coordinates are fairly conventional.

  For world coordinates, absolute and offset values differ only by the
  reference world value (crval).  The exception is longitude-type axes
  (e.g. RA), where offset coordinates are offsets on the sky -- that is
  the offsets are multiplied by the cos(latitude) (cos(DEC)) term.

  For pixel coordinates, absolute and offset values differ by reference
  pixel value (crpix).

  For visibility datasets (where the axes are simply RA and DEC),
  "pixel coordinates" are defined as those that would result from
  imaging (using a conventional 2D Fourier transform algorithm) the
  data-set with a cell size of 1 radian.  Additionally the reference
  pixel values (crpix) are set to 0.  This means that the "absolute
  pixel" and "offset pixel" coordinates are identical, and that "offset
  pixel" and "offset world" coordinates differ only by the inaccuracy
  in the normal small angle approximation for offsets in RA and DEC.

  Input:
    in         A character string indicating the input coordinate
               types.  See the prologue of coCrack.
    x1         Input coordinate elements of type specified by the 'in'
               parameter.  The dimensionality must agree with 'in'.
    out        Output coordinate codes, in the same fashion as 'in',
               corresponding one-for-one with the inputs.
  Output:
    x2         Output coordinate elements of type specified by 'out'.
    valid      If true, all is OK, otherwise the coordinate conversion
               requested was invalid.
