Pre-smoothing spectral SNR mask to suppress noise-dominated low-frequency bins#83
Pre-smoothing spectral SNR mask to suppress noise-dominated low-frequency bins#83Riviss wants to merge 6 commits intoSeismicSource:mainfrom
Conversation
|
Hi @Riviss, thank you very much for this PR! It looks very well-structured, and my standard test cases all still work. I'll make a detailed review in the following days. In the meanwhile, please add a Thanks! |
|
Hi again @Riviss, I would like to push some changes to your branch https://github.com/Riviss/sourcespec/tree/snr-mask-feature, but it looks like your repository is now archived and read-only. Could you please "unarchive" it? Thanks! |
| include docs/* | ||
| include imgs/* | ||
| # Explicitly include all Python modules so new files are picked up | ||
| recursive-include sourcespec *.py |
There was a problem hiding this comment.
Confused on why you need this, since there are already the following lines in pyproject.toml:
[tool.setuptools.packages.find]
include = ["sourcespec", "sourcespec.*"]Could you tell me more about the problem you encountered?
| f_ramp_start, f_cross, color='#CC9933', alpha=0.12, zorder=2) | ||
|
|
||
|
|
||
| def _plot_event_moment_line(spec, ax, ax2): |
There was a problem hiding this comment.
This function is not technically part of this PR, yet it's interesting 😉 .
Maybe we should add a config parameter to enable it?
Summary
Adds an optional pre-smoothing spectral SNR mask that clamps noise-dominated low-frequency bins before log-frequency smoothing, preventing the smoothing kernel from bleeding high noise amplitudes into the usable frequency band.
Problem
When the spectral smoothing kernel encounters bins where noise exceeds the signal (common at low frequencies), it spreads those high noise values into neighboring bins. This contaminates the frequency band used for spectral fitting and can bias the corner frequency and moment estimates. We encountered this systematically while processing induced seismicity in northeastern British Columbia, where cultural and industrial noise dominates the low-frequency band.
Solution
A configurable SNR mask is applied between spectrum computation and smoothing:
left_of_first(default) finds the first frequency where SNR >= threshold and clamps all lower bins;binaryclamps every sub-threshold bin.spectral_snr_mask_freq_range) to constrain the search band.New configuration parameters
spectral_snr_mask_thresholdspectral_snr_mask_modeleft_of_first(default) orbinaryspectral_snr_mask_ramp_decadesspectral_snr_mask_freq_range[min_freq, max_freq]in HzVisualization
Files changed
sourcespec/ssp_build_spectra.py- core mask logic, RSS application, deferred smoothingsourcespec/ssp_plot_spectra.py- mask indicator visualizationsourcespec/config_files/configspec.conf- new config parametersMANIFEST.in- include all Python modules in sdist (minor packaging fix)Notes