JohnWStockwellJr / SeisUnix

The CWP/SU: Seismic Un*x Package - a free open seismic processing, research, and educational software package. Please seek distribution gzipped tar files at https://wiki.Seismic-Unix.org not the Github version.
https://wiki.Seismic-Unix.org
Other
266 stars 123 forks source link

FIX: algorithm error on RMS calculation #142

Closed pablombarros closed 1 year ago

pablombarros commented 1 year ago

Sumax calculation for RMS is not working properly. The algorithm should add tr.data[i]2 over all samples of each trace to rmssumsq (and over the whole file to grmssumsq), but it actually resets those sums on each iteration to tr.data[0]2. A sample calculation shows the error:

# suspike creates a vector [0,1,0,0], with rms=sqrt(1/4)=0.5
$ suspike nt=4 ntr=1 nspk=1 ix1=1 it1=2 offset=0 | sumax mode=rms verbose=1 
Using native byte order SU data format w/o XDR.
1 0.000000e+00
global rms = 0.000000e+00

After this fix, the calculation is correct:

suspike nt=4 ntr=1 nspk=1 ix1=1 it1=2 offset=0 | sumax mode=rms verbose=1
Using native byte order SU data format w/o XDR.
1 5.000000e-01
global rms = 5.000000e-01