.ec _
.ll 80
.ad b
.in 4
.ti -4
1 Language
  CLEAN_\ Language Summary

  The CLEAN_\ Language contains commands related to UV data handling, UV to DataCubes conversion and DataCube processing.
  
.nf
ALMA          : Joint deconvolution of ALMA and ACA dirty images
BUFFERS       : List and Display the known buffer status
CCT__CLEAN     : Compute CLEAN image from Clean Component Table, without residuals
CCT__CONVERT   : Convert an image into a Clean Component Table
CCT__MERGE     : Merge two Clean Component Tables
CLEAN         : Deconvolve a dirty image using the current METHOD
.! COLOR         : Control the color LUT to highlight the Zero level
DISCARD       : Discard one of the active data buffers
DUMP          : Dump the control parameters of the deconvolution algorithms
FIT           : Fit the dirty beam
LOG           : LOG "command argument" B|F|S
.! INSPECT__3D    : Visualize datacube by cuts along 3 main directions
MAP__CONVOLVE  : Spatially Smooth a data Cube 
MAP__COMBINE   : Combine two data Cubes
MAP__COMPRESS  : Average a Cube by several channels 
MAP__INTEGRATE : Compute a Moment 0 Map
MAP__REPROJECT : Spatial resampling of a Cube
MAP__RESAMPLE  : Resample a Cube on a different Velocity/Frequency scale
MAP__SMOOTH    : Smooth by N channels
MOSAIC        : Change the mosaic processing mode
MX            : Iteratively image and deconvolve a dirty image
PRIMARY       : Apply primary beam correction
READ          : Read the input files in internal buffers
.! SHOW          : Display (in a plot) some internal buffer result
SPECIFY       : Change Frequency / Velocity /Unit scale or the Telescope
SUPPORT       : Define the support used to search clean components
UV__BASELINE   : Subtract a continuum baseline from a Line UV data
UV__CHECK      : Check UV data for null visibilities or per channel flags.
UV__COMPRESS   : Compress a Line UV data into another Line UV data
UV__CONTINUUM  : Compress a Line UV data into a Continuum UV data
UV__EXTRACT    : Extract a range from
UV__FILTER     : Filter out (line) channels
UV__FLAG       : Interactively flag UV data
UV__MAP        : Build the dirty image and beam from a UV table
UV__RESAMPLE   : Resample (in Velocity) the UV data
UV__RESIDUAL   : Subtract Clean Component from the UV Data
UV__RESTORE    : Restore a Clean image from UV data and Clean Components
UV__REWEIGHT   : Evaluate UV weights from visibility statistics
UV__SHIFT      : Shift a UV table to common phase center
UV__SMOOTH     : Smooth spectrally a Line UV data
UV__SPLIT      : Split a UV table into Line and Continuum
UV__STAT       : Gives beam sizes and noise properties as a function of
                 tapering or robust weighting parameter
UV__SUBTRACT   : Subtract Continuum visibilities from Line UV data
UV__TIME       : Time average the current UV data
.! UV__TRACKS     : Simulate a UV coverage 
UV__TRIM       : Suppress useless information from UV data
UV__TRUNCATE   : Truncate the baseline range of the UV data
.! VIEW          : Show (in a GO VIEW-like plot) some internal buffer result
WRITE         : Save internal buffers or Image variables onto output files
.fi

.ti -4
1 ALMA
.ti +4
[CLEAN_\]ALMA [FirstPlane [LastPlane]] [/PLOT Clean|Residu] [/FLUX [Fmin Fmax]] [/QUERY] [/NOISE] [/METHOD]

Joint deconvolution methods specific to ALMA+ACA observations.

This method is deprecated.

.ti -4
1 BUFFERS
.ti +4
[CLEAN_\]BUFFERS

List the status (current sizes) of known "Buffers".  

A "Buffer" is an internal memory structure that is also accessible
as a SIC variable of the same name (of type Image, Table, UV Table,
or Array depending on its properties).

Active buffers can be nullified by using the DISCARD command.
Buffers can be written by command WRITE, and READ by command READ.

.ti -4
2 AGAINS 
.ti +4

  AGAINS is a buffer containing the results of a self-calibration
with command SELFCAL. It is a special table in the following format.
Each line contains a different time stamp. Column 1 is the Time
(in seconds), Col 2 the Date (in Days, with an arbitrary origin),
Col 3 the number of antennas, Col 4 the antenna reference number,
and then, for each antennas i, Cols (2+3*i:2+3*i) contains the
Amplitude correction factor, the Phase correction (in degree), and
the Signal-to-noise of the correction.

.ti -4
2 BEAM
.ti +4
  BEAM is a 2,3 or 4-D image buffer containing the synthesized beam
computed by UV__MAP (or by READ BEAM).
        
.ti -4 
2 CCT
. ti +4
  CCT is a special 3-D array containing the Clean Component Table.
The first dimension contains (x,y,f), the flux (in Jy) at offset
x,y (in radians). The second dimension handles the number of channels.
The last dimension handles the Clean iteration number. 

.ti -4
2 CGAINS
.ti +4
 
 CGAINS is a pseudo-UV table containing the complex gain correction
 resulting from a SELFCAL command (or read by READ CGAINS). It is
 analogous to a single-channel UV table, but interpreted by IMAGER
 as gain corrections to apply to the UV data by command APPLY.
 
.ti -4
2 CLEAN
.ti +4
  CLEAN is the deconvolved 2 or 3-D image produced by UV__MAP
(or read by READ CLEAN).  It is not corrected for primary 
beam attenuation.
  
  For Mosaics, command CLEAN produces a SKY brightness map, corrected
 from primary beam attenuations.

.ti -4
2 CLIPPED
.ti +4
  CLIPPED is a 2-D table containing the Clipped spectra produced
by command UV__PREVIEW. Col 1 contains the Velocity, Cols 2:N+1
the spectra for the N tapers used in UV__PREVIEW, Col N+2 
the natural weights.

.ti -4
2 CONTINUUM
.ti +4
  CONTINUUM contains the "continuum" image. It can be obtained
in 3 ways
.nf
  1) READ CONTINUUM  FileName.Type  (provided this a 2-D image)
  2) from command MAP__CONTINUUM  
  3) from command UV__MAP /CONTINUUM followed by command CLEAN.
.fi

.ti -4  
2 DIRTY
.ti +4
  DIRTY contains the dirty image produced by UV__MAP. Its interpretation
is different for a Single field than for a Mosaic.

.ti -4
2 EXTRACTED
.ti +4
  EXTRACTED   contains the 3-D data cube produced by command EXTRACT

.ti -4
2 FIELDS
.ti +4
  FIELDS is an intermediate buffer created by SHOW PRIMARY. It
is a transposed version of the PRIMARY buffer, in order (l,m,f) where
f is the field number.
  
  Note: there is a confusion with the FIELDS structure created
by READ UV on Mosaic UV tables.

.ti -4
2 MASK 
.ti +4
  MASK contains the Mask computed by command MASK (or read by READ MASK).
It may be used (or not) for CLEAN, depending on the selected type
of Support (see SUPPORT /MASK and MASK USE commands).        

.ti -4
2 M__AREA   
.ti +4
    M__AREA is a 2-D image containing the integrated area
computed by command MOMENTS   (CASA 0-th moment)
    
.ti -4
2 M__PEAK   
.ti +4
    M__PEAK is a 2-D image containing the peak flux 
computed by command MOMENTS   (CASA 8-th moment)
    
.ti -4
2 M__VELO   
.ti +4
    M__VELO is a 2-D image containing the mean velocity 
computed by command MOMENTS. Its value depends on the method
used in command MOMENTS: it can be the 1-st moment, or a fit
of the peak velocity.    
    
.ti -4
2 M__WIDTH   
.ti +4
    M__WIDTH is a 2-D image containing the velocity dispersion
computed by command MOMENTS. It is equivalent to the Full Width
at Half Maximum is the line shape is Gaussian.
    
.ti -4
2 PRIMARY
.ti +4
  PRIMARY is the primary beam, computed by command PRIMARY or
read by command READ PRIMARY. It may be 2-D (for single fields)
or 3-D (for Mosaics). It the later case, it is in the order
(f,l,m) where f is the field number. 

.ti -4
2 RESIDUAL
.ti +4
  RESIDUAL is the image of the residuals from the Clean deconvolution.

.ti -4
2 SHORT
.ti +4
  SHORT is the Short-Spacing image, computed by commands UV__SHORT
or XY__SHORT, or read by command READ SINGLE.

.ti -4 
2 SINGLE
.ti +4
  SINGLE is the Single-Dish data read by command READ SINGLE.
It may be a Class-table or a 3-D data cube.

.ti -4
2 SKY
.ti +4
  SKY is a 3-D image buffer containing the current estimate of the 
Sky brightness distribution. It is provided by command PRIMARY from 
the CLEAN and PRIMARY buffers for single-field data, but by command 
CLEAN for Mosaics.  Noise is not uniform in SKY image.

.ti -4
2 SLICED
.ti +4
  SLICED is 2-D buffer produced by the SLICE command.

.ti -4
2 SPECTRUM 
.ti +4
  SPECTRUM is a 2-D table containing the  spectra produced
by command UV__PREVIEW. Col 1 contains the Velocity, Cols 2:N+1
the spectra for the N tapers used in UV__PREVIEW, Col N+2 

.ti -4
2 UV__DATA
.ti +4
  UV__DATA (or UV in short) is the current UV data.
It is initially set by command READ UV,
but modified by many UV__like commands (resampling, calibration, etc...)

.ti -4
2 UV__FIT
.ti +4
  UV__FIT handles the results of the UV__FIT command. It is a
special format 2-D table. See HELP UV__FIT for details.

.ti -4
2 UVCONT
.ti +4
  UVCONT handles the intermediate (pseudo-)UV table created and used
by command UV__MAP /CONT for Multi-Frequency-Synthesis. It is a valid
2-D UV table, but which have more than 1 visibility for the same time
and baseline pair, with different (frequency-scaled) (u,v) coordinates.
Such UV tables can be properly imaged, but not properly self-calibrated.

.ti -4
2 UVRADIAL
.ti +4
  UVRADIAL  handles an azimutally averaged version of the UV data. It
is produced by command UV__RADIAL.

.ti -4
2 UV__RESIDUAL
.ti +4
  UV__RESIDUAL handles the residuals of UV__FIT. As UV__DATA and UV__MODEL,
it can be selected for further imaging by command UV__SELECT.

.ti -4
2 WEIGHT
.ti +4
  WEIGHT is the equivalent of PRIMARY for Mosaics. It is a 2 or 3-D 
image buffer containing the relative response given by all pointings 
of the Mosaic coverage.

.ti -4
1 CCT__CLEAN
.ti +4
  [CLEAN_\]CCT__CLEAN [Niter]
  
  Convert the CCT Clean Component Table into the CLEAN image. The
residuals are not added at this stage, contrary to what is done by
the CLEAN command.

 Niter is the last iteration to be retained (to be implemented). If
 not present, all components are considered. 

.ti -4
1 CCT__CONVERT
.ti +4
  [CLEAN_\]CCT__CONVERT [Threshold]
  
  Convert the CLEAN image into the CCT Clean Component Table.
  
  Threshold is the minimum (absolute value of) flux per pixel 
retained. Default is 0

.ti -4
1 CCT__MERGE
.ti +4
  [CLEAN_\]CCT__MERGE Out In1 In2


  Combine two input Clean Component Tables.
  
  Out can be a file name or an existing Image variable. 
The distinction is made by the existence of a "." in the name
          If it is a file, it is created like the In1 Variable
          If it is an Image variable, it must match the number
        of channels of the In1 Variable, and
          be large enough to handle the total number of components.
          
  In1 and In2 can be file names or existing Image variables.
They must match in terms of number of channels.
  
.ti -4
1 CLEAN
.ti +4
[CLEAN_\]CLEAN [FirstPlane [LastPlane]] [/RESTART [File]][/PLOT Clean|Residu] 
  [/FLUX [Fmin Fmax]] [/QUERY] [/NITER NiterList] [/ARES AresList]

Deconvolve a Mosaic or Single-field using the current METHOD (in SIC variable METHOD).
See INPUT CLEAN for the other SIC variables controlling the deconvolution process.
Supported methods are CLARK, GAUSS, HOGBOM, MRC, MULTISCALE and SDI. Use
HELP CLEAN Method and/or HELP CLEAN METHODNAME for further details 
on each algorithm. 

Clean the specified plane interval (default: planes between variables FIRST
and LAST). If only FirstPlane is specified, Clean only that plane.
This command allows a per-plane definition of the convergence criteria 
CLEAN__NITER and CLEAN__ARES.

.so imager-help-clean-input.nroff-so

.ti -4
2 /FLUX
.ti +4
[CLEAN_\]CLEAN [FirstPlane [LastPlane]] /FLUX [Fmin Fmax] [/PLOT Clean|Residu] [/QUERY] [/NITER NiterList] [/ARES AresList]

Display the cumulative Clean flux as Clean progresses. Fmin and Fmax are
Min and Max flux in the display. If not present, an automatic dynamic scaling is used.

This option is inactive in Parallel mode.

.ti -4
2 /PLOT
.ti +4
[CLEAN_\]CLEAN [FirstPlane [LastPlane]] /PLOT Clean|Residu [/FLUX Fmin Fmax] [/QUERY] [/NITER NiterList] [/ARES AresList]

Display the iterated Clean or Residual image for Cleaning methods which have
major cycles (CLARK or SDI). This option is inactive in Parallel mode.

.ti -4
2 /QUERY
.ti +4
[CLEAN_\]CLEAN [FirstPlane [LastPlane]] /PLOT Clean|Residu /QUERY [/FLUX Fmin Fmax] [/NITER NiterList] [/ARES AresList]

*** Obsolescent ***

Prompt for continuation when a Major cycle is complete. This option is inactive in Parallel mode. 

As a replacement of this facility, we suggest you to fragment your CLEAN in several steps, using the /RESTART option 
and the VIEW CLEAN (or RESIDUAl) command after each step.

.ti -4
2 /NITER
.ti +4

[CLEAN_\]CLEAN [FirstPlane [LastPlane]] /NITER NiterList [/PLOT Clean|Residu] [/FLUX Fmin Fmax] [/QUERY] [/ARES AresList]

Use a per-plane value for the number of iterations, instead of the
global NITER variable.  NiterList should be a 1-D integer array
of dimension the number of channels.

This option is only available through the CLEAN command, not through
the specific command of each method.

.ti -4
2 /ARES
.ti +4

[CLEAN_\]CLEAN [FirstPlane [LastPlane]] /ARES AresList [/PLOT Clean|Residu] [/FLUX Fmin Fmax] [/QUERY] [/NITER NiterList] 

Use a per-plane value for the absolute residual used to stop
cleaning,  instead of the
global ARES variable.  AresList should be a 1-D real  array
of dimension the number of channels.


.ti -4 
2 /RESTART
.ti +4

[CLEAN_\]CLEAN [FirstPlane [LastPlane]] /RESTART [File] [/PLOT Clean|Residu] 
  [/FLUX Fmin Fmax] [/QUERY] [/NITER NiterList] [/ARES AresList]

Instruct CLEAN to start from the specified Clean Component Table stored in the specified File, 
or those currently in memory if no File is given.

This can be used to re-start a Clean that was not deep enough. It can be used to split the Clean
operation in several steps, possibly changing the support at each step, or even the Clean METHOD.

For spectral data, the starting model should have the same number of channels, or have only 1.
The later capability can be used to start from the Clean Components derived from a Continuum-only 
data set, so that deconvolution proceeds to find out the line-only structure. This is an alternative
to separate deconvolution of Continuum and continuum-subtracted data followed by addition of the
Clean images.

