TSLIST cycle slip analysis

tslist can call subroutine cycleslips (in ~/sas/p/cycslips.f )

         call cycleslips (x(1,1),x(1,2),ndim,n,lmc-1,mccycsl,t1,dt
     &,                   dxcycsl,mcycsl,ncycsl
     &,                   qstrong,cycthresh,iucycsl)

optionally with an output file opened before call.

The purpose is to increase correlation between series  X1  and  Xn  and reduce variance of  X1  by adding  m δ  to ordinates of  X1.

Note that the call transmits  x(1,2) as the invariable series, but since the dimensions of  X are passed too, the other columns of  X  beyond 2 are also accessible.
There are  lmc-1  such columns after we've imported  lmc  columns from an mc-file.  mccycsl  may limit the extent to less than lmc-1 columns
Thus we can maximise an expression that is based on the correlation of  X1  with a range of series.

The parameters that guide the cycleslip hunt are  qstrong  (logical) and  Th := cycthresh  (threshold, floating-point).
Let
      ΔC := Th / n
      Th' := σ2 Th / n

Significant gain in correlation is supposed when 
    
(w-1) Sum j (C 'j - Cj)  - w (V ' - V) / V  > ΔC
where Cj and j is the correlation between X1 and Xj, before respectively after adding a cycleslip m δ to X1,
and variance before and after adding a cycle slip is V and V ', respectively.

Always demanded is that V ' < V

A strong demand is Min j C'j > s

Thus, a cycleslip is accepted if it decreases variance and if it improves the correlations by at least  ΔC

The weight factor w can be used to balance the gain in correlation with the decrease of variance,
honoring the impact of variance in proportion to w.


OPTION SYNTAX:
To be coded in a continuous string; no blankspace!

-CYCSLIPd,m,n[,C=c][,T=t][+S[=s]][+W=w][+R=r][+A][+Z][#u:file]

  d          
cycle size  δ                                                    [no default]
  m,n         cycle range m δ .. n δ                                         [no default]
  c           number of columns                                           [all available]
  t           threshold
  +S          strong criterion                                                    [weak]
 
+S=s               strength s (the smallest improvement on correlation
                     at any point in time and in any channel has to exceed s       [0.0]
 
+W=w        honour the decrease of variance at any point in time with weight w   [0.0]
 
+R=r        hard limit for cycle range, |k δ | <  r                                 [any]
  +A          in print, include all samples (gaps and zeroes)
 
+Z                    the zero samples                       [only the nonzero values]

  #u:file     unit number and file name. Specify u to two digits                    [no]
              Specify  #06:  for stdout.



EXAMPLES

tslist tmp.mc -L'A|R' -L'S|Z' -L'S|E' -L'S|N' -I -CYCSLIP10.0,-2,2,T=0.
Three columns by default, any improvement on correlation is good.

cd ~/Seismo/gcf/AG
tslist saxdata/ag-sax-sv.mc -L'A|R' -L'SV|Z' -L'S|E]',Rwd -L'S|N' -I \
      -CYCSLIP7.75,-5,5,T=0.001+S=-0.0001+W=0.2,O#51:cycsl-ZEN-7.75.dat \
      -I -o o/ag-dropres-cyc-r-5,5-s7.75.ts

 <Cycsli>>> Threshold:  1.0000E-03  4.1701E-07 Var-weight:  2.0000E-01 Strong: T  -1.0000E-04
 <CycSli>>> SLIPCOUNT, CYCSIZE:    627  7.7500E+00
 <CycSli>>> CORRC before/after:   0.148411    0.294032    1
 <CycSli>>> CORRC before/after:  -0.138275   -0.300293    2
 <CycSli>>> CORRC before/after:   0.209073    0.371217    3
 <CycSli>>> RMS   before/after:   1.4983E+01  1.2941E+01
 <CycSli>>> Frequency of cycle slips of order  -5 ..  5
 <CycSli>>> SLIPS: -5: 14  -4: 34  -3: 34  -2: 67  -1: 167  0: 1771  1: 156  2: 83  3: 34  4: 26  5: 12
 <CycSli>>> Frequency of criteria  0 .. 8 taken:
 <CycSli>>> CRITS: 0: 486  1: 1281  2: 4  3: 627  4: 0  5: 0  6: 0  7: 0  8: 0
That CRITS thing isn't really final.

Add the cycleslips to the data:
cd ~/Seismo/gcf/AG
#
# One method
tslist ${SAXD}data/${SAXD}-s${lag}.mc -L'A|R' -L'S|'$COMP -I \
       -CYCSLIP${cyci},-2,2,O#51:cycsl-${COMP}.dat \
       -O:`label AG,CYC${COMP}` ${SAXD}data/ag-dropres-cyc.mc | m

# Another method
tslist saxdata/ag-sax-sv.mc -L'A|R' -L'S|Z' -L'S|E' -L'S|N' -I \
       -CYCSLIP10.0,-2,2,T=0.,O#51:cycsl-ZEN.dat

setenv FNSUB saxdata/ag-sax-sv.mc
setenv LABSUB 'A|R'
setenv VALSUB 1.0
tslist cycsl-ZEN.dat -g'i4,2i3,i4,2i3,i4,f16.0>0' \
       -k4 -C4 -Esubts.tse,SUBLUV -I