; HF2SV
;---------------------------------------------------------------
;! convert HF tables from FRING/MBDLY to form used by Calc/Solve
;# TASK TABLE VLBI ASTROMETRY
;-----------------------------------------------------------------------
;;  Copyright (C) 1995, 1997, 2009
;;  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
;-----------------------------------------------------------------------
HF2SV     LLLLLLLLLLLLUUUUUUUUUUUU CCCCCCCCCCCCCCCCCCCCCCCCCCCCC
HF2SV:    Convert HF table to Binary Output for Calc/Solve
INNAME                             Main input file (name).
INCLASS                            Main input file (class).
INSEQ             0.0    9999.0    Main input file (seq. #).
                                      0 => high
INDISK            0.0       9.0    Disk unit #.       0 => any
INEXT                              'HF' only.
INVERS                             Input  file version no.
ANTENNAS                           Reference antennas 0 => all
BCOUNT            0.0    99999.0   Beginning row to copy
ECOUNT            0.0    99999.0   Last row to copy: 0 => end
OUTFILE                            Logical name of directory
                                   for output.
----------------------------------------------------------------
HF2SV
Type:  Task
Use:   This task reads the HF files created by CL2HF or written
       in by MK3IN.  This is simply a bookkeeping program which
       converts each HF row into a file directory structure
       which can be read in directly by dbedit in the calc
       solve package.
Adverbs:
  INNAME......Main file name (name).       Standard defaults.
  INCLASS.....Main file name (class).      Standard defaults.
  INSEQ.......Main file name (seq. #).     0 => highest
  INDISK......Disk drive # of image.       0 => any
  INEXT.......Input table type.  Must be 'HF'.
  INVERS......Input extension file version #.
  ANTENNAS....Reference antennas.  0 => all
              One reference antennas will do all baselines to
              that antenna.
  BCOUNT......Beginning row number to be included .
  ECOUNT......Last row number included.  0 = highest.
  OUTFILE.....The logical name used for the directory in which
              the data is put.  The directory must already be
              created.
----------------------------------------------------------------
PROGRAM:  HF2SV
DOCUMENTOR:  Ed Fomalont  94.11.15
RELATED PROGRAMS:  FRING, MBDLY, BLING, BLAPP, CL2HF, calc/solve

                      PURPOSE

The program HF2SV reads an HF file created by CL2HF.  The HF file
contains the fringe-fit residual rates, delays and phases
determined from FRING and MBDLY (or BLING and BLAPP), and the
apriori rates, delays and phases calculated from the CL table.
Many other parameters associated with the scan are also given in
the HF file.  The output file has 6 binary records, each with
256 bytes.  Their contents are described in the documentation
for dbedit in the solve software package.

The files written by HF2SV are placed under the directory given
in OUTFILE.  The proper definition of OUTFILE is generally
made before AIPS is initiated by the setenv command.  The
predefined logical files, like FITS can be used.

For example, before initiating AIPS type in unix

        setenv HFTEST /tmp_mnt/AIPS/USERS
        mkdir SBAND  (if not already existing)

Then, begin AIPS.  For OUTFILE='HFTEST:SBAND', the following
files will be made during execution.

        /tmp_mnt/AIPS/USERS/SBAND/FRING.LIST

which contains a summary of all of the data files which have
been written.  The data files are in:

        /tmp_mnt/AIPS/USERS/SBAND/ddd-hhmm/AB.F.MM.abcdef
where:
      ddd-hhmm  is the day number of the observations
                egs. 241-1434.
      AB        is the baseline, one capital letter per
                station.  The codes are defined by the
                infile parameter in CL2HF.
      F         is the band designation.  egs X or S.
      MM        is a sequence number, from 01 to 99.  It
                distinguishes separate fringe results of
                the same data.
      abcdef    is a 6-figure, 26-base time stamp.  It
                is not used at the present time.

In general the directory /ddd-hhmm contains several files;
one for each baseline fringe fit and one file of the form
wd/ddd-hhhmm/SOURCE.  This latter file is optional and not
needed by solve.

The files under OUTFILE can be read directly into solve
using the program dbedit.  If the files are to be transported
elsewhere it is more convenient to place them in a tar file.
For example, if the files are located in

          tmp_mnt/AIPS/USERS/SBAND/ddd-hhmm/BB.F.N.jbuuca

then execute tar from the tmp_mnt/AIPS/USERS

          tar cvf TARSBAND SBAND

to create a file tarfile which contains everthing in the
SBAND directory.  This tar file can then be conveniently
transported over ftp or by tape.  It can then be put back
into the original directory structure by running

          tar xvf TARSBAND

in a desired directory DIR.  The data will be put under
directory DIR/SBAND.

