HOW TO make noise


You have:
    A time series, e.g. a gravity residual

You want:
    Many time series with the same power spectrum


Have a look at script make-pef-noise.

The following instructions are for hand-on work (if make-pef-noise is promising too much).

Here's what to do:
cd ~/Ttide/SCG
Look at the instruction file sasm03-openend.ins
edit and set the environment parameters as required; e.g.
setenv URTAPFD 090615-OPNEND
setenv FDATE 090615
setenv URTAPDT 1h
setenv RT ra
setenv MRK -ochy-wwf
setenv IDIR tmp-ochy
setenv ODIR tmp-ochy
so that the input file, symbolically
${IDIR:[o]}/g${URTAPFD}-${URTAPDT}${MRK:[]}.${RT:[wr]}.ts 
is found under real-world name
tmp-ochy/g090615-OPNEND-1h-ochy-wwf.ra.ts
Run the power spectrum job, generating PEF-filters up to order pef_order (Namelist)
sasm03 @ sasm03-openend.ins
Generates the PEF filter bank, here named  tmp-ochy/tmp-ochy-wwf.ra-1h.pef 
To check the MEM spectrum of the highest filter order,
plot-memsp -O ~/www/4me/ -T "MEM-PSP Resid 1h pre-filtered 0,-0.8" -d cyc/day \
           tmp-ochy/g
-OPNEND-1h-ochy-wwf.ra.memsp   # [sic]
Now you can make noise. First a pilot to detect the RMS
setenv PEFBANK tmp-ochy/tmp-ochy-wwf.ra-1h.pef
set ndata=`tslqn tmp-ochy/g090615-OPNEND-1h-ochy-wwf.ra.ts`
set begdate=`tslp2d -, F
tmp-ochy/g090615-OPNEND-1h-ochy-wwf.ra.ts`
set seed=1

make-pef-noise $ndata,
$seed 90 -BH$begdate -r1. -o tmp-ochy/s090615-OPNEND-1h-ochy-$seed-pef90.ts
tslq tmp-ochy/s090615-OPNEND-1h-ochy-1-pef90.ts | fgrep RMS-dev
 <Main-->>>           RMS-dev=   1.5838E+00 from column  1
tslq tmp-ochy/g090615-OPNEND-1h-ochy-wwf.ra.ts | fgrep RMS-dev
 <Main-->>>           RMS-dev=   5.3758E+00 from column  1

Now you can go into production:
set scale=`calc 5.38/1.58`
foreach seed ( `fromto -f "%3.3i " 1 100` )
make-pef-noise $ndata,$seed 90 -BH$begdate -r1. -SO$scale -o tmp-ochy/s090615-OPNEND-1h-ochy-$seed-pef90.ts
end


An advanced example:     Use the results to obtain the width of uncertainty in a cross-correlation analysis

Have a look at ~/Ttide/SCG/stackextremes.tse

This computes sliding-mean gain data (24h interval) between a gravity residual and jpb-hyd and jpb-oce predictions, looking for residual signal due to instationarity (or seasonal variation of prediciton accuracy):

setenv XCORRMOV 24
setenv XCORRLEN 2688
setenv XCORRFILE ~/TD/jpb-hyd/OS09166h-erain-1h.ts
tslist tmp-ochy/g090615-OPNEND-1h-ochy-wwf.ra.ts -I -E slide-xcv.tse,S -o tmp-ochy/moving-gain-ra-hyd.ts
tslist tmp-ochy/g090615-OPNEND-1h-ochy-wwf.ra.ts -I -E slide-xcv.tse,R -o tmp-ochy/moving-rms-ra-hyd.ts
tslist $XCORRFILE
-I -E slide-xcv.tse,R -o tmp-ochy/moving-rms-hyd.ts
And now the same with the artificial data:
foreach seed ( `fromto -f "%3.3i " 1 100` )
   tslist tmp-ochy/s090615-OPNEND-1h-ochy-$seed-pef90.ts -I -E slide-xcv.tse,S -o tmp-ochy/moving-gain-$seed-hyd.ts
   tslist tmp-ochy/s090615-OPNEND-1h-ochy-$seed-pef90.ts -I -E slide-xcv.tse,R -o tmp-ochy/moving-rms-$seed-ra.ts
end

setenv XCORRFILE ~/TD/jpb-oce/OS931612-ecco1-1h.ts
tslist tmp-ochy/g090615-OPNEND-1h-ochy-wwf.ra.ts -I -E slide-xcv.tse,S -o tmp-ochy/moving-gain-ra-oce.ts
tslist $XCORRFILE -I -E slide-xcv.tse,R -o tmp-ochy/moving-rms-oce.ts
foreach seed ( `fromto -f "%3.3i " 1 100` )

   tslist tmp-ochy/s090615-OPNEND-1h-ochy-$seed-pef90.ts -I -E slide-xcv.tse,S -o tmp-ochy/moving-gain-$seed-oce.ts
end
Compute bracketing extremes of the gains that would fit random noise:
foreach ochy ( hyd oce )
   setenv OCHY $ochy
   setenv EXTYPE MAX
   tslist tmp-ochy/moving-gain-001-hyd.ts -I -E stackextremes.tse,E -o tmp-ochy/moving-gain-max-$ochy.ts
   setenv EXTYPE MIN
   tslist tmp-ochy/moving-gain-001-hyd.ts -I -E stackextremes.tse,E -o tmp-ochy/moving-gain-min-$ochy.ts
end
Now you can plot the -oce- sliding-gain curve with the min and max curves as a tube of insignificance, and likewise for the -hyd- case. With 100 noise innovations you have a level of confidence of 0.99. You could narrow the significance tube by scaling the min and max curves with 2/3.
 


.bye