.ti -4
2 Methods:
.nf
  CLARK       A minor/major cycle cleaning using FFTs for speed
              Fast, but less stable than others.
  HOGBOM      The basic deconvolution method, working component per 
              component. Very robust, but possibly Slower than CLARK
  GAUSS       A multi-resolution Clean method using point sources and
              Gaussian sources of different sizes. Slower than HOGBOM,
              but better at recovering all scales. 
  MRC         A dual-scale multi-resolution Clean working on a smooth
              and a difference map. Fast, but with no notions of Clean
              component.
  MULTISCALE  A 3-scales multi-resolution-Clean working on 3 smoothed
              versions of the map. Slow, but very stable and adapted to
              sources with extended structures. GAUSS is faster.
  SDI         A major-cycle only method. Good for extended structures
              but not very performant overall. 
.fi
.ti -4
2 CLARK
.ti +4
  CLEAN [FirstPlane [LastPlane]] [/PLOT Clean|Residu] [/FLUX [Fmin Fmax]] [/QUERY]

with METHOD = CLARK

A Major-Minor cycles CLEAN method, originally developed by B.Clark, in
which clean components are selected using a limited beam patch, and
deconvolved through Fourier transform at each major cycle. In mosaic mode
(See command MOSAIC), a mosaic clean is performed. Rings and/or stripes may
appear on extended sources.  Faster than the HOGBOM method for single
fields but maybe slower for mosaics. The strategy to search for CLEAN
components in CLARK method does not work properly when the secondary side lobes
are too large (say larger than 0.3), or in case of high phase noise.

.ti -4
2 HOGBOM
.ti +4
  CLEAN [FirstPlane [LastPlane]] [/FLUX [Fmin Fmax]] [/RESTART [File]]

with METHOD = CLEAN

The simplest CLEAN algorithm, originally developed by Hogbom. In mosaic
mode (See command MOSAIC), a mosaic clean is performed.  Rings and or
stripes may appear on extended sources. It is slower than CLARK for a single
field but maybe faster for a mosaic. It is extremely robust.  Cleaning can
be interrupted by pressing <Control>C at any time.

.ti -4
2 GAUSS
.ti +4
  CLEAN [Gauss1 ... GaussN] [/FLUX [Fmin Fmax]] [/RESTART [File]]

with METHOD = GAUSS 

A multi-scale resolution CLEAN using Gaussian decomposition. 
Gauss1 to GaussN indicate the size of the Gaussian in arcseconds.
Point sources are also considered by default (so without argument, it
is equivalent to HOGBOM).

It works also for Mosaics, but the result at edges may differ from
those of HOGBOM or CLARK because of the Gaussian clean components
are not truncated as Dirac functions.

.ti -4
2 MRC
.ti +4
CLEAN [FirstPlane [LastPlane]] [/PLOT Clean|Residu] [/FLUX [Fmin Fmax]] [/QUERY] 

with Method = MRC

Perform a Multi-Resolution CLEAN on the current dirty image.  MRC does not
support mosaics for theoretical reasons.

If option /PLOT is given, a display of the CLEAN or RESIDUAL map
will be shown at each major cycle, depending on the argument (default:
Residual). The user will be prompted for continuation when the /QUERY
option is present. The cumulative, already cleaned flux is displayed in
real time in an additional window while cleaning goes on when the /FLUX
option is present. Parameters of the /FLUX option are then used to give the
flux limits for this display. A summary plot with the Difference, Smooth,
and total CLEANed maps is also displayed.


.ti -4
2 MULTI
.ti +4
CLEAN [FirstPlane [LastPlane]] [/FLUX [Fmin Fmax]] [/RESTART [File]]

with METHOD = MULTI

Perform a 3-scales Hogbom-like deconvolution. A each minor cycle, the
the scale with the highest signal to noise is used to define the
Clean Components to retain. The algorithm is thus very stable.
 
The cumulative, already  cleaned flux is displayed in real time
in an additional window while cleaning goes on when the /FLUX option is
present. Parameters of the /FLUX option are then used to give the flux
limits for this display.

MULTI also works on mosaics.  The smoothing ratio can be controlled
by variable CLEAN__SMOOTH.

.ti -4
2 SDI
.ti +4
CLEAN [FirstPlane [LastPlane]] [/PLOT Clean|Residu] [/FLUX [Fmin Fmax]] [/QUERY] [/RESTART [File]]

with METHOD = SDI

Perform a Steer-Dewdney-Ito CLEAN. This clean method selects an ensemble of
clean components and remove them at once using FFTs.  It works best for
extended sources and UV coverages with short spacings. In such a case, it
may avoid the "ringing" features which appear using the CLARK or HOGBOM
techniques. In mosaic mode (see command MOSAIC), a mosaic clean is
performed.

SDI is very sensitive to the selected support (see MASK and SUPPORT commands),
especially when the dirty beam sidelobes are significant.

.ti -4
2 Variables:
.ti +4
.so imager-help-clean-clean-list.nroff-so

.so imager-help-clean-clean-desc.nroff-so

.ti -4
1 DISCARD
.ti +4
[CLEAN_\]DISCARD [BufferName1 [BufferName2 ...]]]

Discard (i.e. remove from the memory and the list of known variables) 
the specified buffer(s).  Only the most important buffers can be discarded.
This may be needed in Memory hungry situations.

DISCARD * 
.br 
will discard all image-like buffers:
.br
  BEAM,  CCT,  CLEAN,  CONTINUUM,  DIRTY,  MASK,   PRIMARY,   
.br 
  RESIDUAL,  SHORT,  SINGLEDISH,  SKY
  
DISCARD UV*
.br
will discard all UV-like buffers
.br
  UV,  UVCONT,   UVSELF,   UV__MODEL

.ti -4
1 DUMP
.ti +4
[CLEAN_\]DUMP [Key]

Dump on screen the control parameters of the different CLEAN deconvolution
algorithms, mainly for debugging purpose. 
.nf
  DUMP BUFFERS  will trace UV data buffer association
  DUMP MEMORY   will give the memory usage. Swapped out memory may not be 
                accounted in this action.
  DUMP METHOD   list the CLEAN method internal values
  DUMP THREADS  give the number of threads used
  DUMP USER     list the User-specified values for CLEAN method
.fi


.ti -4
1 FIT
.ti +4
[CLEAN_\]FIT [Plane] | [CHANNEL First Last] [FIELD First Last] 
  [/THRESHOLD Value] [/JVM__FACTOR [NoCircle]] 

Fit the dirty beam to obtain the clean beam parameters.  

For single fields, the Plane argument can be used to fit just one of the possible
Frequency dependent beam planes. Note that the number of beam planes can
be different from that of image channels.

For mosaics, dirty beams can be up to 4-D, depending on Frequency and Field number.
Keywords CHANNEL (or equivalently PLANE) and FIELD allow to restrict the fit 
to the specified range of Channels or Field numbers. All ranges are considered

Note that an automatic FIT is performed by all CLEAN algorithms when needed. 
The appropriate Frequency plane corresponding to each image channel is used.
For mosaics, CLEAN takes the average of the fitted beam parameters on all fields.

User specified values can be used instead (see HELP FIT FixedValues).


.ti -4
2 FixedValues 
.ti +4 

Clean beam parameters can also be specified by the users, by loading the BEAM__SIZE array with values other than its 
default values (0,0,0). In this case, no automatic fit will be performed. 

In general, we discourage this usage, as it may result in a very improper flux
scaling if the beam size is inappropriate. This mode should be reserved
to special cases where the beam cannot be properly fitted, or to
have a circular beam by taking as beam size the geometrical mean
of the fitted major and minor sizes.

Fixing the beam size should be associated to the FIT /JVM command to minimize 
(but not suppress !...) errors in total flux scaling. 


.ti -4
2 Results
.ti +4

Beam parameters are returned in the BEAM__FITTED array which is
analogous to the BEAM__SIZE one (Major axis, Minor axis in arcsec,
and Position angle, in degrees East from North), and in
the BEAM__JVM variable, that contains the scaling factor of
the residuals.


.ti -4 
2 /JVM__FACTOR
.ti +4
[CLEAN_\]FIT [Plane] | [CHANNEL First Last] [FIELD First Last] 
  [/THRESHOLD Value] /JVM__FACTOR [NoCircle] 

This option instructs the FIT command to estimate the so-called
JvM factor (from Jorsater and van Moorsel 1995), which is the
ratio of Clean beam area to Dirty beam area.  The value is
returned into the BEAM__JVM variable.

The Dirty beam area is an ill-defined quantity (if no Zero spacing
is included, the Dirty beam area tends toward Zero when a sufficiently
large area is included). It is defined here by integrating only
up to the first null of the Dirty beam.

In case of Dirty beams presenting shoulders around the main beam, 
this ratio may be used to adjust the contribution of residuals to 
the CLEAN image so that the flux is better preserved.
For well-behaved beams, it should be quite close to 1.

NoCircle is an argument which, if present, indicates that the
Clean and Dirty beam should not be circularized to derive the factor;
this should be reserved for debugging.



.ti -4
2 /THRESHOLD
.ti +4
[CLEAN_\]FIT /THRESHOLD Value [/JVM__FACTOR]

Use Value instead of CLEAN__SIDELOBE to fit only regions of the beam
above Value by a Gaussian.  Gaussian fit may give different sizes
for significantly non-Gaussian beams.

.ti -4 
2 BEAM__SIZE

BEAM__SIZE is a Real array of size 3 containing the user-specified values
for the Clean beam size, with BEAM__SIZE[1] the Major axis, BEAM__SIZE[2] the
Minor axis (both in arcsec) and BEAM__SIZE[3] the Position angle (in degrees, North towards East).

If BEAM__SIZE[1] and BEAM__SIZE[2] are 0, the CLEAN or FIT commands will determine 
the Clean beam size (available in variable BEAM__FITTED similar
to BEAM__SIZE) by adjusting the dirty beam main peak.

If only one of BEAM__SIZE[1] and BEAM__SIZE[2] is non zero, it will be
used as the Clean beam size for a circular beam.

If both are non zero, BEAM__SIZE totally specifies the Clean beam size.
BEAM__FITTED is thus set to the BEAM__SIZE values when used.

.ti -4 
2 CLEAN__SIDELOBE 

Minimal relative intensity to consider for fitting the syntheized
beam to obtain the Clean beam parameters (BEAM__SIZE variable) 
when 0.  The default is 0.30.

In case of poor UV coverage, CLEAN__SIDELOBE should be higher than the
maximum sidelobe level to perform a good Gaussian fit. Some particularly
bad UV coverage may not allow any good fit at all, however.



.ti -4
1 LOG
.ti +4
[CLEAN_\]LOG "Command Argums... /Option..." B|F|S

Insert the corresponding command with its arguments and options into
the LogFile (F key), the Stack (S key) or both (B key).

This command is used by some scripts that require interactive input
from the users, so that the Stack can replay the same actions
(e.g. MASK)

.ti -4 
1 MAP__CONVOLVE
.ti +4
[CLEAN_\]MAP__CONVOLVE  OutCube InCube METHOD [Parameters ...]

Spatially smooth a data cube using the specified METHOD.

InCube is an existing 2-D or 3-D data file or SIC Variable.
OutCube is data filename or SIC Variable. If OutCube is a 
filename, the file is created. If OutCube is
an existing SIC Variable, it must match the InCube sizes.
If OutCube is a non-existing SIC variable name, it is automatically
created with the proper sizes.

Available methods are GAUSS, KERNEL or NOISE. See further
subtopics for details.

.ti -4
2 GAUSS
.ti +4
[CLEAN_\]MAP__CONVOLVE OutCube InCube GAUSS Major [Minor [PA]]

Spatially smooth a data cube by the specified Gaussian OR
to reach a given (circular) resolution.  Major and Minor
must be in the same units as that of the input cube axes
(i.e. Radians for astronomical images). Smoothing is performed
by an FFT-based convolution. 

If only Major is given, and the input cube has a specified
spatial resolution, MAP__CONVOLVE will attempt to provide
a new spatial resolution of size Major. This requires that
the initial major axis is smaller than Major. 

In other cases, the input cube is smoothed by specified
Gaussian. 


.ti -4
2 BOX
.ti +4
[CLEAN_\]MAP__CONVOLVE OutCube InCube BOX 

Spatially smooth a data cube by a uniform ("box")
5x5 pixels kernel.


.ti -4
2 HANNING
.ti +4
[CLEAN_\]MAP__CONVOLVE OutCube InCube HANNING 

Spatially smooth a data cube by a pseudo-Hanning kernel. The Kernel has weights 3 
(central pixel), 2 (adjacent cross pixels) and 1 (others). 


.ti -4
2 KGAUSS
.ti +4
[CLEAN_\]MAP__CONVOLVE OutCube InCube KGAUSS Gauss

Spatially smooth a data cube by a (small) Gaussian.
Smoothing is performed using a 5x5 Kernel sampling 
the Gaussian, which must thus be small in size.

.ti -4
2 NOISE
.ti +4
[CLEAN_\]MAP__CONVOLVE OutCube InCube NOISE Threshold Radius


Smoothes  an  input  image  using the noise cheating enhancement method.
The method only makes sense to search for positive signals.

Values  for  adjacent  pixels are summed until a given total (specified by 
Threshold) is reached. Then, the total is divided by the number of pixels added 
and the result is used for  the output pixel value.  

This smoothing is very non linear and spatially variable: in particular no
smoothing occur on pixels stronger than the smoothing threshold.  
Parameter RADIUS (in pixels) allows to restrict the averaging to 
nearby pixels only, rather than the whole image.


.ti -4
2 USER 
.ti +4
[CLEAN_\]MAP__CONVOLVE OutCube InCube USER s0 s10 s11 s20 s21 s22

Spatially convolve a data cube by a user specified
symmetric 5x5 kernel. The kernel is defined by
its 6 coefficients:
.nf
      S22 S21 S20 S21 S22
      S21 S11 S10 S11 S21
      S20 S10 S00 S10 S20
      S21 S11 S10 S11 S21
      S22 S21 S20 S21 S22
.fi
Negative kernel values can be used to enhance fine gradients.

.ti -4
2 Resolution
.ti +4
  Most MAP__CONVOLVE methods do not result in a well-defined angular
resolution. The only exception if for the GAUSS method applied to
data with an existing beam, and with a minor axis argument that is larger
than the existing beamsize.. In this case GAUSS will smooth the
data to the specified (isotropic) angular resolution. 

.ti -4
2 Units
.ti +4
  MAP__CONVOLVE applies a spatial smoothing of the data. It thus
usually makes sense only for brightness-like quantities, such as Jy/pixel
or brightness temperature in K. 

  Accordingly, when the GAUSS method results in a well-defined angular 
resolution, the brightness unit Jy/beam is rescaled to the appropriate 
beam size. In all other cases, the Jy/beam unit is converted to Jy/pixel
to conserve flux.

  For all other units, it is up to the user to properly interpret the
smoothing effect.



.ti -4
1 MAP__COMBINE
.ti +4
[CLEAN_\]MAP__COMBINE OutCube CODE In1 In2 [Off] [/FACTOR A1 A2]
  [/THRESHOLD T1 T2] [/BLANKING Bval]

Combine in different ways two input images (or data cubes).
MAP__COMBINE does **NOT** request that the inputs have the same
angular resolution, neither the same unit. It is up to the user
to avoid combining inconsistent quantities !...

However, MAP__COMBINE attempts to handle input data in different 
units in a reasonably clever way, converting different brightness 
quantities into a single unit. Accordingly, depending on the requested 
operation CODE, MAP__COMBINE will return the results in different units. 
In practice, this is K for brightness (ADD), and no unit for Ratio (DIVIDE), 
Opacities (OPACITY) or Spectral Index (INDEX).

  MAP__COMBINE also supports an "intuitive" , more mathematical syntax,
.ti +4
  MAP__COMBINE OutCube = [A1*]In1 Oper [A2*]In2 [Off] 
  [/THRESHOLD T1 T2] [/BLANKING Bval]

where Oper can be any of the values allowed for CODE, or one of the 
4 standard operators, + - * | (the / would conflict with the option separator),
and scale factors are given in a natural way.  

CODE is the Operation Code: see HELP MAP__COMBINE CODE for details.
Off is an optional offset for the operation. 

OutCube can be a file name or an existing SIC Image variable. 
The distinction is made by the existence of a "." in the name.
If it is a file, it is created like the In1 Variable
If it is a SIC Image variable, it must exist and match the shape of In1. 
  
