Skip to main content

Efficient implementatins of the Konno Ohmachi filter in Python.

Project description

pykooh

PyPi Cheese Shop Build Status Code Quality Test Coverage License DOI

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.

Method Comparison

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

pykooh-0.5.0.tar.gz (933.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pykooh-0.5.0-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

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

Hashes for pykooh-0.5.0.tar.gz
Algorithm Hash digest
SHA256 8007715d1456a504a6cb735daadd3c06a5e5b2d2117524375b6b3d32fcb11112
MD5 56a3b3b33fec752135ac9cb6f58950a8
BLAKE2b-256 23c44bd65fe26b8e4bb31435aaa60200c7427cde8beb6a74506018ff832b9a19

See more details on using hashes here.

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

Hashes for pykooh-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 41768131dcb851bde22078c29342490aabf1e36813c392bc608103b856fd6cd0
MD5 f664e013ba559def63ecb272d96aefbf
BLAKE2b-256 01a9d1686c09d4d98ff3cacb24810fb57fdc28bc26aca9ea068bb632fb3f9e7a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page