%N miniflip %F $MIR/src/subs/calphase.for
%D Flip phases into a continuous string
%: calibration, line up phases
%P lgm
%B
      SUBROUTINE miniflip(npts,phas,flips)

      INTEGER npts, flips(*)
      REAL    phas(*)

   Input:
       npts:   Number of points in phases array
       phas:   phases to be played with in radians

   Output:
       phas:   output phases nicely unwrapped
       flips:  record of number of 2pi flips applied to each point

   miniFlip attempts to correct the phases for phase wrapping
   It uses vector averaging, and hence needs to be supplied
   with an array specifiying how vector averaging is done.
   The source code is full of witty comments how it really
   works.
