Efficient implementatins of the Konno Ohmachi filter in Python.
Project description
pykooh
Konno Ohmachi filter implemented in Numba.
This code implements Konno-Ohmachi spectral smoothing as defined in:
Konno, K. and Ohmachi, T., 1998. Ground-motion characteristics estimated
from spectral ratio between horizontal and vertical components of
microtremor. Bulletin of the Seismological Society of America, 88(1),
pp.228-241.
This code was originally written for smoothing submodule in gmprocess by Bruce Worden. Dave Boore has provided notes on this topic, which also may be of interest. Notes regarding the characteristics of the Konno-Ohmachi filter and the implementation are provided in the implementation Jupyter Notebook.
Installation
pykooh is available via pip and can be installed with:
pip install pykooh
pykooh uses numba for fast implementation of the filter.
Implementation Notes
Previous versions of pykooh supported both Numba and Cython implementations.
Testing showed that both implementations provided similar calculation speeds,
but Cython required significantly more effort for packaging and distribution.
Therefore, Cython support has been removed in favor of the Numba-only
implementation which provides excellent performance with much simpler packaging.
Usage
Two primary approaches for using this library. Smooth a signal using a bandwidth of 30.
import pykooh
signal_smooth = pykooh.smooth(freqs, freqs_raw, signal_raw, 30)
If you are okay with a little bit of inaccuracy, you can pass simplified=True
and have a 10x increase in speed. In other instances, where the smoothing is
repeated applied, it might make more sense to use the CachedSmoother. This
pre-computes the weights and then applies them with np.dot.
import pykooh
smoother = CachedSmoother(freqs_raw, freqs, 30)
signal_smooth = smoother(signal_raw)
By default, all of the smoothing functions normalize that weights, which is
different than the default behavior of obspy. By normalizing the weights, the
amplitude of the FAS is perserved regardless of spacing of the frequency values.
Comparison of the smoothing provided by pykooh is compared with that of
obspy in the following figure. The simplified numba routine results in some
minor reduction in accuracy.
Additional examples and comparison with obspy are provided in
example.
Citation
Please cite this software using the following DOI.
Albert Kottke. (2025). arkottke/pykooh (v0.5.0). Zenodo. https://doi.org/10.5281/zenodo.15499453
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pykooh-0.5.0.tar.gz.
File metadata
- Download URL: pykooh-0.5.0.tar.gz
- Upload date:
- Size: 933.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8007715d1456a504a6cb735daadd3c06a5e5b2d2117524375b6b3d32fcb11112
|
|
| MD5 |
56a3b3b33fec752135ac9cb6f58950a8
|
|
| BLAKE2b-256 |
23c44bd65fe26b8e4bb31435aaa60200c7427cde8beb6a74506018ff832b9a19
|
File details
Details for the file pykooh-0.5.0-py3-none-any.whl.
File metadata
- Download URL: pykooh-0.5.0-py3-none-any.whl
- Upload date:
- Size: 7.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
41768131dcb851bde22078c29342490aabf1e36813c392bc608103b856fd6cd0
|
|
| MD5 |
f664e013ba559def63ecb272d96aefbf
|
|
| BLAKE2b-256 |
01a9d1686c09d4d98ff3cacb24810fb57fdc28bc26aca9ea068bb632fb3f9e7a
|