USAGE:
          xcorr-vs-time [DIRECTIVES] [options] <campaign>
 
 PURPOSE:
          Plot cross-correlation versus time
          by segmenting a campaign. There are two levels of segments,
          segments proper, and subsegments
          Segments are at project level.
          Subsegments divide projects into ~equal-length stretches
          so that x-correlation is based on a roughly constant
          sample size.

          Prepares a time series that can be used as a seismic
          correction to AG drops (under plot/scatter-plot)
 
 RECOMMENDED:
          Finish a sequence of calls for the same project
          before turning to another one (a range of
          in-/out-files is not marked with the project name).
 
 Incomplete:
          Choice of sampling interval for parallel seis
          consistent with xcorr-length?
 
          LIKEG-data needed for parallel SCG
          There is code in ../SCG
 
 DIRECTIVES: (use `+┬┤ as a delimiter between multiple dir's)
 
  xx      - Do only the intro

  SCG     - Generate parallel SCG xcorr's (needs LIKEG-seismo;
            presently deprecated)
  [N]AG   - do with AG data (N : generate new data)
  [N]ZA   - do with seismometer Z-acceleration (N : new data)   
  Z[A]W   - use specific tse-sections to weed out problems
              in gcf-files.

  X       - do the cross-correlation
 
  P       - plot
  PT      - plot only the xcorr-vs-time diagram.
  PS      - prepare scatter plot data and plot.
            Creates also the seismic corrections to the AG data,
            d/ag4sub-${ym}-$dt.ts
  PSO     - only plot scatter (facilitates experimenting
              with -YR option.
  PSA     - only the autocorrelation plot
 
  +GO     - Don't prompt for confirmation.
            With making new segments:

              If you are certain that segmenting was successful,
              the command files from segmenting are copied under
              file names segm-<yymm>.cmd and seissegm-<yymm>.cmd
              Else the program will exit so you can check.
            With X and without +GO you are prompted to check
              calculation of cross-correlation of each segment.
 
  +R      - Re-use the segmentation (else make a new one)
 
  FIT     - Do fitxym test. Calculates a-priori error factors;
              to actually use them you need the -u option.
              The factors are written to a file
              apriori-<ym>.err (ym is 2-dig.year + month + camp.-letter)
 
  STD     - Do fitxym with RMS-derived weights from Seismograms ...
  X+STD+W     ... and, in addition, with the Std Dev's from the AG; then
  +W          ... must be given already at data generation (NZA)

 


 OPTIONS:     (D) = in effect under directive D                [default]
 
  -dur   #n   - segment duration n , in hours (X)                      [6]

  -zadeci <s> - tsf-edit target in ./deci.tse for decimation of
                seism. Zacc  (NZA)                                    [D2]


  -cal   #v   - calibration value for seismometer
(NZA)              [1.0]

  -scutm #n   - cut margin for seismogram in seconds (NZA)           [200]


  -corrl #n   - length for xcorr, in sampling units  (X)             [200]


  -segl  #n   - segment length in AG data file must be longer
                 than n samples (param. m in segmenting.awk) (! +R)  [200]
 
  -wr         - AG-data is weighted residual .wr.ts     
                  (Must be decided from the start and
                  kept for the whole suite of runs) (NAG)         [.ra.ts]
 

  -ey    #y   - use a-priori error y in fitxym -Ey  (FIT)           [15.0]
                  Under directive +W the default is ...              [1.0]

  -ez    #z   - error in seism. Zacc = z├ŚRMS (X+STD)                [/10.]
 

  -u          - multiply a-priori error with the factors
                  determined in the fitxym test (P PS)     [use const. #y]        
 
  -sel        - Do scatter plots on *selected* segments (P PS). 
                  The segment numbers are expected in a source
                  file named  corrfs-sel-${ym}.set
                  Here is a recipe to select by RMS-reduction:

                select4scatplot <ym> 0.03
                  (script is still more or less a stub)
 
  -YR #yr #tix  
              - Range -yr/yr and tick specification for scatter
                  plots (AG-values are along the y-axis).
                  (P PS PSO)
.

  -force-deci - In effect in autocorrelation plot (P PS PSA):
                  Force decimation. Applicable to sparse files,
                  i.e. those that have a basic sampling interval
                  that is shorter than the AG's drop interval.
                  This option must be accompanied with environment
                  parameters:
                setenv ACV_D #n
                setenv ACV_R `calc #n -1`
                  See autoc.tse,DECI .
                  The first setting specifies the decimation rate,
                  the other one the sample-and-hold length of the
                  REPAIR command.

   [N]Z[A]W instructions:
                File ~/Seismo/gcf/weed.tse contains sections with targets WEED${ym}ap${q} with
                instructions to e.g. delete a range of samples.  ${q refers to a  file segment; code with two decimal places, e.g.
                    TSF EDIT WEED1606ap03
                The updated file replaces the original; thus you need to do this only once for every directive  NZA 
 
 FILES:
             - (possibly incomplete. Many *.log files, also in
                ~/tslist-logs/ . Result files o/*.rsl .
               The list below shows files that are re-imported

               ${ym} is the shortname of the campaign
 
                  segm-${ym}.cmd  - ... and ...
              seissegm-${
ym}.cmd  - segmentation parameters.
                  agfs-${ym}.set  - file names for segments of AG data.
                  agws-${ym}.set  - file names for segments of AG std-devs.
                corrfs-${ym}.set  - file names for subsegments (mostly).
           corrfs-take-${ym}.set  - selection of successful rms reductions.
               facsubs-${ym}.set  - the regression coefficients.
          regress_test-${ym}.rsl  - the results of fitxym under directive FIT.
            rms-reduct-${ym}.rsl  - the rms reduction (positive means success).
           seiscut-mrg-${ym}.set  - tslist options to cut seism file. 
                seisfs-${ym}.set  - file names for segments of Seis data
                                    (e.g. seisfs-1502b.set)
.
 
 EXAMPLES:
           This is a package of 3 commands:
           (1)   xcorr-vs-time NAG+NZA  -dur 3 201106b
           (2)   xcorr-vs-time AG+GO    -dur 3 201106b
           (3)   xcorr-vs-time X+P+R+GO -dur 3 201106b
 
           add these for realistic a-priori values
  Compute  (4)   xcorr-vs-time FIT+R      -dur 3 201405a
  Use      (5)   xcorr-vs-time P+R -u     -dur 3 201405a
  or       (4')  xcorr-vs-time FIT+P+R -u -dur 3 201405a
 
           Processing with standard deviations:
           (1)   xcorr-vs-time NAG+NZA+STD+W  -dur 3 201405a
           (2)   xcorr-vs-time X+R+STD+W+GO   -dur 3 201405a
           (3)   xcorr-vs-time FIT+R+STD+W+GO -dur 3 201405a
           (4)   select4scatplot 1405a
           (5)   xcorr-vs-time PS+R+STD+W+GO -u -dur 3 -sel -YR 800 a200f50 201405a