; OFLAG
;---------------------------------------------------------------
;! uses on-line flag table information to write a flag table
;# TASK TABLE EDITING
;-----------------------------------------------------------------------
;;  Copyright (C) 2008, 2018
;;  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
;-----------------------------------------------------------------------
OFLAG     LLLLLLLLLLLLUUUUUUUUUUUU CCCCCCCCCCCCCCCCCCCCCCCCCCCCC
OFLAG:  Task to convert on-line flag info to a flag table
INNAME                             Image name (name)
INCLASS                            Image name (class)
INSEQ             0.0    9999.0    Image name (seq. #)
INDISK            0.0       9.0    Disk drive #
INVERS            0.0   46655.0    Extension file version #
FLAGVER          -1.0   46655.0    Flag table to copy first
OUTFGVER          0.0   46655.0    Output flag table version
DETIME            0.0              Expand OF time by DETIME sec
DOFLAG           -1.0              Flag if score >= DOFLAG
FPARM            -1.0       1.0    Flag if bit set?
BADDISK                            Disks to avoid for scratch
--------------------------------------------------------------------
OFLAG
Type:  Task
Use:   OFLAG interprets the bit pattern column and "warning score"
       columns of an on-line flag (OF) table to write a normal AIPS
       flag (FG) table.  At present this is only implemented for the
       VLA.

       FILLM by default acts as if FPARM=0; DOFLAG=3.  Note that OFLAG
       will count the bits that are set even if FPARM is 0 when
       samples are flagged due to DOFLAG or other bits.  This count is
       reported as "Found" unless it matches a count of "Flagged"
       because of each bit.
Adverbs:
  INNAME.....Image name (name).           Standard defaults.
  INCLASS....Image name (class).          Standard defaults.
  INSEQ......Image name (seq. #).         0 => highest.
  INDISK.....Disk drive # of image.       0 => any.
  INVERS.....Extension file version #     0 => highest.
  FLAGVER....As a convenience to the user, a pre-existing flag table
             may be copied to OUTFGVER before the OF table is read.
             -1 => do not copy, 0 => copy highest pre-existing
             version.  Note: if OUTFGVER is pre-existing, no table is
             copied.
  OUTFGVER...Desired output FG table.  0 -> highest plus 1.
  DETIME.....OF tables have a single time for each record.  The FG
             table should have a time range for each flag.  That will
             be TIME - DETIME to TIME + DETIME where DETIME is in
             seconds and has a minimum value of 0.02.
  DOFLAG.....> 0 => generate flags whenever the score column(s) equal
                    or exceed DOFLAG
             <= 0 => ignore the score column(s)
             A warning score of 0 means no warning and is displayed
             with blanks by PRTOF.  Values of 1 - 3 are intended as
             mild warnings, values of 4 - 15 are more severe.  In
             practise, the VLA appears to issue scores of 0 and 4
             only.
  FPARM......If FPARM(i) > 0, then generate a flag if bit i of the
             bit-pattern column is set (1).  For the VLA the pattern
             has meanings
             Bit   Meaning
             --   ---------------------------------------------
              1   reference pointing requested, but not applied
              2   antenna shadowed at source change time
              3   antenna off source
              4   first LO not locked
              5   Tsys fluctuating
              6   antenna flagged bad by operator
              7   back-end total power out of range
              8   back-end filters mis-set
              9   L8 module not locked
             10   L6 module not locked
             11   sub-reflector not in position
             12   source change in progress
             13   phase switching disabled
             14   round-trip phase correction disabled
  BADDISK....The disk numbers to avoid for scratch files (sorting
             tables mostly).
----------------------------------------------------------------
