USAGE:
        resids directives [options] begin-yyyy mm dd  end-yyyy mm dd
OR
        resids directives [options] filename
 
PURPOSE:

        Create MC-file from GGP 1-min data: GRAV_VAL, BARO_VAL, GRAV_PRED
        Optionally output the residual using the coefficients from
        t/urtap.trs and t/urtap.prl
        Optionally plot the time series GRAV, GRAV-PRED, and GRAV-BARO,
 
In the second form, begin and end dates are taken from the specified file.

!!! UPDATE: shocktable default is IGNORE. Specify directive s to use an old one,
            directive n to create a new one. 
 
DIRECTIVES:
 { - | [p] [x[P]] [o[n]] [d] [e] [P[P]] [T] [a] [r] [z]} 
                  no blanks!
                  - p:  plot
                  - x:  prepare data (observations:
                        gravity, barometer, and predicted tides
)
                  - xP: prepare data with polar motion and reduce.
                  - P:  reduce polar motion
                  - PP: prepare new polar motion and reduce
                  - T:  compute new predicted tide, copy
                        gravity and barometer from earlier.

                  - d:  use drift parameters from exp.tse
                  - e:  prepare new drift parameters in newexp.tse
                  - o:  output residual to .ts
                  - os: use shocktable newshocks.tse
                  - on: make a new shock table
                  - a:  ascii output of residual
                  - r:  ascii output of sliding rms
                  - z:  show recently created resids files
 
OPTIONS:
 -d d[,m]       - decimate using deci.tse at label d with
                  move m. A prior  setenv MOVE m  will not be changed
                  with this procedure's default. If you like the default,
                  do    unseat MOVE     first before resids.
                  Remember that the label in deci.tse is thought to
                  correspond with the decimation rate.

                  Default MOVE = 14 which fits d = 10 (?)
 
 -s scale       - rescale predicted tides. Default 1.0d0
                  Typically, if the tidal analysis ran with
                  scale_y=-776.014, then -s/-776.014 would be appropriate.
 -s /CAL          rescale predicted tides to Volt using the
                  calibration value of the -c option.

 -p { path | =delta }     
                 - delta factor for polar motion. Default = 1.16
                   If a path is given, take the POLM result from path/urtap.prl

 
 -c { caldir | =value | ready | READY }
                - the top level directory under which the calibration
                  results are found: $caldir/o/scg-cal.prl . Default: ./cal
 -c =value      - a specific value, e.g. =-776.014
 -c ready         Special value 'ready' ('READY'): the series are already in nm/s^2
 
N.B.:             Program does auto-backup newexp.tse to oldexp-$date.tse under directive e
                 
If drift determination fails, the reason could be that
                  Polar motion was not handled correctly.

FILES:
 Created:         d/MC${yy}${mm}-${deci}m.ts       upon directive  x or T
                 
d/MC${yy}${mm}-${deci}m.ts-bup   upon directive  T        (backup)
                  d/pm${db}-${deci}m.ts            upon directives xP or PP
                  ./newshocks.tse                  upon directive  n
                 
./newexp.tse                     upon
directive  e
                  ./oldexp-`date +%Y%m-%H%M%S`.tse upon directive  e        (backup)
                  d/r${yy}${mm}-${deci}m.ts        upon directive  o and not a
                  d/r${yy}${mm}-${deci}m.tsf       upon directive  a

                  d/rms${yy}${mm}-${deci}m.ts      upon directive  r and not a
                  d/rms${yy}${mm}-${deci}m.tsf     upon directive  ra
                  plot/MC${yy}${mm}-${deci}m.ps    upon directive  p
                 
~/tslist-logs/*.log (several; associated with most .ts-files above)

 
 Temp:            tmp.dat, tmp.txt, and tmp.ts
 
 Required input:  t/urtap.trs                 Tide table created by urtap,
                                              executed in
~/Ttide/SCG/
                                              stored in ~/Ttide/SCG/t
                                              favourably by symbolic link

                  t/urtap.prl                 Tide result sheet ...

                  [$caldir/o/scg-cal.prl]     Calibration result sheet,
                                              upon -d caldir

                  MON_o054/GW*.GGP            1-min observation files

 
PROCEDURES REQUIRED:
 Shell            csh tcsh  
 Home-grown:      ecq, fromto, JDC, tslist, urtip & run_urtip, plot/hans-mcplot.env & tsplot

EXAMPLE:
                    resids Ppod -s /-776.014 d/MC0906-1m.ts
 
                  Decimation: no (default -d 1,0), Polor motion and drift reduction: re-use
                  Tide analysis has been made in physical units (-776.014 V/nm/s2
                  Temporal scope is taken from file
d/MC0906-1m.ts
 
                    resids xPPTeon -d 10 -c cal0911/ -s /-776.014 2009 06 15 2010 04 22 > ! resids-100422.log