2D despiking#
Despike SEG-Y file(s) using a 2D moving window function.
Description#
Remove (single trace) noise bursts from seismic data using an user-defined moving 2D window (time x ntraces) approach:
- Define moving 2D window (time x ntraces) with
overlap
in time domain (in percent) - Compute background amplitude per time sample over ntraces using user-specified function
mean
: average amplituderms
: root mean squared amplitudemedian
: median amplitude
- Compare reference trace amplitudes with computed background amplitudes using user-specified
threshold
andamplitude > threshold * background amplitude
→ spike detectionamplitude <= threshold * background amplitude
→ no spike
- Replace detected spike samples using user-specified method:
scaled
: Scale signal down to background amplitude (based on mode). Tapering applied.mode
: Replace with background amplitude valuesthreshold
: Replace withthreshold * background
amplitude values.zeros
: Replace with zero values.median
: Replace with median values (calculated from neighboring traces).
Usage#
This script is designed to be used from the terminal (i.e. command line).
Command line interface#
The script can handle three different inputs:
- single SEG-Y file (e.g.,
filename.sgy
) - datalist of files to process (e.g.,
datalist.txt
) - directory with input files (e.g.,
/input_dir
)
There are two options to run the script. We recommend using the CLI entry point like:
Alternatively, the script can be executed using the (more verbose) command:
>>> python -m pseudo_3D_interpolation.despiking_2D_segy {filename.sgy | datalist.txt | </directory>} [optional parameters]
Optionally, the following parameters can be specified:
--help
,-h
: Show help.--output_dir {DIR}
: Output directory (either--inplace
or--output_dir
are required!).--inplace
: Replace input data without creating copy (either--inplace
or--output_dir
are required!).--suffix {sgy}
: File suffix (default:sgy
). Only used if directory is specified.--filename_suffix {SUFFIX}
: Filename suffix (e.g.pad
,static
) to filter input files. Only used if directory is specified.--txt_suffix {despk}
: Suffix to append to output filename (default:despk
).--use_delay
: Use delay recording time to split input data before despiking (e.g. for TOPAS, Parasound).--byte_delay {109}
: Byte position of input delay times in SEG-Y file(s) (default:109
).--mode {MODE}
: Mode used to compute background amplitude and detect spikes in data.mean
,rms
, ormedian
--window_time {TIME}
: Moving window length in time domain (TWT [ms]).--window_traces {TRACES}
: Moving window length in offset domain (traces [#]).--window_overlap {PERCENT}
: Time overlap of moving windows (%) (default:10
).--threshold_factor {FACTOR}
: Used for spike detection (threshold_factor * background amplitude).--out_amplitude {METHOD}
: Replace spike amplitudes using selected methodscaled
,mode
,threshold
,zeros
,median
--verbose {LEVEL}
: Level of output verbosity (default:0
).
Python script#
Import function
Create dummy data
import numpy as np
dt = 0.05 # ms
length = 250 # ms
ntraces = 100
shape = (int(length / dt), ntraces)
# create dummy data
data = np.ones(shape, dtype='float32')
# insert noise burst
noise_time = slice(int(100/dt), int(120/dt))
noise_trace = 50
data[noise_time, noise_trace] = 5
# add some noise
data += np.random.standard_normal(shape)
Despike dummy data
window = 30 # length (ms) of window, should be larger than noise (~20 ms)
data_despk = despike_2D(
data, window, dt, overlap=10, ntraces=5, mode='mean', threshold=2, out='scaled', verbosity=0
)
Compare original vs despiked data
print('original data:', data[noise_time, noise_trace], sep='\n')
print('despiked data:', data_despk[noise_time, noise_trace], sep='\n')
Last update:
Monday, 03 July 2023 at 09:46:51