HOW TO make spectral plots, e.g. combining MEM and PSP


Spectral data is conveniently produced with  sasm03 and stored in binary files,
the basis of MEM-spectra as the PEF-filter bank,
the PSP spectrum directly in an sp-file (to be processed with splist for plotting). See the example sasm03-lap-ochy.ins

For the step from the PEF-bank to MEM spectra tslist/tsfedit can be used. Here is an example with comments (in pink)

File manymemsp.tse :
setenv PARAM001 92 # pef-order        #  selects a set of PEF's with decreasing order
setenv PARAM002 25 # pef-order
setenv PARAM003 10 # pef-order
setenv PARAM004 08 # pef-order
setenv PARAM005 06 # pef-order
setenv PARAM006 04 # pef-order

# ...
setenv LOOPL 6                        #  sets the number of different PEF's

tslist _16348 -B2017,1,1 -r1. -E manymemsp.tse,M -I | tee tslist.log
echo "Log saved in tslist.log"
exit

# the label for the MEM-segments in the file o/manymemsp.sp is RSP (hard-wired in tsfedit).
# splist -nORDER001 o/manymemsp.sp RSP


TSF EDIT MEMPSP
OPEN 31 < o/manymemsp.sp
LOOP ${LOOPL:[1]} <101>
PEF U=41 F=d/grav-ra-1h.pef L=${PARAM###LOOP#}
REWIND 41
MEMSP 16384 U=-0.8,Q OMEMSP=31,ORDER${PARAM###LOOP#}
ENDLOOP <101>
END
N.B. the MEMSP option string  U=-0.8,Q
,Q    
: request abs-square (not absolute values)
U=-0.8
: restore the attenuation of the diff-filter in sasm03


Exec using
source manymensp.tse

A csh-script for plotting (still raw and widely hard-wired) is here (~/Ttide/Oload/plot-psp-pefs)
#!/bin/csh

set ps=manymems.ps

set labs = ( `splist o/manymemsp.sp X | awk -F'>' '/REAL/{gsub(/</," ",$0) ;print $6}'` )

set cols =  ( `makecpt -Chaxby -T0/$#labs/1 | awk '/^[0-9]/{print $2"/"$3"/"$4}'` )

psbasemap -R0.001/12/-20/100 -JX8l/5 -Ba1f3:"Freq. [cyc/d]":/a20f5:"Power [dB]":WeSn \
          -X1.5 -G200 -K >! plot/$ps
#
# Plot the PSP, first error bars, then the curve itself
#
splist -f0 -EC -q -cpd -adB d/grav-ra-1h.sp PSP |\
   psxy -R -JX -Ey0.02/3/160 -K -O -W2/0 >> plot/$ps
splist -f0 -q -cpd -adB d/grav-ra-1h.sp PSP |\
   psxy -R -JX -K -O -W2/0 >> plot/$ps
#
# Plot the MEM's
#
set y=0
@ i = 0
foreach l ( $labs )
@ i ++
   splist -n/$l -f0 -q -cpd -adB o/manymemsp.sp RSP |\
      psxy -R -JX -K -O -W4/$cols[$i] >> plot/$ps

   set lo=`echo $l | sed 's/ORDER//'`
   set y=`echo PEF l=$lo | addlegend -y$y -d-1 -W4/$cols[$i]`
end

pslegend -y$y -d-1 -X6 -Y`calc "4-0.1*$#labs"` -JX2/`calc "0.2+0.1*$#labs"` >>   plot/$ps

cd plot
ps2png -rr -m -d 144x144 -o ~/www/4me/toe/ $ps

exit
The diagram can be seen here.


sasm03 example

sasm03 produces a PEF-bank up with to order lpef-1 with increment 1. 
setenv URTAPFD 090615-SLDEND
setenv URTAPDT 1h
setenv RT ra


sasm03 @ sasm03-lap-ochy.ins
Showing only the essential content in the present context
21 ^ ${IDIR:[o]}/g${URTAPFD}-${URTAPDT}${MRK:[]}.${RT:[wr]}.ts
   C
   C the PEF-bank:
41 < d/grav-$RT-1h.pef                                           
42 B ${ODIR:[o]}/g-OPNEND-1h${MRK:[]}.${RT:[wr]}.psp
43 B ${ODIR:[o]}/g-OPNEND-1h${MRK:[]}.${RT:[wr]}.memsp
   C
   C PSP, the sp output

52 < d/grav-$RT-1h.sp
   Q

 &param
   lpef=93
   dff1=-0.8d0

   nmems=16384

 &end
.bye