Skip to main content

Normalized frequency index (nFI) computation for earthquake source spectra

Project description

py-nfi

PyPI version Python versions License: MIT

Compute the normalized frequency index (nFI) from earthquake spectra. nFI is a data-driven measure of the relative high-frequency content of a seismic source, providing an observation-based alternative to stress-drop estimation for characterizing source behavior at high frequencies.

Installation

pip install py-nfi

or, with conda:

conda install -c conda-forge py-nfi

py-nfi requires the following packages:

  • numpy
  • pandas
  • scipy
  • tqdm

Quick start

import numpy as np
import pandas as pd
from nfi import nFIEstimator

# df_records: one row per event-station record (a single observed spectrum)
# spectra:    N x nf array of signal amplitude spectra, aligned row-for-row
#             with df_records (the signal windows; noise spectra are used
#             upstream for signal-to-noise screening, not passed here). Each
#             record in spectra has already passed signal-to-noise criteria.
# f:          length-nf frequency array (0 to Nyquist)

est = nFIEstimator(df_records, spectra, f, save_dir="results/")
est.compute()

# per-event results, including the 'nfi' column, are written to results/
# and available as est.df_events

df_records structure

df_records must contain the following for each record at minimum:

  • event_name, the recorded event's unique identifier;
  • channel_name, the recording station's unique identifier;
  • emag, elat, elon, and edep (km), the event's magnitude and location ;
  • slat, slon, and selev, the station's location; and
  • deldist, the horizontal event-station distance in kilometers;

This pandas DataFrame should be of length N, with each row corresponding to the nth row in spectra. e* fields describe the event and s* fields describe the recording station.

Method

nFI is computed from spectra in three stages.

1. Frequency index. For every observed spectrum, we take the log ratio of the median amplitude in a high-frequency band to that in a low-frequency band:

logbeta = log10(A_HF) - log10(A_LF)

This quantifies the richness of high frequencies relative to low frequencies for a single recording. The low band should sample the flat portion of the displacement spectrum below the corner frequency, and the high band should sample the decay above it.

2. Path and station correction. Observed spectra carry path and station effects that must be removed to isolate source variability. For each target event, we identify small nearby "calibration" earthquakes recorded at the same stations. Differencing logbeta between a target and a calibration event at a shared station cancels the common station and path terms. Taking the median of these differences across calibration events per station, then the median across stations, yields the corrected source term dlogbeta for each event. Calibration events are selected within a narrow magnitude range and a limited horizontal and vertical distance of the target.

3. Magnitude correction. Larger earthquakes radiate proportionally less high-frequency energy, so dlogbeta retains a magnitude dependence. We estimate this trend by taking the median dlogbeta in magnitude bins, smoothing it, and subtracting the interpolated trend from each event. The result is nFI: by construction it has approximately zero median at any magnitude, with positive values indicating high-frequency enrichment and negative values indicating depletion.

For full detail and validation of the method, see Vandevert et al. (2026) below.

Reproducing the Ridgecrest results

Clone this repository:

git clone https://github.com/ivandevert/py-nfi your/local/save/path/

Download the precomputed, signal-to-noise passing spectra from (15 July 2026: COMING SOON -- email me for link) into the repo's ridgecrest/data/ subdirectory:

coming soon

Launch run_nfi_compute.ipynb and run all cells.

Citation

If you use this software, please cite:

Vandevert, I., Shearer, P. M., & Fan, W. (2026). Using a High-to-Low-Frequency Spectral Ratio to Distinguish Variations in Earthquake Source Properties. Bulletin of the Seismological Society of America. https://doi.org/10.1785/0120250171

License

Released under the MIT License.

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

py_nfi-0.1.4.tar.gz (21.9 kB view details)

Uploaded Source

Built Distribution

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

py_nfi-0.1.4-py3-none-any.whl (18.7 kB view details)

Uploaded Python 3

File details

Details for the file py_nfi-0.1.4.tar.gz.

File metadata

  • Download URL: py_nfi-0.1.4.tar.gz
  • Upload date:
  • Size: 21.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for py_nfi-0.1.4.tar.gz
Algorithm Hash digest
SHA256 dbe16b8a7ed5f80bb394f1c9a13de57ad3b2465c68a3969f6b8a91b6ba344e98
MD5 8a4a39a277289a124b096e6dba155f08
BLAKE2b-256 3e2304a24191297591a38cfcfc57cda55d0e9437dcc2101229acc5cec35ad2da

See more details on using hashes here.

Provenance

The following attestation bundles were made for py_nfi-0.1.4.tar.gz:

Publisher: publish.yml on ivandevert/py-nfi

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file py_nfi-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: py_nfi-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 18.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for py_nfi-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 11c28e63a46bed1ac95a22a18b53402866a0eebb9dcbde2ae40a7506f4ebff28
MD5 f54775478c0645340800b4defc049997
BLAKE2b-256 e79d31a513c0a4b6b871156f6781e3a04ef0c18cd049e01dbd00e68ff0acf423

See more details on using hashes here.

Provenance

The following attestation bundles were made for py_nfi-0.1.4-py3-none-any.whl:

Publisher: publish.yml on ivandevert/py-nfi

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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