! Purpose : test conversion between XYZ Geocentric coordinates
! and Longitude, Latitude, Altitude
!
! Call  
!     @ xyz-lonlat uvfits_file_name  (without extension)
!
! Method
!     Recover the XYZ coordinates from the two places
!   they may have in the CASA UVFITS files
!     Call the xyzlonlat task to do the conversion and
!     display
! S.Guilloteau 20-Jan-2015
!
define fits a &1.uvfits
!
define double geoxyz[3] /global
if exist(a%aips_an%arrayx) then
  geoxyz[1] = a%aips_an%arrayx
  geoxyz[2] = a%aips_an%arrayy
  geoxyz[3] = a%aips_an%arrayz
  if exist(a%aips_an%col%stabxyz) then
    if (geoxyz[1].eq.0.and.geoxyz[2].eq.0.and.geoxyz[3].eq.0) then
      geoxyz = a%aips_an%col%stabxyz[1]
    endif
  endif
else
  say "E-XYZ-LONLAT,  FITS file has no Array location"
  return
endif
!
begin data xyzlonlat.dat
  !
  TASK\REAL "Geocentric coordinates" XYZ$[3] geoxyz
  TASK\CHAR "Greenwich East Longitude" LONGITUDE$ " "
  TASK\CHAR "Latitude" LATITUDE$ " "
  TASK\REAL "Altitude (in meters)" ALTITUDE$ 0
  TASK\GO 
end data
!
run xyzlonlat xyzlonlat.dat /nowin
!
exa geoxyz
!
!------------------------------------------
SAY "Example for Plateau de Bure"
def doubl lon lat
! From CASA  http://casa.nrao.edu/docs/CasaRef/measures.observatory.html
!
! In CASA
!   print me.observatory(’PDB’)
!
let lon 0.10309153883282669
let lat 0.7756481013100227
def char clon*14 clat*14
let lon lon*180/pi
let lat lat*180/pi
let clon lon /sexa
let clat lat /sexa
exa clon
exa clat
!


