if ("&1 ".eq."? ").or.(pro%narg.eq.0) then
  SAY " @ self-polar Name"
  SAY " "
  SAY "     Compute and Apply Self-calibration to a Full polarization data set."
  SAY " "
  SAY "  First, split the (UVT or UVFITS) data file that contains 4 polarization states into"
  SAY "     4 Gildas UV tables, one for each of the Stokes parameters I,Q,U,V"
  SAY "     Naming convention applies: the input name is appended by -S where S is Stokes"
  SAY "     parameter of the data, any of I,Q,U,V"
  SAY "  Then, compute self-calibration from Stokes I"
  SAY "  Apply it also to Q,U,V data"
  return
endif
!
CATALOG               ! No catalog, no Line emission
IMAGER\PIPELINE ?     !     " Setup pipeline"
@ stokes-split &1     ! "Split the X+Y (XX,YY,XY,YX) UVFITS file into I,Q,U,V Stokes UV tables"
IMAGER\PIPELINE organize   !  " Move UV tables to RAW/"
sic find *.uvfits 
if (dir%nfile.gt.0) then
  sic mkdir UVFITS
  SIC\SYSTEM " mv *.uvfits UVFITS/"
endif
SIC\SYSTEM " mv RAW/&1.uvt ./"  !   "Remove the X+Y UV table from RAW/"
!
! Select the I image for self-calibration
let all%filter *-I
IMAGER\PIPELINE select
IMAGER\PIPELINE compute
!
! Apply self-calibration solution to I,Q,U,V data
let all%filter *
IMAGER\PIPELINE find
IMAGER\PIPELINE select
IMAGER\PIPELINE collect
IMAGER\PIPELINE apply
! Image every thing consistently
IMAGER\PIPELINE image
PIPELINE SAVE
!
sic dir MAPS
sic find *.lmv-clean
for fich /in dir%file
  define head a 'fich' read
  if a%rms.eq.0 then
    read clean 'fich'
    statistic clean
    write clean 'fich'
  endif
  dele /var a
next
sic dir ..
!
MAP_POLAR MAPS/s-&1 +C.lmv-clean /COMPUT 6
MAP_POLAR /BACK FRACTION
!MAP_POLAR s-&1 +C.lmv-clean /BACK F


