USAGE:

        splist [options] file label1 [{label2|---]

 PURPOSE:

        Reads BIN-sp files written with OUTSP (ufiosps.f)
        and optionally converts admittance and phase by Hilbert means.
        Label1 usually addresses the complex co-spectrum.
        Label2 is optional; usually it addresses the confidence.
        `---´ is an alternative to an empty label.
        A file may contain a series of spectra, and their types (real or
        complex) and lengths may appear in any order. Let's call them
        Segments.
        Use
           splist file x x
        to get an inventory of a file with multiple spectra.

        Segments will normally carry a short comment, 2*8 characters long.
        The comment depends on how the main program's make use of it; it may
        just be a dull reminder of the job's id (e.g. the ins-file) or it may
        posit a string to identify specifics (e.g. in a series of
        parametrized spectra). The comment can be targeted for input
        (see option -n).

        For causality analysis, use the file that sasm06
        saves under option qsavesp=.true. ( -> unit 51)
        and request CSP PSX .

        For admittance and co-phase use the files assigned by
        iun_zadmit and iun_zphase. Request CAD ADC .

        Many more processing options could be imagined.

        Changes 2021-10-30, temporary version in
          ~/sas/p/mt/evolv/splist-restored-211030.f and ~/bin/splist.x
        old version in
~/bin/safe/splist-211029
        and old man page here
        Repair work after a destructive event maybe still incomplete.


 OPTIONS:

  -DBG[#v]   - Debug with msglevel v in sas-subroutines and openf
               At startup, msglevel is 2

 -w <name>   - Ascii output to this file. Default is STDOUT.

 -n<target>  - Input the segment marked with target in the comment part.
               Must match the comment at position 1 and through the length of target.
 -n~
<target> - Liberal match: anywhere in the comment.
 -n~<trg1>/<trg2>
             - Match trg1 at position 1 and trg2 at the end of the comment.
               A ->tag<>comment<- like ->FSP<>48,2.500><7.80e-2 <- can be matched with
               splist -n~48,2.5/7.80 <file> FSP
 

 -n/
<target> - Liberal match: anywhere in the second part of the comment.ll
               Only one of these sub-options can be specified. No wildcards as of yet.

   -I        - in retrieval of a segment, print the file information.
   -N[#n]    - print the n first output records. Default n=0.

             For output:
   -q[#m]    - quiet, print only data. Set message level m for openf, default = 3

   -s[#w]    - smooth ringing in gain and phase spectra weighing neighbours
with w
               (default=0.5). 
 
-scia      - auto-scale on input with the value at zero-frequency.
 
-sci[/]#x  - scale on input with x or, with `/´, 1/
               (acts on both file sections; might need differentiation).

   -F<fmt>   - the format part for spectral columns. Default = 1p,3e12.4
  -FR<fmt>   -
the format part for frequency. Default = 1p,e12.4

  
    -C       - Include the confidence in the output, beware context

    -a       - compute admittance (or absolute value)
    -alg     - ... show as 10log
 -aL  -adB   - ... in neper or decibel
    -E       - ... for psxy  -Ey option.
    -C       - with -aL or -adB , recalc confidence logarithmic
    -EC      - produce value+error bar series based
               on statistics info in file header.

    -EPW     - in the case of power spectra, the statistics info
               in the file header will probably contain zero
               (i.e. unset) confidence limits; however, confidence
               level and degrees-of-freedom are usually available.
               Then, use this option to calculate the limits.

    -p..     - like -a.. , assume input in power units, however

    -EH      - like -C but for coherence: use confidence information
               (sasm06: tag1::tag2 = KOH::KOC )
               to produce value+error bar series.

   -vi[#lvl] - drop insignificant values in print (cfd < lvl, default 1e-10)
   -ri
[#lvl] - replace confidence values cfd > lvl with zero (default 1e-10)
               The lvl parameter in -iv and -ir is identical.
 
  -cfl
[#lvl] - limit confidence value to lvl in print (default 1e16)   

 -Pdopt  -Propt   
             - compute phase in degrees resp. radians.
Additional options:
               j   - conjugate (invert the values)
               b   - issue break symbols for GMT at phase jumps > half circle
               /#v - cut circle at 2π×v   (at the end of the option string!)
                     [default=0.5]

    -W       - weed out insignificant values
    -B#v     - floor for amplitudes in logarithms, default = 1.d-10

 
-f[0][l][n] - 0: skip the zero-frq
               n: skip the Nyquist frq.

               l: print 10log(frq) Resets format to 'f10.6'

 
-mHz -Hz -cpd -cph
             - first column gives frequency; select scale (default is number).

             For some spectral processing:

    -PHS     - compute phase from gain using Hilbert tr.,
               2-column output, 2nd is standard phase.

    -S#t     - simulate a shift of time with t seconds (?).

 
-dfu#h  -dff#h 
             - for power spectra (tag(1:)='PS', options -a.. or -p..:
               -dfu: "un-filter" = restore spectrum for the effect of a
                     1-term difference filter (1,h),
-1 < h < 0
               -dff: apply the filter             

 -[anti]causal[-sp]
             - compute (anti-)causal part of filter (-spectrum),
               (-antica and antica-sp will suffice)

 
-[anti]causal-spf
             - compute (anti-)causal spectral factor.
               (antica-sp will suffice)

 -WF[m,]n <filename>
             - output a Wiener filter for lags m ≤ in
               Default m = -n

  -cep       - compute clog(zsp)
  -cepi      - compute cepstrum, i.e. FFT-1{
clog(zsp)}
  -cepi:#b,#e
             - use only bins b to e for cepstrum 



 Find out labels:
              splist file X X

 EXAMPLES:

   (1)    After sasm03 with qsavesp=.true. in namelist, read the file that
          sasm03 writes on unit 51. Assume here: sasm03.sp

           Read power spectrum in dB:

              splist -Hz -pdB    sasm03.sp PSX
           Generate confidence information, for use in psxy -Ey:
              splist -Hz -pdB -E sasm03.sp MEC PCF

   (2)    A lot of use is made in ~/Seismo/gcf/SCG/cal-seis

   (3)    After sasm06, first an admittance spectrum's estimates, and then the series
          for plotting error bars:
cd ~/Seismo/gcf
splist o/zadm-3V37_A150.sp X X
 <OPENF->3> 21:^ o/zadm-3V37_A150.sp                  -
 <getsp->d> Header:  4800 CAD @@               T  3.5673E-03  5.6064E+02  2.7778E-05  0.0000E+00  0.0000E+00  9.5000E-01
 <GetsSt>>> Unit 21 tag CAD. VarRedFac=    0.0036, DegFreed=    560.64
 <GetsCn>>> conf.limits:   0.0000E+00  0.0000E+00 lvl: 0.950 0.950
 <Main-->>> read done, n=  4800 dt=  2.7778E-05 stats: T  3.5673E-03  5.6064E+02 conf:  0.0000E+00  0.0000E+00 lvl:0.950
 <GETSP->>> CMPX #21:o/zadm-3V37_A150.sp - contains ->CAD<>@@      ><        <- bins 0... 4800
 <GETSP->>> REAL #21:o/zadm-3V37_A150.sp - contains ->ADC<>@@      ><        <- bins 0... 4800
 <GETSP->>>  EOF #21:o/zadm-3V37_A150.sp


splist -q -adB    -Hz -f0 o/zadm-3V37_A150.sp CAD
splist -q -adB -E -Hz -f0 o/zadm-3V37_A150.sp CAD ADC
          ... and the phase spectrum with break symbols at jumps
splist -q -Pdb    -Hz -f0 o/zadm-3V37_A150.sp CPH APH
          ... and a power spectrum using the statistics in the file header
splist -q -pdB -EPW -Hz -f0 gcf+sg/sg-zacc-1s.psp PSX

   (4)    Select a section on behalf of the comment
h[hgs]~/Ttide/SCG> splist o/manymemsp.sp X X
 <OPENF->3> 21:^ o/manymemsp.sp                       -
 <getsp->d> Header:  4096 RSP ORDER001         T  1.0000E+00  2.0000E+00  1.0000E+00  2.7108E-01  3.9498E+01  9.5000E-01
 <GetsSt>>> Unit 21 tag RSP. VarRedFac=    1.0000, DegFreed=      2.00
 <GetsCn>>> conf.limits:   2.7108E-01  3.9498E+01 lvl: 0.950 0.950
 <Main-->>> read done, n=  4096 dt=  1.0000E+00 stats: T  1.0000E+00  2.0000E+00 conf:  2.7108E-01  3.9498E+01 lvl:0.950
 <GETSP->>> REAL #21:o/manymemsp.sp - contains ->RSP<>ORDER001><        <- bins 0... 4096
 <GETSP->>> REAL #21:o/manymemsp.sp - contains ->RSP<>ORDER002><        <- bins 0... 4096
 <GETSP->>> REAL #21:o/manymemsp.sp - contains ->RSP<>ORDER003><        <- bins 0... 4096
 <GETSP->>>  EOF #21:o/manymemsp.sp


splist -nORDER002 o/manymemsp.sp RSP

   (5)   Coherence, a) the estimates, b) the confidence intervals for GMT psxy -Ey...

          splist -q -cpd -f0     o/bprios-ochy.psp KOH
          splist -q -cpd -f0 -EH o/bprios-ochy.psp KOH KOC

   (6)   MEM spectra from sasm03

          splist tmp/tmp-monitor.memsp x x
 <OPENF->3> 21:^ tmp/tmp-monitor.memsp                -
 <getsp->d> Header:  3600 MEM PEFORDER00000390 T  3.4092E-01  5.8665E+00  2.7778E-04  4.1206E-01  4.9707E+00  9.5000E-01
 <GetsSt>>> Unit 21 tag MEM. VarRedFac=    0.3409, DegFreed=      5.87
 <GetsCn>>> conf.limits:   4.1206E-01  4.9707E+00 lvl: 0.950 0.950
 <Main-->>> read done, n=  3600 dt=  2.7778E-04 stats: T  3.4092E-01  5.8665E+00 conf:  4.1206E-01  4.9707E+00 lvl:0.950
 <GETSP->>> REAL #21:tmp/tmp-monitor.memsp - contains ->MEM<>PEFORDER><00000390<- bins 0... 3600
 <GETSP->>> REAL #21:tmp/tmp-monitor.memsp - contains ->MEM<>PEFORDER><00000300<- bins 0... 3600
 <GETSP->>> REAL #21:tmp/tmp-monitor.memsp - contains ->MEM<>PEFORDER><00000250<- bins 0... 3600
 <GETSP->>> REAL #21:tmp/tmp-monitor.memsp - contains ->MEM<>PEFORDER><00000200<- bins 0... 3600
 <GETSP->>> REAL #21:tmp/tmp-monitor.memsp - contains ->MEM<>PEFORDER><00000150<- bins 0... 3600

          splist -n/0390 -q -pdB -mHz tmp/tmp-monitor.memsp MEM