!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! Convert from UVDAT to UVFIL data format when needed. The difference being
! the meanings of the weights.
!
! J.Pety and S.Guilloteau 2004
!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
on error return base
!
! Input parameters
!
define character gildasdata*6 gildasdatatype*5
define character old_uvt*256 new_uvt*256
let old_uvt &1 /prompt "old uvt file name (without extension)"
let new_uvt &2 /prompt "new uvt file name (without extension)"
let old_uvt 'old_uvt'".uvt"
let new_uvt 'new_uvt'".uvt"
!
! Check file existence
!
if file(old_uvt) then
   ! Check that it is a GILDAS binary file
   accept gildasdata /col 'old_uvt' /format (a)
   if (gildasdata.eq."GILDAS") then
      ! Check GILDAS data type
      accept gildasdatatype /col 'old_uvt' /format (7x,a)
      if (gildasdatatype.eq."IMAGE") then
         message w uvdat2uvfil ""'old_uvt'" is a gildas image, not a UV table"
      else if ((gildasdatatype.eq."UVDAT").or.(gildasdatatype.eq."UVSOR")) then
         message i uvdat2uvfil ""'old_uvt'" is a UV table using OLD format: converting"
         vector\transpose 'old_uvt' "gag-temp-old_uvt.tuv" 21
         vector\transpose "gag-temp-old_uvt.tuv" 'new_uvt' 21
         sic delete "gag-temp-old_uvt.tuv"
         message i uvdat2uvfil "Success"
      else if (gildasdatatype.eq."UVFIL") then
         message i uvdat2uvfil ""'old_uvt'" is a UV table using NEW format: nothing to be done"
      else
         message w uvdat2uvfil ""'old_uvt'" is of special type "'gildasdatatype'
         message w uvdat2uvfil "Please report to gildas@iram.fr"
      endif
   else
      message e uvdat2uvfil ""'old_uvt'" is not a GILDAS data file"
   endif
else
   message e uvdat2uvfil ""'old_uvt'" does not exist"
endif
!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