In1 can be a file name or an existing SIC Image variable.
    
In2 can be a file name or an existing Image variable.
The rank of In2 must be smaller than or equal to that of In1, and 
other dimensions must match.  

A1 and A2 are scale factors applied to In1 and In2 if needed (default
1).

T1 and T2 are thresholds below which no result is computed (default none).

.ti -4
2 CODE
.ti +4
[CLEAN_\]MAP__COMBINE OutCube CODE In1 In2 [Off] [/FACTOR A1 A2]
  [/THRESHOLD T1 T2] [/BLANKING Bval]

  CODE is the operation code. Allowed values are
.nf
ADD      or PLUS    OutCube = A1*In1 + A2*In2 + Off 
SUBTRACT or MINUS   OutCube = A1*In1 - A2*In2 + Off  
DIVIDE   or OVER    OutCube = A1*In1 / A2*In2 + Off    
MULTIPLY or TIMES   OutCube = A1*In1 * A2*In2 + Off    
OPACITY             OutCube = -Log( A1*In1 / A2*In2 + Off)  
INDEX               OutCube = Log( A1*In1 / A2*In2) / Log(Nu1/Nu2)  
.fi  
where Nu1 is the Frequency of In1, and Nu2 that of In2.
Off is 0 if not specified.
  
  With the "intuitive" mathematical syntax,
.ti +4
  MAP__COMBINE OutCube = [A1*]In1 Oper [A2*]In2 [Off] 

