; OOSRT
;---------------------------------------------------------------
;! Sort a UV dataset into a specified order
;# TASK UV CALIBRATION OOP
;-----------------------------------------------------------------------
;;  Copyright (C) 2000, 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
;-----------------------------------------------------------------------
OOSRT     LLLLLLLLLLLLUUUUUUUUUUUU CCCCCCCCCCCCCCCCCCCCCCCCCCCCC
OOSRT:  Task which sorts UV data
INNAME                             Input UV file name (name)
INCLASS                            Input UV file name (class)
INSEQ             0.0    9999.0    Input UV file name (seq. #)
INDISK                             Disk unit # of input UV data
OUTNAME                            Sorted UV file name (name)
OUTCLASS                           Sorted UV file name (class)
OUTSEQ           -1.0    9999.0    Sorted UV file name (seq. #)
OUTDISK                            Disk unit # of sorted UV data
                                     0 => highest with space
                                   If outfile spec. equals the
                                   infile spec., output will
                                   overwrite the input
SORT                               Two char. sort order, eg.'XY'
                                   blank => 'XY'
ROTATE         -360.0     360.0    Angle thru which to rotate.
                                   positive rotates CCW
BADDISK                            Disk drive #'s to avoid
----------------------------------------------------------------
OOSRT
Type:  Task
 Use:  To sort UV data into a specified order.  The data are
       sorted into ascending values of the 2 two keys.
       Two keys are always used in the sort.

       NOTE: this task does NOT apply flagging or calibration tables
       to the input UV data.  Run SPLIT first if that operation is
       desired.
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.    0 => any.
  OUTNAME....Output UV file name (name).  Standard defaults.
  OUTCLASS...Output UV file name (class). Standard defaults.
  OUTSEQ.....Output UV file name (seq. #).0 = > highest unique.
  OUTDISK....Disk drive # of output UV.  0 => highest with space
             If the outfile specification equals the infile
             specification, the output data file will overwrite
             the input data file.
  BADDISK....Disk drive #'s of bad disks (for scratch files).
  SORT.......Sort order of output.  blank => 'XY' and is the
             sort order needed for input to UVMAP.
               see HELP SORT for more information
  ROTATE.....Angle thru which to rotate map, positive is CCW.
             (degrees) rotation of the image.
----------------------------------------------------------------
OOSRT:  Task which sorts UV data
DOCUMENTOR: E.B.Fomalont (NRAO/VLA)
RELATED PROGRAMS: UVLOD, UVMAP, ASCAL

                         PURPOSE

     OOSRT will sort a UV data base into a specified order.  The
program is generally used after UVLOD and before UVMAP in order
to sort the data from time-baseline order 'TB' into order of
descending abs(u) spacing, which is designated as 'XY', needed
for UVMAP.  Before using ASCAL to self-calibrate a data base
the UV sort order must be 'TB'.  The order of the data base can
be found by using the verb IMHEADER.  After concatenation of
data bases, OOSRT must be run to put the data into 'TB' or 'XY'
order.

     This task does not use the array-processor but it is a very
heavy user of the cpu power and disk space.  If a data base of
length N is sorted, it requires three areas of length N.  Two
areas are needed as scratch files and one is needed for the
output data base.  The latter can be avoided by overwriting the
output onto the input.

                         COMMENTS

OUTNAME, OUTCLASS, OUTSEQ, OUTDISK:
     If the outfile specification is identical to the infile
specification (including defaults used in both file
specifications), then the sorted data will overwrite the input
data.  Make sure the input data set is properly backed up before
you overwrite since a computer crash may destroy the input data
set.

SORT:
     The sort order is specified by two keys which are
characters in the adverb SORT.  The legal keys are:
         blank => X = descending ABS(u)
             B => baseline number
             T => time order
             U => u spatial freq. coordinate
             V => v spatial freq. coordinate
             W => w spatial freq. coordinate
             R => baseline length.
             P => baseline position angle.
             X => descending ABS(u)
             Y => descending ABS(v)
             Z => ascending ABS(u)
             M => ascending ABS(v)

ROTATE:
     A positive number will rotate an image counter-clock-wise.
That is, an image made from the sorted data with ROTATE=30 will
produce an image which is rotated 30 degrees counter-clock-wise
when compared with the image made from the sorted data with
ROTATE=0.
     Map rotation is useful for orienting long, thin sources
vertically or horizontally in order to permit smaller,
rectangular maps to be made.  This rotation cannot be done in
UVMAP since it reorders the UV data.  It is usually more
convenient to orient the source with its long axis vertically
rather than horizontally when using subsequent display software.
