;---------------------------------------------------------------
;! Calculate ionospheric delay and Faraday rotation corrections
;# PROCEDURE VLBI UTILITY CALIBRATION
;-----------------------------------------------------------------------
;;  Copyright (C) 2005-2006
;;  Associated Universities, Inc. Washington DC, USA.
;;
;;  This program is free software; you can redistribute it and/or
;;  modify it under the terms of the GNU General Public License as
;;  published by the Free Software Foundation; either version 2 of
;;  the License, or (at your option) any later version.
;;
;;  This program is distributed in the hope that it will be useful,
;;  but WITHOUT ANY WARRANTY; without even the implied warranty of
;;  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;  GNU General Public License for more details.
;;
;;  You should have received a copy of the GNU General Public
;;  License along with this program; if not, write to the Free
;;  Software Foundation, Inc., 675 Massachusetts Ave, Cambridge,
;;  MA 02139, USA.
;;
;;  Correspondence concerning AIPS should be addressed as follows:
;;         Internet email: aipsmail@nrao.edu.
;;         Postal address: AIPS Project Office
;;                         National Radio Astronomy Observatory
;;                         520 Edgemont Road
;;                         Charlottesville, VA 22903-2475 USA
;-----------------------------------------------------------------------
VLBATECR  LLLLLLLLLLLLUUUUUUUUUUUU CCCCCCCCCCCCCCCCCCCCCCCCCCCCC
VLBATECR  Procedure to calibrate ionospheric delay
INNAME                             Input UV file name (name)
INCLASS                            Input UV file name (class)
INSEQ             0.0     9999.0   Input UV file name (seq. #)
INDISK            0.0        9.0   Input UV file disk unit #
SUBARR                             Subarray to correct
                                     (0 => all)
           VLBATECR is defined in the VLBAUTIL run file.
----------------------------------------------------------------
VLBATECR
Type: Procedure
Use:  Automatically download IONEX files needed to correct the
      ionospheric dispersive delay with TECOR.  Then runs TECOR.
      See EXPLAIN TECOR for more information on this correction.
      To do the automatic download the system must have one of
      the following commands: wget, curl or ncftpget, and an NX
      table.
Adverbs
  INNAME.....Input UV file name (name).      Standard defaults.
  INCLASS....Input UV file name (class).     Standard defaults.
  INSEQ......Input UV file name (seq. #).    0 => highest.
  INDISK.....Disk drive # of input UV file.  0 => any.
  SUBARR.....Subarray to correct.            0 => all.
----------------------------------------------------------------
VLBATECR: Procedure that corrects ionospheric dispersive delay
          using TECOR.  This procedure automatically downloads
          the IONEX files from the CDDIS archive.
DOCUMENTOR: Amy Mioduszewski, NRAO
RELATED PROGRAMS: VLBAUTIL, TECOR

VLBATECR is designed to make the use of TECOR easier.  It uses
the header and the NX table to calculate what files to download
from CDDIS.  It uses the CDDIS site in the US (cddis.gsfc.nasa.gov)
and downloads the jplg or codg version of the IONEX files.  Then it
runs TECOR using these files.  For simplicity (files from multiple
days must to have the same prefix), all the files are renamed with
the jplg prefix.  The IONEX files are left in the /tmp area of your
computer, so you can copy them for your records or ignore them.

See EXPLAIN TECOR for details on the ionospheric correction.

This procedure is defined in VLBAUTIL, type RUN VLBAUTIL to load
VLBAUTIL.

To run VLBATECR:
   1) The dataset must have a correct observation date in the header;
      if it is wrong correct it with PUTHEAD.
      -> there is a weak test on the validity of the observation date;
         the observation year must be <= to the creation year.
   2) The dataset must have an NX table; run INDXR or VLBAFIX to create.
   3) The system must have one of the following commands: wget, curl or
      ncftpget.  VLBATECR will test for the existence of these commands
      in the order given above and will the first one it finds.
      Mac OS - will probably have curl; wget and ncftpget seem to be
      available in Fink.
   4) /tmp directory must exist on your computer
   5) Your computer must allow link to the Internet, some computers may
      have firewalls such that the above commands exist, but will not work.

VLBATECR should be run on data of 8 GHz and lower, and can be run
anytime before the last fringe fit and after VLBAFIX.  For simplicity,
it is recommended that it be run right after VLBAFIX or VLBAEOPS, so
all corrections to the data are done before calibration.