Oper can be any of the above values for CODE, or one of the 4 standard operators, +-/*,
and scale factors are given in a natural way, defaulting to 1 if not present. 
  
.ti -4 
2 UNITS

Depending on the requested operation, MAP__COMBINE will return the results
in different units.

.ti -4
2 /BLANKING
.ti +4
[CLEAN_\]MAP__COMBINE OutCube CODE In1 In2 [/FACTOR A1 A2]
  [/THRESHOLD T1 T2] /BLANKING Bval

Specify the Blanking value to be used in the OutCube. If not
specified, the Blanking from In1 is used instead, and
that of In2 if In1 has no Blanking.

.ti -4
2 /FACTOR 
.ti +4
[CLEAN_\]MAP__COMBINE OutCube CODE In1 In2 /FACTOR A1 A2
  [/THRESHOLD T1 T2] [/BLANKING Bval]

Specify the factors to apply to In1 and In2. Default is 1.0.
This option is not available in the "intuitive" math syntax, where
the factors are specified directly.

.ti -4
2 /THRESHOLD 
.ti +4
[CLEAN_\]MAP__COMBINE OutCube CODE In1 In2 [/FACTOR A1 A2]
  /THRESHOLD T1 T2] [/BLANKING Bval]

Specify the thresholds above which the computation is
valid for In1 and In2.  For pixels below this threshold,
the OutCube is blanked.

Default is no threshold (-huge(0.)).

.ti -4
1 MAP__COMPRESS
.ti +4
[CLEAN_\]MAP__COMPRESS WhichOne Nc [First TYPE] [Output]

Resample (in frequency/velocity) a data cuvbe by averaging NC adjacent channels. 

WhichOne indicates which data cube must be compressed. Allowed values are
.nf  
    - DIRTY, CLEAN or SKY
    - *, which means all of the previous existing ones
    - Any SIC Image Variable that is not a built-in buffer in IMAGER
    - An existing GILDAS data file
.fi
MAP__INTEGRATE only works on 3-D data cubes, replacing them by 
2-D images.

Output is a string indicating where the results will be placed.

.ti -4
2 Output
.ti +4
[CLEAN_\]MAP__COMPRESS WhichOne Nc [First TYPE] [Output]

Output is a string indicating where the results will be placed.
It can be
.nf
    - Any SIC Image Variable that is not a built-in buffer in IMAGER
      The variable must exist and be of adequate size.
    - A file name. The command will write the result as a GILDAS data file
      with this name.
.fi
The distinction between SIC Image Variable and Filenames is based
on the presence of a dot (".") or semi-colon (":") that indicate that
the string refers to a filename.

Output is compulsory unless WhichOne referes to one of the allowed
built-in buffer names (DIRTY, CLEAN or SKY) and forbidden if WhichOne
is *.  When Output is not present, the result are written in place on the
specified buffers.


.ti -4
1 MAP__INTEGRATE
.ti +4
[CLEAN_\]MAP__INTEGRATE WhichOne Min Max Type [Output]

Compute the integrated intensity map(s) over the specified
range from the specified data cube. Type can be VELOCITY
FREQUENCY or CHANNELS. 

WhichOne indicates which data cube must be compressed. Allowed values are
.nf  
    - DIRTY, CLEAN or SKY
    - *, which means all of the previous existing ones
    - Any SIC Image Variable that is not a built-in buffer in IMAGER
    - An existing GILDAS data file
.fi
MAP__INTEGRATE only works on 3-D data cubes, replacing them by 
2-D images.

Output is a name that indicates where the results will be placed,


.ti -4
2 Output
.ti +4
[CLEAN_\]MAP__INTEGRATE WhichOne Min Max Type [Output]

Output is a string indicating where the results will be placed.
It can be
.nf
    - Any SIC Image Variable that is not a built-in buffer in IMAGER
      The variable must exist and be of adequate size.
    - A file name. The command will write the result as a GILDAS data file
      with this name.
.fi
The distinction between SIC Image Variable and Filenames is based
on the presence of a dot (".") or semi-colon (":") that indicate that
the string refers to a filename.

Output is compulsory unless WhichOne referes to one of the allowed
built-in buffer names (DIRTY, CLEAN or SKY) and forbidden if WhichOne
is *.  When Output is not present, the result are written in place on the
specified buffers.

.ti -4
1 MAP__REPROJECT
.ti +4
[CLEAN_\]MAP__REPROJECT Output Input   
    [/BLANKING Bval Eval]    [/LIKE Template]
    [/PROJECTION Type Cx Cy [Angle]]
    [/SYSTEM Type [Equinox]]
    [/X__AXIS Nx Ref Val Inc]
    [/Y__AXIS Ny Ref Val Inc]

Resample spatially a Map or Cube according to the specified
projection (and coordinate system).  The characteristics of the
Output Cube can be controlled by the /LIKE option, or explicitely
by a combination of /PROJECTION, /SYSTEM, /X__AXIS, /Y__AXIS options.

Input can be a GILDAS data file, or a SIC image variable.
Output is a GILDAS data file that is created by the command.

.ti -4
2 /BLANKING
.ti +4
[CLEAN_\]MAP__REPROJECT Output Input   
    /BLANKING Bval Eval    [/LIKE Template]
    [/PROJECTION Type Cx Cy [Angle]]
    [/SYSTEM Type [Equinox]]
    [/X__AXIS Nx Ref Val Inc]
    [/Y__AXIS Ny Ref Val Inc]

Specify the desired Blanking value. If not present, this is
inherited from the Input, or the Template if specified.

.ti -4
2 /LIKE
.ti +4
[CLEAN_\]MAP__REPROJECT Output Input   
    /LIKE Template [/BLANKING Bval Eval]

Specify the shape and projection of the desired Output Cube
from a Template. Template is either a GILDAS data file, or
a SIC Header (or Image) variable.

The Blanking value, if not specified through /BLANKING,
will be inherited from the Template.

The /LIKE option is incompatible with the /PROJECTION, /SYSTEM,
/X__AXIS and /Y__AXIS options.

.ti -4
2 /PROJECTION 
.ti +4
[CLEAN_\]MAP__REPROJECT Output Input   
    [/BLANKING Bval Eval]    
    /PROJECTION Type Cx Cy [Angle]
    [/SYSTEM Type [Equinox]]
    [/X__AXIS Nx Ref Val Inc]
    [/Y__AXIS Ny Ref Val Inc]

Specify the desired Projection center. If Angle is not specified,
it is set to 0. Any argument with a value of * is left unchanged
from the Input Cube value.

This option is incompatible with the /LIKE option.

.ti -4
2 /SYSTEM 
.ti +4
[CLEAN_\]MAP__REPROJECT Output Input   
    [/BLANKING Bval Eval]    
    [/PROJECTION Type Cx Cy [Angle]]
    /SYSTEM Type [Equinox]
    [/X__AXIS Nx Ref Val Inc]
    [/Y__AXIS Ny Ref Val Inc]

Specify the desired coordinate System. Equinox default to 2000.0
for EQUATORIAL system if not specified.

This option is incompatible with the /LIKE option.

.ti -4
2 /X__AXIS 
.ti +4
[CLEAN_\]MAP__REPROJECT Output Input   
    [/BLANKING Bval Eval]    
    [/PROJECTION Type Cx Cy [Angle]]
    [/SYSTEM Type [Equinox]]
    /X__AXIS Nx Ref Val Inc
    [/Y__AXIS Ny Ref Val Inc]

Specify the desired X axis sampling. Any argument with a value of * 
is left unchanged from the Input Cube value.

This option is incompatible with the /LIKE option.

.ti -4
2 /Y__AXIS 
.ti +4
[CLEAN_\]MAP__REPROJECT Output Input   
    [/BLANKING Bval Eval]    
    [/PROJECTION Type Cx Cy [Angle]]
    [/SYSTEM Type [Equinox]]
    [/X__AXIS Nx Ref Val Inc]
    /Y__AXIS Ny Ref Val Inc]

Specify the desired Y axis sampling. Any argument with a value of * 
is left unchanged from the Input Cube value.

This option is incompatible with the /LIKE option.

.ti -4
1 MAP__RESAMPLE
.ti +4
[CLEAN_\]MAP__RESAMPLE WhichOne [Nc Ref Val Inc] [Result] [/LIKE Mold]

Resample 3-D data cubes on a different velocity scale.  
.nf
     Nc   new number of channels
     Ref  New reference pixel
     Val  New velocity at reference pixel
     Inc  Velocity increment
.fi
WhichOne indicates which data cube must be compressed. Allowed values are
.nf  
     - Built-in buffers DIRTY, CLEAN, SKY, SINGLE or *, which means all
       of the previous existing ones. Resampling is done in place.
     - Any SIC Image Variable that is not a built-in buffer in IMAGER.
     - A GILDAS data file
.fi
For the two later cases, the Result argument indicates where the resampled
data cube is stored. Result can be a file name or an existing SIC variable
of adequate dimensions.

MAP__RESAMPLE only works on 3-D data cubes. 

.ti -4
2 /LIKE
.ti +4
[CLEAN_\]MAP__RESAMPLE WhichOne [Result] [/LIKE Mold]

Resample 3-D data cubes on the same velocity scale than the specified 
Mold. Mold can be a SIC variable or GILDAS data file.

.ti -4 
1 MAP__SMOOTH
.ti +4 
[CLEAN_\]MAP__SMOOTH WhichOne Nc [Result] [/ASYMMETRIC]

Smooth a  3-D data cubes by Nc channels along the velocity axis.
.nf
     Nc   number of channels to be averaged in smoothing.
.fi
WhichOne indicates which data cube must be compressed. Allowed values are
.nf  
     - Built-in buffers DIRTY, CLEAN, SKY, SINGLE or *, which means all
       of the previous existing ones. Smoothing is done in place.
     - Any SIC Image Variable that is not a built-in buffer in IMAGER.
     - A GILDAS data file
.fi
For the two later cases, the Result argument indicates where the smoothed
data cube is stored. Result can be a file name or an existing SIC variable
of adequate dimensions.

By default, the smoothing does not modify the spectral sampling of the cubes. While
this naturally occurs when the smoothing number Nc is odd, the Nc even case
requires a specific handling.  For Nc even, the smoothed channel at
channel "i" sums up half of channel i-Nc/2, half of channels i+Nc/2 and
all channels in between.  Thus for Nc=2, this is a Hanning smoothing.

Like for UV__SMOOTH, this behaviour can be modified by option /ASYMMETRIC.

.ti -4
2 /ASYMMETRIC
.ti +4 
[CLEAN_\]MAP__SMOOTH WhichOne Nc [Result] /ASYMMETRIC 

Make no attempt to preserve the spectral sampling when Nc is even: the 
reference channel is then shifted by half the channel spacing.

For odd Nc, the smoothing is naturally symmetric, so the option has no impact.

.ti -4
1 SPECIFY
.ti +4
[CLEAN_\]SPECIFY [Buffer|FileName.Type|*] Keyword Value [Key Val ...]

Specify or modify some information in internal buffers, or
a Sic Image Variable, or Gildas Data File.

If the first argument is a * (or is omitted), SPECIFY will apply
to all relevant internal buffers (CLEAN, CONTINUUM, DIRTY, UV, SHORT, ...)

If the first argument contains a . (the separating character between a
file name from the file type), it is assumed to be a filename.

Otherwise, it should a SIC IMAGE variable or a recognized buffer.

Recognized values for Keyword are: BLANKING, FREQUENCY, LINENAME,
VELOCITY, SPECUNIT, TELESCOPE, UNIT.



.ti -4
2 Obsolete
.ti +4
SEPCIFY [...] /FOR Buffer

  This syntax is replaced by the optional first argument to specify
the Buffer name.

This OBSOLETE syntax behaviour was:
.br
If present the /FOR option indicates which buffer or Image variable
should be affected. If no /FOR option is given, all relevant
available buffers are affected (CLEAN, DIRTY, UV, etc...).

.ti -4
2 BLANKING
.ti +4
SPECIFY Buffer|FileName.Type BLANKING Value


Specify or Modify the blanking value in the specified buffer,
SIC Image variable or Gildas data file.

.ti -4
2 FREQUENCY
.ti +4
SPECIFY [*|Buffer|FileName.Type] FREQUENCY Arg [Keyword Value ...]

Modify the rest frequency(ies) and recompute the velocity scale accordingly
for all buffers, or the specified SIC variable or Gildas file.

If Arg is a number or scalar variable, it should contain 
the new rest frequency in MHz. In this mode, there may be other arguments to
specify e.g. the VELOCITY or LINENAME at the same time.

If it is the name of a SIC array variable, variable Arg must be a 1-D double 
precision array that contains frequencies  (in MHz) for every channel of the 
UV data to which it applies. This is by default the current UV data if not
specified. This mode allows to handle irregular frequency sampling that occurs
e.g. in JVLA data sets. No further argument is allowed in this mode.

.ti -4
2 LINENAME
.ti +4
SPECIFY [*|Buffer|FileName.Type] LINENAME Name [Keyword Value ...]


Change the spectral line name.

In this mode, there may be other arguments to
specify e.g. the VELOCITY or FREQUENCY at the same time.


.ti -4
2 VELOCITY
.ti +4
SPECIFY  [*|Buffer|FileName.Type] VELOCITY Value [Keyword Value ...]


Modify the source velocity and recompute the rest frequency scale accordingly
Value is the new velocity in km/s.

In this mode, there may be other arguments to
specify e.g. the LINENAME or FREQUENCY at the same time.

.ti -4
2 SPECUNIT
.ti +4
SPECIFY Buffer|FileName.Type SPECUNIT VELOCITY|FREQUENCY


Modify the unit used for the spectral axis. This may be needed, e.g.
before exporting data in FITS or UVFITS format towards other packages
that only handle Frequency or Velocity as spectral axis.

.ti -4
2 TELESCOPE
.ti +4
SPECIFY [*|Buffer|FileName.Type] TELESCOPE Name

Add or Replace the telescope section with the parameters (name,
size, position) for the specified telescope name, essentially to 
get the most appropriate beam parameter.

A Telescope section is required for MOSAIC. The beamsize will
depend on telescope diameter and frequency, with a telescope
dependent factor. The default beam size is 1.13 Lambda/D.

.ti -4
2 UNIT
.ti +4
SPECIFY UNIT NewBrightnessUnit /FOR SicVariable


Change data surface brightness unit to the desired value, rescaling the data,
the min, max, rms and noise using the proper scale factor derived
from the data header.  

Recognised units are : K, JY/BEAM, JY/PIXEL, MJY/STERADIA, MJY/STR.
If the input data unit is not one of these, nothing happens.


.ti -4
1 MOSAIC
.ti +4
[CLEAN_\]MOSAIC [?|OFF|ON|GUETH|SAULT|
.ti +4
[CLEAN_\]MOSAIC CenterX CenterY UNIT] [ANGLE Angle]]

List and Control the Mosaic processing mode.  
Two different Mosaicing processing method exists, the GUETH 
and SAULT mode.
Switching between Single-Field and Mosaic processing is automatic, 

MOSAIC ? lists the current Mosaic status.

MOSAIC OFF turns off Mosaicing mode and reset the prompt to IMAGER.

MOSAIC ON activates the current Mosaic mode

MOSAIC GUETH or MOSAIC SAULT select the Mosaic mode 

MOSAIC with coordinates and/or orientation shifts the image center
and mosaic orientation. This can be useful for elongated mosaics.

The SHOW MOSAIC command will display the mode characteristics.
As for command UV__MAP, variable MAP__CENTER can be used to specify the Mosaic
center, unless the optional arguments are specified. Otherwise,
the Mosaic center is derived from the pointing positions.

.ti -4
2 ON
.ti +4
[CLEAN_\]MOSAIC ON  

The MOSAIC ON more is automatically selected when
a new mosaic is loaded, with the currently defined mosaic mode.

.ti -4
2 OFF
.ti +4
[CLEAN_\]MOSAIC OFF  

MOSAIC OFF (and the corresponding prompt change) 
is automatically selected when a new single-field is loaded.

.ti -4
2 GUETH
.ti +4
[CLEAN_\]MOSAIC GUETH

Select the GUETH mode for imaging. It is based on the Gueth, 
Guilloteau and Viallefond method. It uses and produces Primary and 
Dirty beams of the same sizes as the Sky mosaic.
A well proven method, somewhat more memory hungry
than the SAULT mode, but differences are small for less than
19 fields.

.ti -4
2 SAULT
.ti +4
[CLEAN_\]MOSAIC SAULT  

Select the SAULT mode. It uses the 
method published by  Sault, Staveley-Smith and Brouw Astron. Astrophys. Supp Ser 120, 375-384 (1995).
In the Sault et al method, each field is imaged with a smaller map size
than the Sky mosaic, before being combined together. 
This mode is better suited for large mosaics, using less memory and more
accurate (less edge distortion effects) than the GUETH method.

.ti -4
1 MX
.ti +4
[CLEAN_\]MX [FirstPlane [LastPlane]] [/PLOT Clean|Residu] [/FLUX Fmin Fmax] [/QUERY]

Make and deconvolve maps starting from a UV table. It combines UV__MAP and
CLEAN in a single step.

The mapping process is identical to UV__MAP.  It makes a map from UV data
by griding the UV data using a convolving function, and then Fast Fourier
Transforming the individual channels.  However, MX always produces a single
beam for all channels, thus neglecting frequency change between channels.
MX enables to shift the map center and rotate the image, by shifting the
phase tracking center and rotating the UV coordinates of the input UV
table.

The CLEAN algorithm is similar to the CLARK method, but with major cycles
operating directly on the ungridded UV table rather than in the image
plane. Accordingly, aliasing affects only of the residuals, not the clean
components. It is thus more accurate but also slower than CLARK as it asks
for the gridding step at each major cycle.  MX also shares the same
limitation as CLARK on large sidelobes.

.so imager-help-clean-input.nroff-so

.ti +4
        MX ?
.br
    Will list all MAP__* and CLEAN__ * variables controlling the MX parameters.

.ti -4 
2 Variables:
.ti +4
.so imager-help-clean-uvmap-list.nroff-so

.so imager-help-clean-clean-list.nroff-so

.ti -4
1 PRIMARY
.ti +4
[CLEAN_\]PRIMARY [BeamSize] [/APPLY Input Output] [/COMPUTE] [/CORRECT] 
[/TRUNCATE Fraction]

Compute primary beam, apply it to images or correct single-field CLEAN image
for flat-field.

By default, with no option or only the /TRUNCATE option, correct the
(single-field) CLEAN image from the (approximate) primary beam 
attenuation, in order to create the sky brightness image (named SKY).
The truncation level is given by default by variable MOSAIC__TRUNCATE,
and can be overriden by the /TRUNCATE option.

The primary beam model depends on the Telescope used in the data.
If BeamSize (in radian) is specified, it is a Gaussian with  the corresponding
half-power beam size.  If not, the parameters are taken from the 
telescope parameters, as found in the telescope section of the CLEAN image and the observing 
frequency from the CLEAN image. For ALMA, the model is the Fourier transform
of a uniform 10.4 m diameter disc with 0.7 m central blockage. For
NOEMA and all other telescopes, it is a simple Gaussian with appropriate size.

The SKY image is written with extension .lmv-sky by command WRITE.

Options /APPLY, /COMPUTE or /CORRECT modify the default behaviour.
These 3 options are mutually exclusive.

.ti -4
2 /APPLY
.ti +4
[CLEAN_\]PRIMARY [BeamSize] /APPLY Input Output [/TRUNCATE Fraction]

Attenuate the data in the Input data cube by the current primary beam and
place the result in Output.  Input can be a 3-D SIC image variable or
data file, depending on the presence of a dot "." in the name. This
also applies to Output. If the later is a file, it is created.
If it is a SIC variable, it must exists and match in size the Input
data.

The primary beam is recomputed to match the Input data sampling if needed.

.ti -4
2 /COMPUTE
.ti +4
[CLEAN_\]PRIMARY [BeamSize] /COMPUTE [/TRUNCATE Fraction]

Only computes the Primary beam, using the sampling defined by the CLEAN
data set. 

.ti -4
2 /CORRECT
.ti +4
[CLEAN_\]PRIMARY [BeamSize] /CORRECT [/TRUNCATE Fraction]

Correct the CLEAN data using a pre-computed primary beam to produce the
SKY image. Re-computation is forced in case of mismatch or changing
parameters (e.g. if the optional BeamSize is given).

.ti -4
2 /TRUNCATE
.ti  +4
[CLEAN_\]PRIMARY [BeamSize] /TRUNCATE Fraction

Specify the truncation level. Default (in fraction of peak beam response)
is given by the MOSAIC__TRUNCATE variable. Values are blanked beyond this.

.ti -4
1 READ
.ti +4
[CLEAN_\]READ Buffer File [Modifier] [/COMPACT] [/FREQUENCY RestFreq]
  [/RANGE Min Max Type] [/NOTRAIL]

Read the specified internal buffer (BEAM, CCT, CGAINS, CLEAN, DIRTY,  
MASK, MODEL, PRIMARY, RESIDUAL, SKY, SUPPORT, SINGLEDISH, UV) from input File
name. Default extension is .uvt for UV, CGAINS and MODEL, and for the others, 
in order, .beam, .cct, .lmv-clean, .lmv, .msk, .lobe, .lmv-res, 
.lmv-sky, .pol and .tab respectively. FITS file format is supported
for Data Cubes when the extension is given as .fits (see HELP READ FITS
for more details).

If the File name contains a wildcard (*), it is considered as a file filter, and
a search widget is opened if possible (if not an error occurs).

A subset of all available channels can 
be indicated through the /RANGE option, even for UV tables.

The corresponding buffer is available as a SIC image-like variable
of the same name, so that one can use e.g. HEADER DIRTY command.

READ * Name   will attempt to read all existing files of
same Name with the standard file types corresponding to the
respective buffers.

The /COMPACT option is used to load the ACA-specific internal buffer used
in the ALMA joint deconvolution method.

The /NOTRAIL allows to ignore trailing columns in UV data. This is normally not
recommended and should be used for debug only. An exception is for
"false" mosaics with just 1 field: see HELP READ /NOTRAIL for
details.

.ti -4
2 Buffers
.ti +4
[CLEAN_\]READ Buffer File [/COMPACT]
  
  The recognized Buffer names for READ are:
.nf
  BEAM        Synthesized Dirty beam
  CCT         Clean Component list
  CGAINS      Complex gains for APPLY command
  CLEAN       Deconvolved Clean image
  DIRTY       Dirty image
  PRIMARY     Primary beam
  RESIDUAL    Residual image
  MASK        Spatial mask 
  MODEL       UV table for Clean components
  SINGLEDISH  Single-Dish table or data cube
  SKY         Primary beam-corrected deconvolved sky brightness
  SUPPORT     Polygon enclosing the Support for Cleaning
  UV          Same as UV__DATA
  UV__DATA     UV data table
  UV__FIT      UV__FIT results table (for SHOW UV__FIT)
.fi
The MODEL UV table is for use in conjunction with commands in 
the CALIBRATE\ language, i.e. for Self-Calibration.

The following ones are allowed with the /COMPACT option
.nf
  BEAM        Synthesized Dirty beam
  DIRTY       Dirty image
  PRIMARY     Primary beam
  RESIDUAL    Residual image
  UV__DATA     UV data table
.fi

.ti -4
2 FITS
.ti +4
[CLEAN_\]READ Buffer File [/COMPACT]

For most buffers of type "Data Cube" (e.g. BEAM, CLEAN, DIRTY,
PRIMARY, RESIDUAL, SINGLEDISH, SKY), the input File can be 
in FITS format.  READ will check for the appropriate data format
when appropriate.  If the buffer does not accept FITS data format,
an error message is issued.

UVFITS data format is now supported for UV data. See HELP READ UV
for details.


.ti -4
2 UV
.ti +4
[CLEAN_\]READ UV File [STOKES] 

Read UV data from File. File can be in GILDAS or UVFITS format.

The STOKES keyword is ignored for GILDAS format.

For File in UVFITS format, the optional keyword STOKES specifies
how the Stokes parameters are handled. If present, all stokes
parameters are stored.

If the STOKES keyword is not mentionned, READ preserves all Stokes 
parameters when 4 Stokes are in the data, but automatically reduces 
to unpolarized data (Stokes NONE, see HELP STOKES) when only 1 or 2 
Stokes parameter are present. 

UVFITS format files can also be converted to UV Tables in the GILDAS 
data format using the "@ fits__to__uvt" script, which ignores Stokes
parameters by default (only retaining Stokes I or equivalent).

.ti -4
2 Optimisation
.ti +4

Reading can be lengthy, especially for ALMA data.
IMAGER attempts to minimize read operations by checking
if anything has changed since the last command.  This
capability is enable if the SIC variable MAPPING__OPTIMIZE
is non zero, disabled otherwise.
  
  Currently, the READ command always display a message
about what reading may have been skipped, and whether this
possible optimization has been overridden by user choice.

.ti -4
2 /COMPACT
.ti +4
[CLEAN_\]READ Buffer File /COMPACT [/RANGE Min Max Type]

Read the specified internal buffer (UV, MODEL,
BEAM, PRIMARY, DIRTY, CLEAN, MASK, CCT) from input File to the
"compact array" data area.

.ti -4
2 /FREQUENCY
.ti +4
[CLEAN_\]READ Buffer File /FREQUENCY RestFreq [/RANGE Min Max Type]

Read the specified internal buffer and reset the velocity
scale to the corresponding rest frequencies. Velocities specified
in the /RANGE Min Max VELOCITY option would then refer to this
new frequency.

.ti -4
2 /NOTRAIL
.ti +4
[CLEAN_\]READ Buffer File /NOTRAIL [/FREQUENCY Freq] [/RANGE Min Max Type]

When reading UV Tables, ignores any trailing column. Trailing
columns normally appear for mosaics. However, ALMA sometimes uses
known proper motions to shift (by small amounts) phase centers
between two observing periods, yielding pseudo-mosaics with tiny
(in general insignificant) displacements.  The /NOTRAIL option
allows to ignore these details.

.ti -4
2 /PLANES
.ti +4
[CLEAN_\]READ Buffer File /PLANES Min Max 

Read only the last axis "planes" between the  First and Last implied
by Min and Max. For an LMV-ordered cube, this would be equivalent to 
.ti +4
  READ Buffer File /RANGE Min Max CHANNEL

However, for transposed data cubes, VML or LVM-ordered for example, this is
not true at all when a Frequency/Velocity axis is present: /RANGE would
specify a subset of this(yet) axis, while /PLANES always indicate
a subset of the 3rd axis of the cube.

Min and Max indicate offsets from Plane 1 and the number of planes Nplane.
Thus Max can be negative: it then indicates Last = Nplane-Max. 
Also Min=0 and Max=0 implies loading all the channels.

.ti -4
2 /RANGE
.ti +4
[CLEAN_\]READ Buffer File /RANGE Min Max Type

Load only the channels between the First and Last
defined by Min Max and Type.  Type can be
CHANNEL, VELOCITY or FREQUENCY. If the Data cube has
no Frequency/Velocity axis, only CHANNEL is allowed.

For type CHANNEL, Min and Max indicate offsets from
Channel 1 and Channel Nchan (the number of channels
in the data set). Thus Max can be negative: it then
indicates Last = Nchan-Max. Also Min=0 and Max=0 implies
loading all the channels.

The /RANGE option is not allowed for FITS files.

For UV tables with more than 1 Stokes parameter,
which are **NOT** fully supported by IMAGER, the
meaning of "channel" is ambiguous.

.ti -4
2 SINGLE
.ti +4
[CLEAN_\]READ SINGLE File[.ext] [/RANGE Min Max Type]

Read the "Single Dish" data set. It can be a Class table (.tab),
or a 3-D data cube (.lmv order).  The data set is available
as the SINGLE image variable.

If it is a 3-D data cube, the SHORT image variable is also defined
(the data area is shared with that of the SINGLE imager variable,
but the Headers are separate).  If it is a Class table, the
SHORT image becomes undefined. It will be computed by commands
UV__SHORT (see HELP UV__SHORT Step__1) or XY__SHORT. 


.ti -4
1 SUPPORT
.ti +4
[CLEAN_\]SUPPORT [Polygon] [/CURSOR] [/MASK] [/PLOT] [/RESET] [/VARIABLE] 

Define and/or plot the support inside which to search for CLEAN 
components. The support can be defined through a mask (see /MASK option)
or a polygon, depending on the selected options.
The /PLOT option can then be used to plot it.

A polygon stored in a file, or in a Sic variable (/VARIABLE option),
can be loaded as the polygon support. 

See also the [ADVANCED_\]MASK command for a complementary way of 
defining supports, in particular 3-D supports.

.ti -4
2 /CURSOR
.ti +4
[CLEAN_\]SUPPORT /CURSOR

With option /CURSOR, SUPPORT calls the interactive cursor to define the polygon
summits.  Type any key to go to next summit, D to correct the last one and
type E to end the polygon definition. The last polygon side will then
appear. The polygon definition may be aborted by typing Q. For graphical
displays, you may use the mouse buttons for the commands.  The left mouse
button draws a vertex, the middle mouse button deletes the last vertex, and
the right mouse button ends the polygon definition.

The resulting support is available in the Sic structure SUPPORT:
.nf
  - SUPPORT%NXY  [Integer]  Number of summits
  - SUPPORT%X    [Double]   X coordinates
  - SUPPORT%Y    [Double]   Y coordinates
.fi

.ti -4
2 /MASK
.ti +4
[CLEAN_\]SUPPORT /MASK    or  [ADVANCED_\]MASK USE

Use the mask defined by READ MASK or by the MASK command as the clean 
support. This does not suppress the current polygon: it can be 
re-instated by a simple SUPPORT command with no argument.

The Mask can be a 3-D array: CLEAN will find out which mask 
plane must be used for each spectral channel. 

Caution: [CLEAN_\]READ MASK and [ADVANCED_\]MASK command do not perform an 
implicit SUPPORT /MASK command. Only the ADVANCED_\MASK USE command
does it explicitely.


.ti -4
2 /PLOT
.ti +4
[CLEAN_\]SUPPORT [Name] /PLOT

Plot the current (or specified) polygon, or plot the current mask
(if it is 2-D only).

For 3-D masks, use the VIEW MASK command instead.

.ti -4
2 /RESET
.ti +4
[CLEAN_\]SUPPORT /RESET

Reset any support to default. This deletes the current polygon support.
This does not unload any mask defined  by READ MASK. Such a mask can be 
re-instated by SUPPORT /MASK.

.ti -4
2 /THRESHOLD
.ti +4
[CLEAN_\]SUPPORT /THRESHOLD [Raw Smooth [Length [Guard]]

*** Obsolete - see  [ADVANCED_\]MASK THRESHOLD instead ***
 
.ti -4
2 /VARIABLE
.ti +4
[CLEAN_\]SUPPORT VarName /VARIABLE

Load the support from the Sic variable VarName. VarName can be an 
array of the form:
.nf
         VarName[NXY,2]  Real or Double
.fi
or a structure of the form (i.e. same as output):
.nf
         VarName%NXY             Integer or Long
         VarName%X[VarName%NXY]  Real or Double
         VarName%Y[VarName%NXY]  Real or Double
.fi

.ti -4
1 UV__BASELINE
.ti +4
[CLEAN_\]UV__BASELINE [Degree] [/CHANNELS Channel__List]
  [/FREQUENCY List Of Frequencies] [/RANGE Min Max [TYPE]]
  [/VELOCITY List of Velocities] [/WIDTH Width [TYPE]]
  [/FILE FileIn [FileOut]]

Subtract a continuum from a line UV data set, by fitting  a baseline
for each visibility.  The channels to be ignored in this process
(i.e. the ones including the line emission) can be specified 
either by the /FREQUENCY or /VELOCITY options
in combination with the /WIDTH option, or by a channel list with
/CHANNELS or a range (of channels, frequencies or velocities) with
/RANGE.

By default, the command works on the current UV data, unless the
option /FILE is specified.

With no options (or with only /FILE), the command behaves as
UV__BASELINE /CHANNELS Preview%Channels. See UV__PREVIEW for details.

.ti -4
2 /CHANNELS
.ti +4
[CLEAN_\]UV__BASELINE /CHANNELS Channel__List

Channel__List must be a 1-D SIC variable containing the list of channels
to filter out.

.ti -4
2 /FILE
.ti +4
[CLEAN_\]UV__BASELINE [Degree] [/CHANNELS Channel__List]
  [/FREQUENCY List Of Frequencies] [/RANGE Min Max [TYPE]]
  [/VELOCITY List of Velocities] [/WIDTH Width [TYPE]]
  /FILE FileIn [FileOut]
  
Use the UV data in the file FileIn, and write the continuum-free
visibilities in the file FileOut.  If FileOut is not specified,
"-line" is appended to the name indicated by FileIn.  

.ti -4
2 /FREQUENCY
.ti +4
[CLEAN_\]UV__BASELINE /FREQUENCY F1 [... [Fn]] [/WIDTH Width [TYPE]]

Specify around which frequencies the line emission should be filtered.
Frequencies F1 to Fn must be in MHz. The full width of the filtering
window around every frequency can be set by option /WIDTH.
The optional argument TYPE indicates the type of width: FREQUENCY
(in MHz), VELOCITY (in km/s) or CHANNEL (no unit), the default
being FREQUENCY.  The default width is the current channel width.

Tip: it can be convenient to have a list of SIC variables containing
the frequencies of the most intense spectral lines, e.g.
.ti +8
HCO10 = 89188.52
.br 
to be used as argument to the /FREQUENCY option.

.ti -4
2 /RANGE
.ti +4
[CLEAN_\]UV__BASELINE /FREQUENCY F1 [... [Fn]] /RANGE Min Max [TYPE]

Indicate that channels between the First and Last
defined by Min Max and Type contain line emission and should
be ignored in the baseline fitting.  Type can be
CHANNEL, VELOCITY or FREQUENCY.

For type CHANNEL, Min and Max indicate offsets from
Channel 1 and Channel Nchan (the number of channels
in the data set). Thus Max can be negative: it then
indicates Last = Nchan-Max. Also Min=0 and Max=0 implies
loading all the channels.

.ti -4
2 /VELOCITY
.ti +4
[CLEAN_\]UV__BASELINE /VELOCITY V1 [... [Vn]] [/WIDTH Width [TYPE]]

Specify around which velocities the line emission should be filtered.
Velocities V1 to Vn must be in km/s. The full width of the filtering
window around every frequency can be set by option /WIDTH.
The optional argument TYPE indicates the type of width: FREQUENCY
(in MHz), VELOCITY (in km/s) or CHANNEL (no unit), the default
being FREQUENCY.  The default width is the current channel width.

.ti -4
2 /WIDTH
.ti +4
[CLEAN_\]UV__BASELINE /FREQUENCY F1 [... [Fn]] /WIDTH Width [TYPE]

Specify the full width of the
window around every frequency given in the /FREQUENCY option.
The optional argument TYPE indicates the type of width: FREQUENCY
(in MHz), VELOCITY (in km/s) or CHANNEL (no unit), the default
being FREQUENCY.  The default width is the current channel width.
The default width is the current channel width.

.ti -4
1 UV__CHECK
.ti +4
[CLEAN_\]UV__CHECK  Beams|Nulls|Integration [/FILE FileIn]

  Check current UV data for weight consistency, or the UV data in
the specified file if the /FILE option is present.

  BEAMS
.br
  List which channel range can be processed with the same synthesized beam.
See HELP UV__CHECK BEAMS for further details.

  NULLS
.br
  Check if there are null visibilities with non-zero weights, and flag
  them if found.

  INTEGRATION
.br
  Attempt to estimate the integration time. This is done by comparing
  the time stamps of consecutive observations, unless an INTEGRATION
  column is present.
  
.ti -4
2 /FILE
.ti +4
[CLEAN_\]UV__CHECK  BEAMS|FLAG|INTEGRATION|NULL [/FILE FileIn]

  Check the UV data about the specified aspects:
  synthesized BEAMS, FLAGS, INTEGRATION time, NULL visibilities 

By default, the current UV data is used, unless option /FILE specifies
a UV data file.
  
.ti -4
2 BEAMS

    Identify channel ranges that share a common beam. The raw ranges
are returned in variable BEAM__RANGES.  Ranges narrower than BEAM__GAP
are ignored in determining how UV__MAP derives the weight channels.

  When BEAM__STEP = 0, UV__MAP will attempt to use a single common beam
for all channels. For this purpose, edge channels will be dropped if they
have weights differing from the majority. They will not be imaged.

Narrow contiguous ranges of channels with differing weights will not
be considered in the beam derivation process when the range has less
than BEAM__GAP channels. These later ignored ranges will be processed
with the same weighting (and thus beam) than all other ones. They may
thus have sub-optimal noise.

    Default BEAM__GAP = 3

See HELP UV__CHECK BEAM__GAP and HELP UV__CHECK BEAM__RANGES for details.


.ti -4
2 BEAM__GAP

    Maximum number of channels for a range to be ignored in testing
weight identity and continuity to select the total number of beams
in UV__MAP.

.ti -4
2 BEAM__RANGES

  UV__CHECK BEAMS returns a variable named BEAM__RANGES[3,Nbeam] where
  Nbeam is the number of different synthesized beams that can be
  required by the UV data (based on the visibility weights).

.nf
  BEAM__RANGES[1,i]  is the first channel of Beam number i
  BEAM__RANGES[2,i]  is the last channel of Beam number i
  BEAM__RANGES[3,i]  is the total weight of visibilities of Beam number i
.fi

  BEAM__RANGES is later used by UV__PREVIEW to discard edge channels
  that often do not have the same weights as the bulk of channels.

  Variable NBEAM__RANGES indicates the number of beam ranges. It is -1 
  if UV__CHECK has not yet been used.
  
  Most automatic imaging processes will assume BEAM__RANGES is relatively
  simple (2 edges and a dominant main range) and simply discard the edges
  if any, or complain if is too complex.   
    
  For complex datasets with NBEAM__RANGES greater than 2 or 3, 
  BEAM__RANGES could be used to segment the imaging and deconvolution
  process into ranges having a common beam. Setting BEAM__STEP
  to 1 is another possibility, but that creates 1 beam per channel,
  thus doubling the used space.
  

.ti -4 
1 UV__CHOP
.ti +4
[CLEAN_\]UV__CHOP InputUV KEY OutputUV

  Chop into pieces the input UV table specified by InputUV and place
the pieces in separate files of names OuputUV-1 ... OutputUV-N.
The pieces are determined by the keyword KEY:
.nf
  DATES   Split the data by observing dates (time does not count, so
          there will be separate files for continuous observations
          around midnight
  FIELDS  Split by pointing/phase directions
.fi

UV__CHOP InputUV FIELDS OutputUV is thus similar to
.nf  
  UV__MOSAIC InputUv SPLIT OutputUV
.fi  
except that is produces degenerate 1-field mosaics instead of
simple independent single-fields.



.ti -4
1 UV__COMPRESS
.ti +4
[CLEAN_\]UV__COMPRESS [Nc]  [/CONTINUUM] [/FILE FileIn FileOut]

Resample the UV data by averaging NC adjacent channels. 

With no /FILE option, the current UV table obtained by READ UV is resampled.
All further UV commands work on the "Resampled" UV table.
The "Resampled" UV table is a simple copy of the original one after a READ UV
command, or after a UV__RESAMPLE or UV__COMPRESS commands with
no arguments and no options.

With the /FILE option, the UV data is read from file FileIn and the resampled
output is written in file FileOut.

With the /CONTINUUM option, the argument can be omitted, and the
best value for Nc is derived from the current field of view,
to avoid bandwidth smearing.


.ti -4
2 /CONTINUUM 
.ti +4
[CLEAN_\]UV__COMPRESS  /CONTINUUM  [/FILE FileIn FileOut] 

Resample the UV data by averaging Nc adjacent channels. 
The value for Nc is derived from the current field of view,
to avoid bandwidth smearing. This command is intended to provide
a compact form of UV data for continuum-only imaging, through
the UV__MAP /CONTINUUM command. Contrary to the output of
the UV__CONTINUUM command, it is also suitable for Self-Calibration
(and it is more compact).

With no /FILE option, the current UV table obtained by READ UV is resampled.

With the /FILE option, the UV data is read from file FileIn and the resampled
output is written in file FileOut.

Caution: /CONTINUUM may not work with the /FILE option if the
Minimun and Maximum baselines are not available in the FileIn header.

.ti -4
2 /FILE
.ti +4
[CLEAN_\]UV__COMPRESS Nc  /FILE FileIn FileOut
  
Use the UV data in the file FileIn, and write the data after
averaging by NC adjacent channels in the file FileOut.  


.ti -4
1 UV__CONTINUUM
.ti +4
[CLEAN_\]UV__CONTINUUM [Naver] [/INDEX Value [Frequency]]
  [/RANGE Min Max TYPE]

Transform the (presumably spectral line) UV data set loaded by READ UV
into a "continuum" data set.

The transformation selects line channels defined by the /RANGE option,
average them by groups of Naver contiguous channels,
and concatenate the resulting visibilities into a "continuum" UV table.
If not present, Naver is derived from the current field of view
MAP__FIELD and required precision, MAP__PRECIS to avoid bandwidth
smearing at field egdes.

For each output channel, and for all visibilities,
the U and V coordinates are rescaled to the mean observing frequency,
and the resulting (single-channel) visibilities are concatenated into
the "continuum" UV data set. The continuum dataset becomes the current
UV data. Flagged channels are ignored: this allows to mask channels
containing spectral lines (see UV__FILTER).

If no /RANGE option is defined, all channels are selected.

.ti -4 
2 /INDEX
.ti +4
[CLEAN_\]UV__CONTINUUM Naver /INDEX Value [Frequency]
  [/RANGE Min Max TYPE]

Specify which spectral index to be used when scaling the visibilities
as a function of frequency. 

Frequency, if specified, will be used as a reference frequency instead 
of the mean observing frequency of the covered bandwidth.

.ti -4
2 /RANGE
.ti +4
[CLEAN_\]UV__CONTINUUM Naver  /RANGE Min Max TYPE 
  [/INDEX Value [Frequency]]

Indicate that channels between the First and Last
defined by Min Max and Type should be considered to produce
the output continuum UV table. Type can be
CHANNEL, VELOCITY or FREQUENCY.

For type CHANNEL, Min and Max indicate offsets from
Channel 1 and Channel Nchan (the number of channels
in the data set). Thus Max can be negative: it then
indicates Last = Nchan-Max. Also Min=0 and Max=0 implies
all the channels.


.ti -4
1 UV__EXTRACT 
.ti +4
[CLEAN_\]UV__EXTRACT /RANGE Min Max [TYPE]  [/FILE FileIn [FileOut]]

  Extract a subset of all available channels. The command
works on the current UV buffer, unless the /FILE option is
specified

.ti -4
2 /FILE
.ti +4
[CLEAN_\]UV__EXTRACT /RANGE Min Max [TYPE] /FILE FileIn [FileOut]
  
Extract the specified range from the UV data in the file FileIn, and 
write the resulting visibilities in the file FileOut. If FileOut is not 
specified, "-ext" is appended to the name indicated by FileIn.  

.ti -4
2 /RANGE
.ti +4
[CLEAN_\]UV__EXTRACT /RANGE Min Max [TYPE]  [/FILE FileIn [FileOut]]

Indicate that channels between the First and Last
defined by Min Max and Type contain line emission and should
be filtered out.  Type can be
CHANNEL, VELOCITY or FREQUENCY.

For type CHANNEL, Min and Max indicate offsets from
Channel 1 and Channel Nchan (the number of channels
in the data set). Thus Max can be negative: it then
indicates Last = Nchan-Max. Also Min=0 and Max=0 implies
all the channels.

.ti -4
1 UV__FIELDS
.ti +4
[CLEAN_\]UV__FIELDS RaVar DecVar [Unit] [/CENTER Ra Dec] /FILE File

    ***** Experts Only **** Not intended for general use ******

    Replace fields ID by Fields offsets in a Mosaic UV Table.
This can only work for a Mosaic UV table with Fields offsets,
or Phase center offsets. It cannot operate on a UV table with
Pointing center offsets.

For files imported from UVFITS, the Fields offsets are found in 
the AIPS SU Table which is not decoded by the FITS command, 
but only through the DEFINE FITS command.

The UV__FIELDS command allows to convert the Field IDs column of the UV table
into Phase Offsets columns, and insert the proper coordinates.
Unit specifies the unit of the RaVar and DecVar variables. It
can be DEGREE, MINUTE, SECONDS, RADIAN or ABSOLUTE. 

If ABSOLUTE, RaVar and DecVar are assumed to character variable
arrays handling the Right Ascension
and Declinations of the fields expressed in sexagesimal format.

The typical use is after a DEFINE FITS A File.uvfits command, which gives
the (Ra,Dec) positions of the field centers in Degrees
in A%aips__su%col%raepo and A%aips__su%col%decepo variables:



.nf

    fits File.uvfits to File.uvt 
    define fits A File.uvfits HEADER
    compute ra mean a%aips__su%col%raepo
    compute dec mean a%aips__su%col%decepo
    define double ra dec
    define char*16 cra cdec
    let cra ra /sexag d H
    let cdec dec /sexag d d
    !
    uv__fields a%aips__su%col%raepo a%aips__su%col%decepo DEGREE -
      /FILE File.uvt /CENTER 'CRa' 'CDec'
    !
.fi
This command is used in the fits__to__uvt.ima script. Note that
a proper use also requires to set the reference coordinate
to Ra and Dec consistently in the UV Table.

.ti -4
2 /CENTER
.ti +4
[CLEAN_\]UV__FIELDS RaVar DecVar [Unit] /CENTER Ra Dec /FILE File

Specify the reference center (Pointing and Phase) of the Mosaic
UV table with Fields ID.  In this case, RaVar and DecVar are
true Ra and Dec (angles in the specified Unit), not Offsets.
The Offsets are computed from the projection information in
the UV table. 

Ra and Dec should be in usual sexagesimal notation.

Without /CENTER, RaVar and DecVar are Offsets from the Phase and
Pointing center of the Mosaic, as given in the UV data header, unless
Unit is ABSOLUTE. 

.ti -4
2 /FILE
.ti +4
[CLEAN_\]UV__FIELDS RaVar DecVar [Unit] [/CENTER Ra Dec] /FILE File

  Modify the specified File.uvt handling the UV table.
  
If the option is not present, it would instead modify
the current UV data in IMAGER. However, the READ command prevents
to load UV tables that require the action of the UV__FIELDS command,
so in practice, the /FILE option becomes mandatory.

.ti -4
1 UV__FILTER
.ti +4
[CLEAN_\]UV__FILTER [/RESET] [/ZERO] [/CHANNELS Channel__List] 
  [/FREQUENCY List Of Frequencies] [/RANGE Min Max [TYPE]]
  [/VELOCITY List of Velocities] [/WIDTH Width [TYPE]]
  [/FILE FileIn [FileOut]]

"Filter" line emission, by flagging the corresponding channels. The channels
can be specified either by the /FREQUENCY or /VELOCITY options
in combination with the /WIDTH option, or by a channel list with
/CHANNELS or a range (of channels, frequencies or velocities) with
/RANGE.


By default, channels to be filtered are flagged (weights becoming negative).
Option /ZERO can be used to erase them: weights and visibilities are
set to zero, see HELP UV__FILTER /ZERO. On the contrary, option /RESET can be used to unflag
them (and is thus conflicting with option /ZERO).

The command works on the current UV data, unless the option /FILE is specified.

With no options (except possibly /FILE and /ZERO), the command behaves as
UV__FILTER /CHANNELS Preview%Channels. See UV__PREVIEW for details.


.ti -4
2 /CHANNELS
.ti +4
[CLEAN_\]UV__FILTER [/RESET] [/ZERO] /CHANNELS Channel__List

Channel__List must be a 1-D SIC variable containing the list of channels
to filter out.

.ti -4
2 /FILE
.ti +4
[CLEAN_\]UV__FILTER [/ZERO] [/CHANNELS Channel__List]
  [/FREQUENCY List Of Frequencies] [/RANGE Min Max [TYPE]]
  [/VELOCITY List of Velocities] [/WIDTH Width [TYPE]]
  /FILE FileIn [FileOut]
  
Use the UV data in the file FileIn, and write the line-free
visibilities in the file FileOut.  If FileOut is not specified,
"-cont" is appended to the name indicated by FileIn.  

This option is conflicting with the /RESET option.


.ti -4
2 /FREQUENCY
.ti +4
[CLEAN_\]UV__FILTER [/RESET] [/ZERO] /FREQUENCY F1 [... [Fn]] [/WIDTH Width]

Specify around which frequencies the line emission should be filtered.
Frequencies F1 to Fn must be in MHz. The full width of the filtering
window around every frequency can be set by option /WIDTH.
The optional argument TYPE indicates the type of width: FREQUENCY
(in MHz), VELOCITY (in km/s) or CHANNEL (no unit), the default
being FREQUENCY.  The default width is the current channel width.

Tip: it can be convenient to have a list of SIC variables containing
the frequencies of the most intense spectral lines, e.g.
.ti +8
HCO10 = 89188.52
.br to be used as argument to the /FREQUENCY option.

.ti -4
2 /RANGE
.ti +4
[CLEAN_\]UV__FILTER [/RESET] [/ZERO] /RANGE Min Max [TYPE]

Indicate that channels between the First and Last
defined by Min Max and Type contain line emission and should
be filtered out.  Type can be
CHANNEL, VELOCITY or FREQUENCY.

For type CHANNEL, Min and Max indicate offsets from
Channel 1 and Channel Nchan (the number of channels
in the data set). Thus Max can be negative: it then
indicates Last = Nchan-Max. Also Min=0 and Max=0 implies
loading all the channels.

.ti -4
2 /RESET
.ti +4
[CLEAN_\]UV__FILTER /RESET [/CHANNELS Channel__List]
  [/FREQUENCY List Of Frequencies] [/RANGE Min Max [TYPE]]
  [/VELOCITY List of Velocities] [/WIDTH Width [TYPE]]

Unflag the channels matching the selection criteria in the
options. If no option is present, unflag channels in
the Preview%Channels list, or all channels if that list
does not exist.

The /RESET option is conflicting with /ZERO, and not valid
in the /FILE mode either.

.ti -4
2 /VELOCITY
.ti +4
[CLEAN_\]UV__FILTER [/RESET] /VELOCITY V1 [... [Vn]] [/WIDTH Width [TYPE]]

Specify around which velocities the line emission should be filtered.
Velocities V1 to Vn must be in km/s. The full width of the filtering
window around every frequency can be set by option /WIDTH.
The optional argument TYPE indicates the type of width: FREQUENCY
(in MHz), VELOCITY (in km/s) or CHANNEL (no unit), the default
being FREQUENCY.  The default width is the current channel width.

.ti -4
2 /WIDTH
.ti +4
[CLEAN_\]UV__FILTER [/RESET] [/ZERO] /FREQUENCY F1 [... [Fn]] /WIDTH Width [TYPE]

.ti +4
[CLEAN_\]UV__FILTER [/RESET] [/ZERO] /VELOCITY V1 [... [Vn]] /WIDTH Width [TYPE]

Specify the full width of the filtering
window around every frequency given in the /FREQUENCY option or
any velocity given in the /VELOCITY option.
The optional argument TYPE indicates the type of width: FREQUENCY
(in MHz), VELOCITY (in km/s) or CHANNEL (no unit), the default
being FREQUENCY.  The default width is the current channel width.

.ti -4
2 /ZERO
.ti +4
[CLEAN_\]UV__FILTER [/RESET] /ZERO [/CHANNELS Channel__List]
  [/FREQUENCY F1 [... [Fn]] [/VELOCITY V1 [... [Vn]]
  [/RANGE Min Max [TYPE]] [/WIDTH Width [TYPE]]

Erase filtered channels (set weight and visibilities to zero) rather than
simply flagging them (weight set to negative value). This can be more
convenient for further display, but is not reversible.

By default, channels to be filtered are flagged (weights becoming 
negative, and data can be unflagged by UV__FLAG).  Flagged channels are 
ignored in the averaging process, such as UV__RESAMPLE or UV__CONT. 
However, as UV__MAP (in general) uses only one channel to define the 
weights for all others, these flagged channels will nevertheless appear 
in the imaged data cube.

See UV__CHECK for information about handling flagged channels and
different beams in a single UV table.

.ti -4
1 UV__FLAG
.ti +4
[CLEAN_\]UV__FLAG [/ANTENNA Iant] [/DATE ...] [/FILE FileIn [FileOut]] 
  [/RESET]  

Without the /FILE option, display the current UV data and calls the 
cursor to interactively select a region where UV data will be flagged
or unflagged (sign of weight is made negative or positive). The /RESET 
option is used to unflag the data. 

UV data flagged using command UV__FLAG can be saved on file with 
command WRITE UV File. Detailed information about the display control
of the UV data may be found in the SHOW UV help.

See HELP UV__FLAG /FILE for direct operation on a UV data file.

Subsequent mapping with UV__MAP will ignore flagged data. However, for
multi-channel imaging, the weight column is (by default) taken from
one channel, so that channel-based flagging is will not be recognized in the
default mode, but only in the "One Beam per Channel" mode.

.ti -4
2 /ANTENNA
.ti +4
[CLEAN_\]UV__FLAG /ANTENNA Iant [/DATE ...] [/FILE FileIn [FileOut]] 
  [/RESET]  

Restrict the flagging/unflagging to the specified antenna. Only
one antenna at a time can be specified so far. If /ANTENNA is
not present, the action concerns all antennas. 

.ti -4
2 /DATE
.ti -4
[CLEAN_\]UV__FLAG [/ANTENNA Iant] /DATE Date  [/RESET]  
  
Restrict the interactive flagging/unflagging to the specified Date.

.ti -4
[CLEAN_\]UV__FLAG /DATE StartDate [StartUT [EndDate [EndUT]]] 
  /FILE FileIn [FileOut]] [/ANTENNA Iant] [/RESET]  

With the /FILE option, the /DATE option has a more flexible syntax.
It understands any of the following
.nf
  /DATE StartDate                         The whole date is flagged 
                from UT=0 to UT=24 h
  /DATE StartDate EndDate                 The whole range of dates  
                from StartDate to EndDate is flagged
  /DATE StartDate StartUT EndUT           Time range from StartUT
                to EndUT in StartDate is flagged
  /DATE StartDate StartUT EndDare EndUT   Time range from StartUT  
                in StartDate to EndUT in EndDate is flagged
.fi
Date format is DD-MMM-YYYY, and Time is in hours, sexagesimal notation
(hh:mm:ss.ss)  allowed.

.ti -4
2 /FILE
.ti +4 
[CLEAN_\]UV__FLAG /FILE FileIn [FileOut] [/ANTENNA Iant] [/DATE ...]
  [/RESET]  

Flag data found in FileIn, and store the result in FileOut, or in
place if FileOut is not specified.  Note that the UV__FLAG command 
has no memory: it caannot restore the flagging to a previous state, 
but only flag or unflag from the current flag state.

.ti -4
2 /RESET
.ti +4 
[CLEAN_\]UV__FLAG /RESET [/FILE FileIn [FileOut]] [/ANTENNA Iant] [/DATE ...]


Unflag the specified range, instead for flagging it.
Note that the UV__FLAG command has no memory: it cannot restore 
the flagging to a previous state, but only flag or unflag from
the current flag state.

.ti -4
2 CHANNEL

Channel range to be flagged/unflagged.


.ti -4
1 UV__MAP
.ti +4
[CLEAN_\]UV__MAP [CenterX CenterY Unit] [ANGLE AngleValue] 
[/FIELDS FieldList] [/TRUNCATE Fraction] [/RANGE Min Max Type]
[/CONTINUUM [Naver]] [/INDEX Alpha]

Compute a dirty map and beam from a UV data. UV data must have been loaded
from a UV table by command "READ UV File". UV__MAP processes
single fields as well as Mosaics.

The user can control the algorithm through SIC variables. New values 
can be given using "LET VARIABLE value". For ease of use, and whenever 
it is possible, a sensible value of each parameter will automatically 
be computed from the context if the value of the corresponding variable 
is set to its default value, i.e. zero value and empty string. A few 
variables are initialized to "reasonable" values.

The arguments define the Map center and orientation (Projection system).
Unit can be any of DEGREE, MINUTE, SECOND and RADIAN, or ABSOLUTE.
In the latter case, CenterX should be the Right Ascension and CenterY
the Declination in sexagesimal notation. Otherwise, they are offsets
from the current projection center in the specified Unit. 

AngleValue is the ** absolute ** rotation of the projection (counted East 
from North as usual), which means the angle between the Celestial North
and the Y axis in the resulting image. 

If no argument is given, UV__MAP uses the variable MAP__CENTER to
derive the projection system. If it is empty, it does not change it.

.ti +4
[CLEAN_\]UV__MAP ?

Will list all MAP__* variables controlling the UV__MAP parameters

.ti -4 
2 Mosaics
.ti +4
[CLEAN_\]UV__MAP [[CenterX CenterY Unit] [ANGLE AngleValue]
  /FIELDS FieldList [/TRUNCATE Fraction]

The UV data can be a Mosaic UV table. In this case, UV__MAP will image
the Mosaic, using appropriate primary beam size and truncation level.

By default, the primary beam size is taken from the telescope parameters, either as
found in the telescope section of the UV table and the observing frequency
(e.g. for ALMA it uses 1.13 Lambda/D). If absent, the telescope section
information can be added by command SPECIFY TELESCOPE.  

The truncation level (in fraction of peak) for individual pointings is 
taken from variable MOSAIC__BEAM or from the /TRUNCATE option argument. 
It should be 0 for high dynamic range. Non zero values may be used with 
caution in case of large pointing errors, but require sufficient
overlap of the fields.

The imaging method can be GUETH (default) or SAULT, see the MOSAIC command.

.ti -4
2 /CONTINUUM
.ti +4
[CLEAN_\]UV__MAP [CenterX CenterY Unit] [ANGLE AngleValue]
/CONT [Naver] [/INDEX Alpha] [/RANGE Min Max Type]

Produce a Continuum image (from all channels, or those
selected  by the specified Velocity, Frequency or Channel range (depending
on Type) between Min Max when the option /RANGE is present), using
a Multi-Frequency Synthesis, where (u,v) coordinates are scaled
with Frequencies to produce an optimal beam. 

  Naver is the number
of initial channels that will share the same (u,v) coordinates. If
not present, it is computed from MAP__FIELD and MAP__CELL to
limit bandwidth smearing.

In essence, UV__MAP /CONTiNUUM behaves as the combination of
UV__CONTINUUM  followed by UV__MAP, but the pseudo-continuum
UV Table created by UV__CONTINUUM is not kept by UV__MAP /CONTINUUM.

A spectral index can be specified using option /INDEX.

.ti -4
2 /FIELDS
.ti +4
[CLEAN_\]UV__MAP [CenterX CenterY Unit] [ANGLE AngleValue]
  /FIELDS FieldList [/TRUNCATE Percent]

For a Mosaic, only image the fields specified in a 1-D Integer variable
FieldList, or in the explicit list given as argument to the /FIELDS
option.  SHOW FIELDS will highlight the list of fields selected
 by this command.

.ti -4
2 /INDEX
.ti +4
[CLEAN_\]UV__MAP [CenterX CenterY Unit] [ANGLE AngleValue]
/CONT [Naver] /INDEX Alpha [/RANGE Min Max Type]

Specify the spectral index to be used for Continuum imaging
using a Multi-Frequency Synthesis method. This option is only
valid with the /CONT option.

.ti -4
2 /RANGE
.ti +4
[CLEAN_\]UV__MAP [CenterX CenterY Unit] [ANGLE AngleValue]
  /RANGE Min Max Type [/FIELDS FieldList] [/TRUNCATE Percent] 
  [/CONT [Naver]] [/INDEX Alpha]

Indicate that only channels between the First and Last
defined by Min Max and Type should be considered to produce
the image. Type can be CHANNEL, VELOCITY or FREQUENCY.

For type CHANNEL, Min and Max indicate offsets from Channel 1 and 
Channel Nchan (the number of channels in the data set). Thus Max can be 
negative: it then indicates Last = Nchan-Max. Also Min=0 and Max=0 
implies all the channels.

This is a more convenient replacement of the deprecated MCOL variable.
.ti -4 
2 /TRUNCATE
.ti +4
[CLEAN_\]UV__MAP [CenterX CenterY Unit] [ANGLE AngleValue] 
  [/FIELDS FieldList] /TRUNCATE Fraction

For a Mosaic, truncate the individual pointings to the specified level
(in fraction). The default is to use the MOSAIC__BEAM value.

.ti -4 
2 Variables:
.ti +4
        [CLEAN_\]UV__MAP ?

    Will list all MAP__* variables controlling the UV__MAP parameters.
.br
.so imager-help-clean-uvmap-list.nroff-so

See HELP UV__MAP Old__names:  for deprecated variable names.

.so imager-help-clean-uvmap-desc.nroff-so

.ti -4
1 UV__RESAMPLE
.ti +4
[CLEAN_\]UV__RESAMPLE [Nc Ref Val Inc] [/FILE FileIn FileOut] [/LIKE Mold]

With no option, resample the UV data loaded by READ UV on a different 
velocity scale.  All other UV commands except UV__COMPRESS work on the 
"Resampled" UV table. The output spectral sampling is defined by
.nf
     Nc   new number of channels
     Ref  New reference pixel
     Val  New velocity at reference pixel
     Inc  Velocity increment
.fi
Any argument can be set to * for an automatic determination based on
the values of the other arguments. The automatic determination of
NC preserves the velocity coverage.

The "Resampled" UV table is a simple copy of the original one after a READ UV
command, or after a UV__RESAMPLE or UV__COMPRESS command without arguments.

With the /FILE option, the internal buffers are not used: the UV data 
is read from file FileIn and the resampled output is written in file 
FileOut. In this case, the /LIKE option can be used to define
the spectral sampling as identical to the Mold file.

.ti -4
2 /FILE
.ti +4
[CLEAN_\]UV__RESAMPLE [Nc Ref Val Inc] /FILE FileIn FileOut [/LIKE Mold]
  
Use the UV data in the file FileIn, and write the spectrally resampled
UV data in the file FileOut.  

In this case, the /LIKE option can be used to define the spectral sampling 
as identical to the Mold file, instead of specifying it as arguments
to the command.


.ti -4
2 /LIKE
.ti +4
[CLEAN_\]UV__RESAMPLE  /FILE FileIn FileOut /LIKE Mold
  
Use the UV data in the file FileIn, and write the spectrally resampled
UV data in the file FileOut.  The resampled FileOut will spectrally
conform the Mold UV table specified in the /LIKE argument.

Caution: the resampling is in Velocity only, independently of the
Frequencies present in FileIn and Mold. This is to allow resampling different
transition on the same velocity grid.  Accordingly, if FileIn and Mold
refer to data from the same transition, make sure they have the same
reference frequency before using UV__RESAMPLE.

.ti -4
1 UV__RESIDUAL
.ti +4
[CLEAN_\]UV__RESIDUAL [MODE] [Arg1 ... ArgN] [/FIELDS List]

  This command subtract Clean components OR fit results from the last UV__FIT
command, depending on specified argument MODE if present (can be CLEAN or UV__FIT), or
on whether CLEAN (or its specialized versions HOGBOM, CLARK,
etc...) or UV__FIT was done last if not. The residual UV data are available
in SIC structure UV__RESIDUAL, and can be written by WRITE UV__RESIDUAL command.

  The UV__RESIDUAL data can also be selected for further imaging by UV__MAP
(and thus UV__RESTORE) or displayed by SHOW UV using command 
UV__SELECT.  MODEL and UV__RESIDUAL are complementary commands 
(UV__DATA = UV__MODEL + UV__RESIDUAL); see HELP UV__RESIDUAL Note however.

For the Clean component the syntax is
.nf
[CLEAN_\]UV__RESIDUAL [CLEAN] [Niter]
.fi
that subtracts the Niter first (default all) Clean Components from the UV data.

For the UV__FIT results, Clean component the syntax is
.nf
[CLEAN_\]UV__RESIDUAL [UV__FIT] [F1 .. Fn]
.fi
that subtracts the F1 to Fn fitted functions (default all) from the UV data.

.ti -4
2 Note
.ti +4

  UV__RESIDUAL does not yet have the /MINVAL option of command MODEL.

.ti -4
1 UV__RESTORE
.ti +4
[CLEAN_\]UV__RESTORE [/COPY] [/SPEED Mode]

Create a Clean image from the current UV data set and the Clean Component list.
The Clean Components are subtracted from the UV data set, and these residuals
are gridded and Fourier transformed to compute the Residual image. This
Residual image is added to the Gaussian beam convolved image of the sum of
Clean components. The results are similar to those of MX, since only the
residual are aliased.

This command can be used with all methods (HOGBOM, CLARK, MULTI, SDI)
except for MRC which has no notion of Clean Components.

.ti -4
2 /COPY
.ti +4
[CLEAN_\]UV__RESTORE /COPY [/SPEED Mode]

--- Obsolescent ---  Reserved for debugging ---

The /COPY option controls whether array copys or pointers are used
for some internal buffers. The option may be removed without further
notice.

.ti -4
2 /SPEED
.ti +4
[CLEAN_\]UV__RESTORE /SPEED Mode [/COPY]

Create a Clean image from the current UV data set and the Clean Component list,
using the specified Mode to remove the Clean Components before
imaging the residuals.

The argument Mode may be one of the following keyword:
.nf
AUTO    Automatically select the "fastest" method, according to the
      current number of Visibilities and Clean components.
FFT     Subtract Clean Components by FFT and interpolation onto 
      individual visibilities. 
PRECIS  Subtract the Clean Components by simple Sin/Cos phase terms
      for each visibility
.fi
The PRECIS mode is faster for a small number of visibilities and Clean 
components, while the FFT mode is faster for large ones. 

Instead of the above keywords, Mode may also be a number which 
specifies when the AUTO mode should switch from PRECIS mode to FFT 
mode.   The default number to control the AUTO mode is 200 Millions 
(product of the number of visibilities and average number of Clean 
components per channel). This value is "sticky": if changed by /SPEED, 
the new values is retained until next change.


.ti -4
1 UV__REWEIGHT
.ti +4
[CLEAN_\]UV__REWEIGHT MODE [Args...] [/RANGE Min Max Type] 
  [/FLAG Threshold]

Compute and/or Apply a scale factor to the weights of the current
UV data. Can be used to patch e.g. JVLA data files which may
have only relative weights, not absolute values indicating the
noise.

MODE can be APPLY, DO, ESTIMATE or TIME.

.ti -4
2 APPLY
.ti +4
[CLEAN_\]UV__REWEIGHT APPLY Factor

Apply the specified scale Factor to the weights. Factor can be *
to used the last derived scale factor from command UV__REWEIGHT ESTIMATE.
This factor is set to 1.0 by command UV__REWEIGHT APPLY, so that
repetitive use of the APPLY * mode no longer affects the data.

.ti -4
2 DO
.ti +4
[CLEAN_\]UV__REWEIGHT DO [Tolerance [Printout]] [/RANGE Min Max Type] 
  [/FLAG Threshold]

Derive the scale factor from the noise statistics over the channels,
and use it to rescale the weights.
The noise statistic is derived from the real and imaginary parts 
separately, taking mean value,  or the minimum of the twos when the
mean/min ratio is smaller than specified Tolerance (default is 1.2).

The /FLAG option indicates whether data with highly deviating weights
should be flagged. UV__REWEIGHT DO combines the two actions of 
UV__REWEIGHT ESTIMATE (or TIME) and UV__REWEIGHT APPLY, but with a 
control over these outliers (that are not identified by APPLY).

Mode DO uses the ESTIMATE method if the number of channels is > 16,
the TIME method if not.

Printout is a number indicating to print some correction factors
every Printout visibility (no print if 0, the default) (for ESTIMATE
method only).

.ti -4
2 ESTIMATE
.ti +4
[CLEAN_\]UV__REWEIGHT ESTIMATE [Tolerance [Printout]] [/RANGE Min Max Type] 

Derive the scale factor from the noise statistics derived from
the rms individual visibilities over the specified channels.
The noise statistic is derived from the real and imaginary parts 
separately, taking mean value,  or the minimum of the twos when the
mean/min ratio is smaller than specified Tolerance (default is 1.2).

Printout is a number indicating to print some correction factors
every Printout visibility (no print if 0, the default).

.ti -4
2 TIME
.ti +4
[CLEAN_\]UV__REWEIGHT TIME [Tolerance] [/RANGE Min Max Type] 

Derive the scale factor from the noise statistics derived from
consecutive visibilities, considering the specified channel range.
The noise statistic is derived from the real and imaginary parts 
separately, taking mean value,  or the minimum of the twos when the
mean/min ratio is smaller than specified Tolerance (default is 1.2).

The UV data is first baseline-time sorted to ensure that all UV data points
of the UV track for any antenna pair are consecutive. 


.ti -4
2 /RANGE
.ti +4
[CLEAN_\]UV__REWEIGHT DO|ESTIMATE|TIME [Tolerance [Printout]] [/FLAG Threshold]
  /RANGE Min Max [Min Max [...]] Type
  
Specify the spectral range(s) defining the channels to use in the
noise estimates. More than 1 range can be specified if the Mode is not TIME.

/RANGE can not be used with keyword APPLY.

.ti -4
2 /FILE
.ti +4
[CLEAN_\]UV__REWEIGHT DO|ESTIMATE|TIME [Tolerance [Printout]] [/FLAG Threshold]
  /RANGE Min Max [Min Max [...]] Type

.ti -4
2 /FLAG
.ti +4
[CLEAN_\]UV__REWEIGHT DO [Tolerance [Printout]] /FLAG Threshold
  [/RANGE Min Max Type] 
  
The /FLAG option indicates whether data with highly deviating weights
should be flagged. UV__REWEIGHT DO combines the two actions of 
UV__REWEIGHT ESTIMATE and UV__REWEIGHT APPLY, but with a 
control over these outliers (that are not identified by APPLY).

Default Threshold is 3, i.e. data are considered as outliers
if their re-scale factor is more than 3 times above (or below)
the median value.  This is adequate to spot bad data.

/FLAG is only valid for keyword DO.

.ti -4
1 UV__SHIFT
.ti +4
[CLEAN_\]UV__SHIFT  [CenterX CenterY UNIT] [ANGLE Angle] [/FILE FileInOut]

Shift the current (if no /FILE option is present) or specified
(if the /FILE option is here) UV table (single field or mosaic) to a common phase 
center and/or rotate it.

Angle is desired position angle of the Celestial North from the Y axis
(counted positive towards East, i.e. counter-clockwise in usual
astronomical images), in Degree. It is thus an absolute value.

If UNIT is ABSOLUTE, CenterX and CenterY are absolute coordinates
in usual sexagesimal notation.

If not, CenterX and CenterY are offsets in the specified angular unit
(SECOND, MINUTE, DEGREE or RADIAN).



Although UV__MAP also provides a direct possibility to re-center the 
image on a specified projection (phase) center cmobined with a
rotation of the main axes, the modified 
visibilities cannot be saved on file. It is sometimes required to do 
this for specific use. UV__SHIFT provides this possibility, and the 
shifted UV table can be written using command WRITE UV.

UV__DEPROJECT includes the UV__SHIFT capabilities, but
also has additional functions, and a different syntax.

.ti -4
2 /FILE
.ti +4
[CLEAN_\]UV__SHIFT  [CenterX CenterY UNIT] [ANGLE Angle] /FILE FileInOut

Shift and/or rotate the UV table specified in the /FILE option 
(single field or mosaic) to a common phase center and given orientation. 

Warning: Rotated Mosaics cannot yet be saved. IRAM has not decided
upon a convention for storing this information.

.ti -4 
1 UV__SMOOTH
.ti +4
[CLEAN_\]UV__SMOOTH Nc [/ASYMMETRIC] [/FILE FileIn FileOut]


Smooth by NC channels a UV data set. UV__SMOOTH differs from UV__COMPRESS 
because it keeps the original spectral sampling. The resulting UV data is 
thus oversampled by NC channels.

Unless the /ASYMMETRIC option is present, the smoothing is symmetric,
to ensure that the spectral sampling is preserved. This is implicit when
Nc is odd, but for even values of Nc, it is done by smoothing by Nc+1 channels, 
and giving the edge channels of the smoothing kernel a half-weight. The effective 
bandwidth of each smoothed channel is still Nc times the original one.

As a result, UV__SMOOTH 2 is equivalent to a Hanning smoothing.

With no /FILE option, the current UV table obtained by READ UV is resampled.
All further UV commands work on the "Resampled" UV table.
The "Resampled" UV table is a simple copy of the original one after a READ UV
command, or after a UV__RESAMPLE or UV__COMPRESS commands with
no arguments and no options.

With the /FILE option, the UV data is read from file FileIn and the resampled
output is written in file FileOut.

.ti -4
2 /ASYMMETRIC
.ti +4 
[CLEAN_\]UV__SMOOTH Nc /ASYMMETRIC [/FILE FileIn FileOut]

Make no attempt to preserve the spectral sampling when Nc is even: the 
reference channel is then shifted by half the channel spacing.

For odd Nc, the smoothing is naturally symmetric, so the option has no impact.

.ti -4
2 /FILE
.ti +4
[CLEAN_\]UV__SMOOTH Nc  /FILE FileIn FileOut [/ASYMMETRIC]
  
Read the UV data in the file FileIn, and write the data after
averaging by NC adjacent channels in the file FileOut.  



.ti -4
1 UV__SPLIT
.ti +4
[CLEAN_\]UV__SPLIT [Degree [Compress]] /FILE FileIn [FileLine [FileCont]]
  [/CHANNELS Channel__List] 
  [/FREQUENCY List Of Frequencies] [/RANGE Min Max [TYPE]]
  [/VELOCITY List of Velocities] [/WIDTH Width [TYPE]]

"Split" the UV table found in file FileIn into a Continuum-free one 
(FileLine) and a Line-free continuum one (FileCont), using the ranges
specified by one of the other options to indicate where the line
emission is (see UV__BASELINE and UV__FILTER for details). 
The channels can be specified either by the /FREQUENCY or /VELOCITY 
options in combination with the /WIDTH option, or by a channel list 
with /CHANNELS or a range (of channels, frequencies or velocities) with 
/RANGE.

Degree is the baseline fit degree (0 or at most 1).
Compress is the number of line channels averaged together while producing
the pure continuum (Line-free) visibilities. 

The command only works with files: option /FILE is mandatory.

With only /FILE as option, the command behaves as
UV__SPLIT /FILE FileIn [FileLine [FileCont]] /CHANNELS Preview%Channels. 
See UV__PREVIEW for details about Preview%Channels.

.ti -4
2 /CHANNELS
.ti +4
[CLEAN_\]UV__SPLIT [Degree [Compress]] /FILE FileIn [FileLine [FileCont]]
  /CHANNELS Channel__List

Channel__List must be a 1-D SIC variable containing the list of channels
where line emission is assumed to be.

.ti -4
2 /FILE
.ti +4
[CLEAN_\]UV__SPLIT [Degree [Compress]] /FILE FileIn [FileLine [FileCont]]
  [/FREQUENCY List Of Frequencies] [/RANGE Min Max [TYPE]]
  [/VELOCITY List of Velocities] [/WIDTH Width [TYPE]]
  /FILE FileIn [FileOut]
  
Use the UV data in the file FileIn, and write the continuum-free
visibilities in the file FileLine, and the line-free visibilities in
FileCont. If not specified, FileLine (resp FileCont) is derived
from FileIn by appending "-line" (resp "-cont") to the filename.

.ti -4
2 /FREQUENCY
.ti +4
[CLEAN_\]UV__SPLIT [Degree [Compress]] /FILE FileIn [FileLine [FileCont]]
    /FREQUENCY F1 [... [Fn]] [/WIDTH Width]

Specify around which frequencies the line emission should be found.
Frequencies F1 to Fn must be in MHz. The full width of the 
window around every frequency can be set by option /WIDTH.
The optional argument TYPE indicates the type of width: FREQUENCY
(in MHz), VELOCITY (in km/s) or CHANNEL (no unit), the default
being FREQUENCY.  The default width is the current channel width.

Tip: it can be convenient to have a list of SIC variables containing
the frequencies of the most intense spectral lines, e.g.
.ti +8
HCO10 = 89188.52
.br to be used as argument to the /FREQUENCY option.

.ti -4
2 /RANGE
.ti +4
[CLEAN_\]UV__SPLIT [Degree [Compress]] /FILE FileIn [FileLine [FileCont]]
    /RANGE Min Max [TYPE]

Indicate that channels between the First and Last
defined by Min Max and Type contain line emission.
Type can be
CHANNEL, VELOCITY or FREQUENCY.

For type CHANNEL, Min and Max indicate offsets from
Channel 1 and Channel Nchan (the number of channels
in the data set). Thus Max can be negative: it then
indicates Last = Nchan-Max. Also Min=0 and Max=0 implies
loading all the channels.

.ti -4
2 /VELOCITY
.ti +4
[CLEAN_\]UV__SPLIT [Degree [Compress]] /FILE FileIn [FileLine [FileCont]]
  /VELOCITY V1 [... [Vn]] [/WIDTH Width [TYPE]]

Specify around which velocities the line emission should be found. 
Velocities V1 to Vn must be in km/s. The full width of the 
window around every frequency can be set by option /WIDTH.
The optional argument TYPE indicates the type of width: FREQUENCY
(in MHz), VELOCITY (in km/s) or CHANNEL (no unit), the default
being FREQUENCY.  The default width is the current channel width.

.ti -4
2 /WIDTH
.ti +4
[CLEAN_\]UV__SPLIT [Degree [Compress]] /FILE FileIn [FileLine [FileCont]]
  /FREQUENCY F1 [... [Fn]] /WIDTH Width [TYPE]

.ti +4
[CLEAN_\]UV__SPLIT [Degree [Compress]] /FILE FileIn [FileLine [FileCont]]
  /VELOCITY V1 [... [Vn]] /WIDTH Width [TYPE]

Specify the full width of the window around every frequency given in 
the /FREQUENCY option or any velocity given in the /VELOCITY option.
The optional argument TYPE indicates the type of width: FREQUENCY
(in MHz), VELOCITY (in km/s) or CHANNEL (no unit), the default
being FREQUENCY.  The default width is the current channel width.


.ti -4
1 UV__STAT
.ti +4
[CLEAN_\]UV__STAT Mode [Start [Step]] [/PLOT [File]]

UV__STAT allows the astronomer to select the best weighting
and imaging parameters according to its personal trade off between
angular resolution, sensitivity and field of view.

Argument Mode describes the action. Default is ALL, equivalent to 
HEADER+ADVISE. See HELP UV__STAT Argument for details.


.ti -4
2 /PLOT
.ti +4

[CLEAN_\]UV__STAT Mode [Start [Step]] /PLOT [File]

Shows bitmaps of the resulting beams for Mode  BRIGGS, CELL, ROBUST, TAPER or WEIGHT.

A temporary file may be created, but is kept only if the File argument is present.


.ti -4
2 Casa
.ti +4

CASA and GILDAS handle the weighting scheme slightly differently and
with different conventions for the Robust parameter values.

CASA uses only Briggs weighting, while IMAGER offers the Briggs
weighting scheme (obtained for MAP__ROBUST < 0) and a different,
more progressive, weighting (obtained for MAP__ROBUST > 0).

For MAP__ROBUST < 0, the corresponding CASA Briggs value can be obtained
by adding 2. 

In addition, CASA apparently uses a default value for the size of
the UV cell in Briggs weighting which is about the dish diameter(*).
If MAP__UVCELL is 0, IMAGER will use the same default value.
Otherwise, IMAGER will use the specified user input.

(*) The default value quoted before is valid for a single field. 
However, the documentation is unclear in this respect and suggests that
the UV cell size depends on the imaged field size. This would 
be strange, though. What happens for mosaics is even less clear.

.ti -4
2 Mosaics
.ti +4

UV__STAT handles Mosaic like Single-Field for the weighting (BEAM, BRIGGS,
TAPER and WEIGHT arguments): all
visibilities are considered, instead of those of one among the
various fields.  Accordingly, the predicted beam sizes are often
underestimated compared to what UV__MAP and FIT commands would yield.

For a fine adjustment of the beam shape and size, it is recommended
to verify using UV__MAP and FIT commands and iterate if needed. 

.ti -4
2 Results
.ti +4
UV__STAT returns a number of SIC Variables, depending on which action
is performed.

.br 
DEFMAP  a structure containing the current values for the Map 
SIZE, CELL and FIELD of view, derived from the user prescription
in MAP__SIZE, MAP__CELL and MAP__FIELD. 

.br
BEAM__SHAPE[Nw,Nv]  is a 2-D array containing the results by UV__STAT
BRIGGS, CELLS, ROBUST, TAPER or WEIGHT. It can be used in scripts
to select the optimal combination of MAP__ROBUST and MAP__UVTAPER
values according to the desired compromise of sensitivity and angular
resolution.

.bf
UV__BMIN and UV__BMAX, the min and max baselines


.ti -4 
2 Arguments:
.ti +4
[CLEAN_\]UV__STAT Mode [Start [Step]]

Argument Mode describes the action. Possible values are 
.nf
ADVISE     Suggest values for Map size, Map field and Pixel size
ALL        As HEADER + ADVISE
BASELINE   Displays an histogram of baseline lengths
BEAM       Evaluate (and optionally display) the synthesized beam
BRIGGS     Estimate beam size as function of Briggs robust parameter
CELL       Estimate beam size as function of UV cell size
DEFAULT    Reset UV__MAP parameters to Default values
HEADER     Display detailed UV header
RESET      Reset UV__MAP parameters to previous Values
ROBUST     Estimate beam size as function of Gildas robust parameter
SETUP      Take suggested values for Map size, Map field and Pixel size
TAPER      Estimate beam size as function of UV Taper 
WEIGHT     Estimate beam size as function of MAP__ROBUST parameter
.fi

The default value is ALL, which makes the same action as HEADER + ADVISE
combined.

.ti -4
2 ADVISE
.ti +4

[CLEAN_\]UV__STAT ADVISE

  Display the recommended image and pixel sizes, independently of the 
current values of MAP__FIELD, MAP__SIZE and MAP__CELL. 

.ti -4
2 ALL
.ti +4

[CLEAN_\]UV__STAT ALL

  Display the UV header and a few more associated values, like the
recommended image and pixel sizes. Equivalent to HEADER + ADVISE 

.ti -4
2 BASELINES
.ti +4

[CLEAN_\]UV__STAT BASELINES [/PLOT]

  Displays an histogram of baselines length and a Gaussian fit
to it to give an idea of the beam size. This is just a rough estimate,
since it ignores asymmetries in the baseline distributions.

  Option /PLOT is implicit with this argument.

.ti -4
2 BEAM
.ti +4

[CLEAN_\]UV__STAT BEAM [/PLOT]

  Evaluate the expected synthesized beam size and orientation, based
on current imaging parameters MAP__UVCELL, MAP__ROBUST, MAP__UVTAPER.

  If option /PLOT is present, the synthesized beam is also displayed.
A fast gridding is used for this command to minimize computing time, 
so the actual synthesized beam produced by UV__MAP will be (very 
slightly) different. This does not significantly affect the beam size.

.ti -4
2 BRIGGS
.ti +4

[CLEAN_\]UV__STAT BRIGGS [/PLOT]


Beam sizes and noise level (in flux and brightness) will be
computed for 9 different "robust" weighting parameters using
the Briggs method.  The Briggs parameters range from
-4 (nearly uniform weighting) to 0 (natural weighting) (values
are shifted by -2 compared to the Briggs parameters in CASA).
The taper is taken from variable UV__TAPER.
The UV cell size is specified by MAP__UVCELL in m.

See HELP UV__STAT Casa for details about Briggs parameter vs Robust
parameter.

The /PLOT option will display the inner regions of the beams.

.ti -4
2 CELL
.ti +4
[CLEAN_\]UV__STAT CELL [Start [Step]] [/PLOT]

Predict the synthesized beam, expected noise level, and recommended pixel
size for different values of  the uv cell size for current robust
weighting and taper parameters. 

The /PLOT option will display the inner regions of the beams.

.ti -4
2 DEFAULT
.ti +4
[CLEAN_\]UV__STAT DEFAULT

Reset MAP__SIZE, MAP__CELL, MAP__FIELD and MAP__UVCELL to their Default 
values (all 0). Robust parameter and Tapers are not changed. Command
UV__STAT RESET does a slightly different job.

.ti -4
2 HEADER
.ti +4
[CLEAN_\]UV__STAT HEADER

Display a brief summary of the UV data: number of antennas,
observing dates, baseline ranges,  spectroscopic information.

.ti -4
2 RESET
.ti +4
[CLEAN_\]UV__STAT RESET 

  Reset MAP__SIZE, MAP__FIELD and MAP__CELL to their previous values
after a UV__STAT SETUP. This is different from the UV__STAT DEFAULT
command.

.ti -4
2 ROBUST
.ti +4
[CLEAN_\]UV__STAT ROBUST [Start [Step]] [/PLOT]

For ROBUST, beam sizes and noise level (in flux and brightness) will be
computed for 9 different MAP__ROBUST weighting parameters (from Start to
Start*Step^9). Default value for Step is sqrt(10), and default value
for Start is derived to center the "robust" parameter values around 1.
UV cell size is taken from variable MAP__UVCELL, and Taper is taken
from variable UV__TAPER.

The /PLOT option will display the inner regions of the beams.

.ti -4
2 SETUP
.ti +4
[CLEAN_\]UV__STAT SETUP

Compute the recommended values for the imaging: image size,
pixel size, field of view, largest angular scale, etc...,
and set the corresponding MAP__variables (MAP__SIZE, MAP__FIELD
and MAP__CELL) to these values if they were not previously
specified.

.ti -4
2 TAPER
.ti +4
[CLEAN_\]UV__STAT TAPER [Start [Step]] [/PLOT]

For TAPER, beam sizes and noise level (in flux and brightness) will be
computed for 9 different tapers (from Start to Start*Step^9).
Default value for Step is sqrt(2), Default value for Start
is 50 m. Weighting mode, UV cell size and "robust" parameter
are taken from variable MAP__UVCELL and MAP__ROBUST (i.e. one can combine
Robust weighting and Tapering).


The /PLOT option will display the inner regions of the beams.

.ti -4
2 WEIGHT
.ti +4
[CLEAN_\]UV__STAT WEIGHT [/PLOT]

The WEIGHT action combines BRIGGS and ROBUST, allowing a more
exhaustive exploration of weighting. UV cell size is taken from variable
MAP__UVCELL, and Taper is taken from variable UV__TAPER.

The /PLOT option will display the inner regions of the beams.
Caution: the ordering of the MAP__ROBUST parameter is different in
the printed output and in the plotted beams.


.!-------------------------------------------------------------------

.ti -4
1 UV__SUBTRACT
.ti +4
[CLEAN_\]UV__SUBTRACT [Time [Factor]] /FILE FileIn FileCont [FileOut] 
  [/RANGE Min Max Type]
  
Subtract the Continuum UV data present in UV Table file given in FileCont
from the spectral line visibilities of the UV table FileIn, and put
the result in FileOut. The /FILE option is mandatory for syntax
conformance reasons.

If FileOut is not present, FileIn will be overwritten.

Time is the smoothing time constant to determine the continuum visibility
(default none).  Factor is an optional scale factor to apply to the
continuum visibility.

2 /FILE 
.ti +4
[CLEAN_\]UV__SUBTRACT [Time [Factor]] /FILE FileIn FileCont [FileOut] 
  [/RANGE Min Max Type]

The /FILE option is mandatory for UV__SUBTRACT command, to keep syntax
conformance with other commands. See HELP UV__SUBTRACT.


.ti -4
2 /RANGE
.ti +4
[CLEAN_\]UV__SUBTRACT [Time [Factor]] /FILE FileIn FileCont [FileOut] 
  /RANGE Min Max Type
  
  *** Not yet Implemented ***

  When FileCont is a spectral line UV table, specify over which range
the signal should be averaged to get the continuum visibility. 
Type can be CHANNEL (default), FREQUENCY or VELOCITY


.!-------------------------------------------------------------------
.ti -4
1 UV__TIME
.ti +4
[CLEAN_\]UV__TIME [?|Time] [/Weight Wcol] [/FILE FileIn]

Average in time the current UV data set to reduce the number of visibilities.
Time must be in seconds. If not specified, an automatic guess
is performed based on Nyquist criterium using the 
antenna size and baseline lengths.

With a ? as argument, return the longest reasonable time.
This time depends on the field of view (that can be controlled by
MAP__FIELD) and the requested precision (controlled by MAP__PRECIS).
It is also limited by the UV cell size for beam forming (MAP__UVCELL).

.ti -4
2 /WEIGHT
.ti +4
[CLEAN_\]UV__TIME Time /WEIGHT Wcol

Select the weight column. Default is 0.

.ti -4
2 /FILE
.ti +4
[CLEAN_\]UV__TIME [?|Time] /FILE FileIn [FileOut] [/Weight Wcol]

Work on the specified input (FileIn) and ouput (FileOut) for
the time compression instead of the UV buffer. FileIn must exists.

.!-------------------------------------------------------------------
.ti -4
1 UV__TRIM
.ti +4
[CLEAN_\]UV__TRIM Action [/FILE FileIn [FileOut]]

  Trim the UV data of useless information, according to the Action keyword.
Action can be
.nf
ANY      Remove visibilities that have at least one channel flagged
FLAG     Remove visibilities where all channels at flagged
TRAIL    Remove trailing columns
.fi
  
  The command works on the current UV data set, unless the /FILE option
is present.

.ti -4
2 /FILE
.ti +4
[CLEAN_\]UV__TRIM Action /FILE FileIn [FileOut] 

  Trim the UV data of useless information, according to the Action keyword.
The UV data is taken from file FileIn and written on FileOut (default:
overwrite FileIn).

.!-------------------------------------------------------------------
.ti -4
1 UV__TRUNCATE
.ti +4
[CLEAN_\]UV__TRUNCATE Max [Min]

Truncate the UV data, by removing baselines out of
the specified range Min (default 0) and Max (in meter).

.!-------------------------------------------------------------------
.ti -4
1 WRITE
.ti +4
[CLEAN_\]WRITE EntityName File [Format] [/APPEND] [/RANGE Start End Kind] [/REPLACE] [/TRIM [Any]]

WRITE the entity specified by EntityName on to the specified File.

The "entity" can be a known "Buffer" (e.g. UV, CGAINS, and BEAM, PRIMARY, DIRTY, CLEAN, RESIDUAL, SUPPORT, CCT, SKY, 
see HELP BUFFER for details and a more complete list). In this case, default extensions are .uvt for UV and CGAINS and 
.beam, .lmv, .lobe, .lmv-clean, .lmv-res, .pol, .cct, and lmv-sky respectively for the next ones mentionned above.

The "entity" can also be any SIC Image variable. The default extension is then .gdf.

Format is an optional argument indicating the output file data format (see
HELP WRITE Format) which is otherwise taken from the SET FORMAT command. 

For UV data, the flagged data are written by default. They may
be omitted using the /TRIM option.

WRITE * File can be used to write all modified image-like buffers (EXCEPT the
UV tables) under a common File name. This typically include .beam, .lmv 
and .lmv-clean, but also the .lmv-sky file if the PRIMARY command has been
used after deconvolution.

Options /APPEND and /REPLACE are mutually exclusive, and in general
used with the /RANGE option. They are only valid for the default
GILDAS format.

.ti -4
2 Format
.ti +4
[CLEAN_\]WRITE Name File Format [/RANGE Start End Kind] [/TRIM [Any]]

The 3rd (and 4th) argument of the WRITE command are optional keywords 
indicating the output file data format, which is otherwise specified by
the SET FORMAT command.  Allowed values are
.br
CSV, GILDAS, FITS, FITS VELOCITY, FITS FREQUENCY

FITS format is allowed for UV data and Images (n-D hypercubes), but not for Tables 
like the Clean Component Tables, or self-calibration results because of lack of
suitable FITS convention for such information. 

CSV format (Comma Separated Value, used by most spreadsheets) is for 2-D tables only, 
of limited size (less than 128 columns). WRITE fallbacks to GILDAS format if this 
condition is not matched.

Note also that options /APPEND and /REPLACE are only valid for GILDAS format.

.ti -4 
2 /RANGE
.ti +4
[CLEAN_\]WRITE Buffer File [Format] /RANGE Start End Kind [/APPEND] [/REPLACE]

A range of planes can be specified through /RANGE option. Kind
is the unit of the Start-End values: CHANNEL, VELOCITY, or FREQUENCY.
This is also possible for UV data, except for FITS output format.

The Buffer name must be specified (* is not valid here). 


.ti -4
2 /APPEND
.ti +4 
[CLEAN_\]WRITE Buffer File /APPEND [/RANGE Start End Kind] 

The selected channels are appended to an existing file. 

This is not valid for UV tables, neither for FITS output format.

The Buffer name must be specified (* is not valid here). 

.ti -4
2 /REPLACE
.ti +4 
[CLEAN_\]WRITE Buffer File /REPLACE [/RANGE Start End Kind] 

The selected channels are replaced in an existing file. 

This is not valid for UV tables, neither for FITS output format.

The Buffer name must be specified (* is not valid here).

.ti -4
2 /TRIM
.ti +4
[CLEAN_\]WRITE UV File /TRIM [ANY]

Remove the flagged visibilities while writing. A visibility
is declared "flagged" if all channels in it are flagged, unless
the keyword ANY is present. In this later case, if a single
channel is flagged, the whole visibility is declared flagged.


.ti -4
1 ENDOFHELP
