; FIXBX
;---------------------------------------------------------------
;! converts a BOXFILE to another for input to IMAGR
;# Task Imaging
;-----------------------------------------------------------------------
;;  Copyright (C) 2004-2005, 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
;-----------------------------------------------------------------------
FIXBX     LLLLLLLLLLLLUUUUUUUUUUUU CCCCCCCCCCCCCCCCCCCCCCCCCCCCC
FIXBX:  Task to convert a BOXFILE to another for input to IMAGR
INNAME                             UV dataset name (name)
INCLASS                            UV dataset name (class)
INSEQ             0.0    9999.0    UV dataset name (seq. #)
INDISK            0.0       9.0    Disk drive #
SOURCES                            Source selected
INFILE                             previous BOXFILE for IMAGR
                                   containing desired boxes
NMAPS             0.0    4096.0    Old number facets
NGAUSS            0.0      10.0    Old/new number Gaussians
NOISE                              Old RASHIFT values
PBSIZE                             Old DECSHIFT values
NBOXES             0.0     50.0    Number of boxes for Clean
                                   NB: field 1 only.
CLBOX             -2.0   16384.0   Four coordinates for each box
BOXFILE                            new BOXFILE for IMAGR to be
                                   given translated boxes
NFIELD            0.0    4096.0    New number facets
RASHIFT                            New facet RA shift (asec)
DECSHIFT                           New facet Dec shift (asec)
OBOXFILE                           new BOXFILE for IMAGR with
                                   translated boxes
CELLSIZE        0.0                new grid spacing in asec
IMSIZE          0.0      16384     new field size
ROTATE                             new rotation
BPARM                              (1) Old CELLSIZE(1)
                                   (2) Old CELLSIZE(2)
                                   (3) Old IMSIZE(1)
                                   (4) Old IMSIZE(2)
                                   (5) Old ROTATE
                                   (6) Edge pixels to be avoided
                                   (7) Scale box size factor
----------------------------------------------------------------
FIXBX
Type:  Task
Use:   FIXBX fixes the problem caused by wanting to change the size of
       imaging facets or their cell sizes or centers while retaining
       the information on Clean boxes generated with the current
       faceting.

       Two input box files are used.  The first (INFILE) defines the
       old facet centers and previous Clean boxes.  NMAPS and NGAUSS
       define the number of facets per Gaussian width and the number
       of such widths in the old imaging.  INFILE may be supplemented
       with values stored in adverbs NBOXES, CLBOX, NOISE, and PBSIZE.
       The second input (BOXFILE) defines the new facet centers and
       field sizes.  Any Clean boxes defined in BOXFILE are ignored.
       It may be supplemented by adverbs NFIELD, RASHIFT, and
       DECSHIFT.  It is wise to specify NMAPS, NGAUSS, and NFIELD in
       many cases.

       An output box file is written.  It will contain any facet
       information found in BOXFILE plus the new Clean boxes taken
       from INFILE and CLBOX.  If an output facet has no Clean box, a
       default inscribed circle box will be added.
Input adverbs:
  INNAME.....The UV dataset name (name).    Standard defaults.
  INCLASS....The UV dataset name (class).   Standard defaults.
  INSEQ......The UV dataset name (seq. #).  0 => highest.
  INDISK.....The disk drive #.         0 => any.
  SOURCES....The source to be used from a multi-source file; a single
             source name is required to get the central pointing
             position from the source table.  Ignored for single-source
             files.
  INFILE.....The box-file previously used with IMAGR containing lines
             which specify the fields used for imaging and other
             lines giving the Clean boxes used in that imaging.
             ' ' => all information contained in NBOXES, CLBOX,
             NMAPS, NOISE, and PBSIZE.
  NMAPS......The old number of fields to map in the antenna beam.
             Note that only 64 fields may be described in adverbs, but
             4096 are allowed.  If NMAPS is zero, then INFILE is used
             to define the number of facets and the number of
             Gaussians is taken to be 1.
  NGAUSS.....Number of Gaussians in the old and new imaging.  0 -> 1.
  NOISE......Old RA shift of the phase center of each field from the
             tangent point of the uv data in asec.  Map center =
             tangent point + shift. If X>0 shifts map center to east.
             NOTE: RASHIFT is a shift in RA scaled by cos (Dec_0) as
                 Ra_new(i) = RA_0 + RASHIFT(i) / cos (Dec_0)
             where _0 => the tangent point in the uv data.  This is a
             change for 15OCT99 from shifts in -SIN projection (which
             do not work for -NCP data and large angles).  If the UV
             data have been rotated then RASHIFT and DECSHIFT refer
             to X and Y in the new coordinate system.
             NMAPS values of NOISE will be used as initial values
             before INFILE is read - field centers in the file will
             override the NOISE values.
  PBSIZE.....Old declination shift of map center from tangent point of
             each field in asec.  Map center = tangent point + shift.
             If Y>0 shifts map center to north.
             NMAPS values of PBSIZE will be used as initial values
             before BOXFILE is read - field centers in the file will
             override the PBSIZE values.
  NBOXES.....Number (<=50) of rectangular search boxes to search on the
             first field; the Clean windows in all other fields are
             given in INFILE.  If any boxes for field 1 appear in
             INFILE, NBOXES and CLBOX are ignored.
  CLBOX......A 4x50 array with the parameters of each box.
             0 => use window specified in FLDSIZE.
             CLBOX(1,i)=-1 indicates a circle of radius CLBOX(2,i)
                pixels centered on (CLBOX(3,i), CLBOX(4,i)).
             CLBOX(1,i) >= 0 indicates a rectangular box.
  BOXFILE....Input text file containing lines which specify the
             fields for the multi-field imaging in a changed scheme.
             Any Clean boxes in BOXFILE will be discarded.  The Clean
             boxes from INFILE will be added to OBOXFILE after
             translation where possible.  No default.  ' ' =>
             information given by NFIELD, RASHIFT, and DECSHIFT.
  NFIELD.....The new number of fields to map in the antenna beam. Up
             to 4096 are allowed.  If NFIELD=0, the maximum facet
             number found in the field and Clean box lines in BOXFILE
             will be used.  Note that NGAUSS Gaussian widths are also
             assumed.
  RASHIFT....New RA shift of the phase center of each field from the
             tangent point of the uv data in asec.  Map center =
             tangent point + shift. If X>0 shifts map center to east.
             NOTE: RASHIFT is a shift in RA scaled by cos (Dec_0) as
                 Ra_new(i) = RA_0 + RASHIFT(i) / cos (Dec_0)
             where _0 => the tangent point in the uv data.  This is a
             change for 15OCT99 from shifts in -SIN projection (which
             do not work for -NCP data and large angles).  If the UV
             data have been rotated then RASHIFT and DECSHIFT refer
             to X and Y in the new coordinate system.
             NFIELD values of RASHIFT will be used as initial values
             before BOXFILE is read - field centers in the file will
             override the RASHIFT values.
  DECSHIFT...New declination shift of map center from tangent point of
             each field in asec.  Map center = tangent point + shift.
             If Y>0 shifts map center to north.
             NFIELD values of DECSHIFT will be used as initial values
             before BOXFILE is read - field centers in the file will
             override the DECSHIFT values.
  OBOXFILE...Output text file containing lines copied from BOXFILE
             which specify the fields for the multi-field imaging in
             a changed scheme.  The Clean boxes from INFILE will be
             added to OBOXFILE after translation where possible.
             This file should then be specified as the new BOXFILE
             for IMAGR.  No default and the file must not pre-exist.
  CELLSIZE...New pixel size for the fields in IMAGR in arc seconds.
             No default.
  IMSIZE.....New size of each field.  No default.
  ROTATE.....New rotation to be used (degrees CCW).
  BPARM......(1) The value of CELLSIZE(1) used previously.
                  Default = CELLSIZE(1).
             (2) The value of CELLSIZE(2) used previously.
                  Default = CELLSIZE(2).
             (3) The value of IMSIZE(1) used previously.
                  Default = IMSIZE(1).
             (4) The value of IMSIZE(2) used previously.
                  Default = IMSIZE(2).
             (5) The value of ROTATE used previously.
                  No default
             (6) The number of pixels to be omitted from any Clean
                  box at the edges of fields.  0 -> 3.
             (7) Scale the size of the Clean boxes by BPARM(7). 0->1
----------------------------------------------------------------
