; VLBALOAD
;---------------------------------------------------------------
;! Loads VLBA data
;# PROCEDURE VLBI UTILITY FITS
;-----------------------------------------------------------------------
;;  Copyright (C) 2000-2006, 2008
;;  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
;-----------------------------------------------------------------------
VLBALOAD  LLLLLLLLLLLLUUUUUUUUUUUU CCCCCCCCCCCCCCCCCCCCCCCCCCCCC
VLBALOAD: Procedure to load VLBA data from tape
INTAPE            0.0       9.0    Input tape drive number
DATAIN                             Disk file name
NFILES         -999.0    9999.0    # of files to advance on tape
NCOUNT            0.0    9999.0    Number of files to load
                                   (read from insert card)
OUTNAME                            Output file name
OUTDISK           0.0      15.0    Disk drive for output data
                                   (0 => any)
DOUVCOMP         -1.0       1.0    >0 => write compressed data
CLINT                              CL entry interval (min)
                                   0 => 0.25 minute

          VLBALOAD is defined in the VLBAUTIL run file.
----------------------------------------------------------------
VLBALOAD
Type: Procedure
Use:  VLBALOAD is a procedure that loads VLBA data from tape and may
      be used for any data from the VLBA correlator.  VLBALOAD also
      runs TAMGR to merge redundant entries in the calibration tables
      (GC, TY and PC) (this makes running VLBAMCAL unnecessary).

      Type RUN VLBAUTIL to make the VLBALOAD procedure available.
      Note that VLBALOAD permanently flags data with weights less than
      0.7, which is fine for most data sets.

Adverbs:
  INTAPE......The input tape drive number. This procedure assumes that
              you have already mounted a FITS tape on this drive. Zero
              defaults to tape drive number one.
  DATAIN......48-character name of the disk file from which to read a
              FITS file.  It must be in the form
                  <logical>:<file name>
              or
                  <node>::<logical>:<file name>
              where <node> is the remote computer name, <logical> is the
              environment variable (logical name) for the disk area in
              which the file named <file name> is stored.  <node> is
              usually omitted when the file is local to the current
              computer.  If DATAIN is not found, the task will try
              DATAIN with the character 1 appended.
              Beginning 2003-Oct-16 FITLD can read more than one disk
              file at a time.  In that case, they must all have the
              same name except that the last letter(s) are the
              sequence number 1 through NCOUNT with no leading zeros.
              DATAIN must give the base name only, omitting the
              sequence number.  Then either
                    DATAIN = 'MYDATA:file_
              or
                    DATAIN = 'MYDATA:file_1
              can access files in $MYDATA named file_1, file_2,
              file_3, etc.  Note that this is similar to the pieces of
              a FITS pieced UV-table data set, but only one UV-table
              data set may be read at a time.
  NFILES......# of files to skip on tape before reading data.  For
              example, 1 => start of next file, -1 => start of previous
              file.  0 => no tape movement at all.  (AIPS verbs AVFILE
              plus TPHEAD allow you to position and check the tape in
              advance; be sure to reset NFILES to 0 for FITLD after
              them.)
  NCOUNT......The number of files to read from the tape.
              Zero defaults to a large number.
              You can read the number of files on a VLBA
              correlator tape from the listing inserted in the
              tape case.
  OUTNAME.....The name for the output files. The output files
              will all be given the class UVDATA and assigned
              distinct sequence numbers as needed.
  OUTDISK.....The disk drive number for the output data. Choose
              a disk with a large amount of space.
  DOUVCOMP....If true (> 0.5) then output data will be
              compressed which saves disk space at the expense
              of losing some weighting information.
  CLINT.......Calibration table interval in minutes. This should
              normally be in the range 0.25 to 1.0.  If <=0 then
              0.25 is assumed.
----------------------------------------------------------------
VLBALOAD:           Procedure to load VLBA data from tape.
Documentor:         Chris Flatters
Related Programs:   FITLD, VLBAUTIL, VLBAMCAL, TAMGR

WHEN TO USE VLBALOAD

Use VLBALOAD to load all of the data from one or more VLBA export tapes into
a single AIPS file. Do not use VLBALOAD if you need to apply data selection
criteria or otherwise need more control over FITLD.  As VLBALOAD permanently
flags data with weights less than 0.7, VLBALOAD is not appropriate for
data with a high fraction of low weights.  VLBALOAD will also run TAMGR
to merge redundant entries in the calibration tables (GC, TY and PC).
This will only be run if there are calibration tables and more than 1
file has been loaded from tape.  THIS IS A NEW FEATURE AND MAKES RUNNING
VLBAMCAL UNNECESSARY.

VLBALOAD is primarily intended for novice VLBA users and ensures that FITLD
is run with settings that make sense for most VLBA experiments.

LOADING DATA WITH VLBALOAD

1) If you have not already done so, type RUN VLBAUTIL to make the VLBALOAD
   procedure available to you.

2) Examine the listings inserted in each of your tapes and sum the total
   kilobytes for all of the tapes. This approximates the size of the
   uncompressed data set that will be used in AIPS.

3) Type FREE and check the free blocks for each disk. You will need enough
   disk space to hold at least 2 copies of your data in order to process it.

4) If there is at least one disk where the number of free blocks is more than
   twice the uncompressed size of your data in kilobytes or if there are at
   least two disks where the number of free blocks is greater than the
   uncompressed size of your data in kilobytes then set DOUVCOMP to FALSE, set
   OUTDISK to the number of a disk with a number of free blocks greater than
   the uncompressed size of your data, and then proceed to Step 7, otherwise
   continue with Step 5.

5) Divide the uncompressed size of your data by 3. This is a rough estimate of
   the compressed size of your data. If there is at least one disk where the
   number of free blocks is more than twice the compressed size of your data
   or if there are at least two disks where the number of free blocks is
   greater than the compressed size of your data then set DOUVCOMP to TRUE,
   set OUTDISK to the number of a disk with a number of free blocks greater
   than the uncompressed size of your data, and then proceed to Step 7,
   otherwise continue with Step 6.

6) If you have reached this point then you do not have sufficient disk space
   to reduce you data. You either need to delete some old files or to find a
   machine with more disk space.

7) Choose a calibration table interval and specify it as CLINT. One minute
   will be suitable for most experiment. Higher frequency bands may require
   shorter intervals. Consult a more experienced VLBA user if you are not sure
   what to use.

8) Specify a name for your output data files. The OBSCODE is often a good
   choice.

9) Specify the tape drive that you will be using as INTAPE.

10) Insert the first tape in your drive and mount it using the MOUNT verb.

11) In most cases set NFILES to 0

12) Set NCOUNT to the number of files listed on the insert and then type
    VLBALOAD.

13) When the procedure finishes and the AIPS prompt reappears, dismount the
    tape.

14) If you have more than one tape then repeat steps 10 through 12 for each
    remaining tape.

WHAT TO DO NEXT

After loading the data, you should normally run VLBAFIX to sort the data etc,
if necessary.
