Skip to main content

Apply the LLNL-G3D-JPS resolution matrix to velocity models.

Project description

llnltofi

A Python package for tomographic filtering of seismic mantle structure ($v_S$ or $v_P$) using the resolution matrix $R$ of the LLNL-G3D-JPS model by Simmons et al. (2015). Given a velocity model on the LLNL grid, llnltofi applies the resolution operator via a single sparse matrix-vector multiply $Rm = m'$ and returns the filtered result.

Author: Sia Ghelichkhan (sia.ghelichkhani@anu.edu.au)

Installation

pip install -e .

Dependencies are just numpy and scipy. For running the example scripts you will also need matplotlib, which can be installed with:

pip install -e ".[examples]"

Quick start

import llnltofi

model = llnltofi.ResolutionModel()

# Get grid coordinates as (lon, gc_lat, depth_km)
coords = model.coordinates_in_lonlatdepth  # shape (1_003_608, 3)

# Or as Cartesian (x, y, z) in metres
xyz = model.coordinates_in_xyz  # shape (1_003_608, 3)

# Evaluate your model at these points and compute slowness perturbation
# du = 1/v_3D - 1/v_1D at each grid point
model.values = ...  # shape (1_003_608,)

# Apply the resolution matrix
du_filtered = model.apply()  # shape (1_003_608,)

An interpolation helper is also provided for projecting an arbitrary point cloud onto the LLNL grid:

from llnltofi.interpolation import project_onto_grid

du = project_onto_grid(source_points, source_values, model)  # shape (1_003_608,)

Correctness note

This package is a modern reimplementation of LLNL_ToFi by Bernhard Schuberth (LMU Munich). The original code performed the filtering by looping over the sparse matrix entries element by element, converting each 1-based global column index back to a (layer, coordinate) pair using integer division and modulo arithmetic:

c_index = np.mod(cj, np_UM_TZ) - 1
l_index = cj // np_UM_TZ

This mapping has a boundary bug. Whenever cj is an exact multiple of the layer size (40,962 for upper-mantle/transition-zone layers, 10,242 for lower-mantle layers), the modulo returns zero, c_index becomes $-1$, and l_index is off by one. Python silently wraps the $-1$ to the last array element, so the code reads a value from the wrong depth layer without raising any error. Cross-validation against the original text files shows that 2,357 out of 75,508,775 R-matrix entries fall on these boundary columns, producing errors in 1,107 output grid points (0.11 % of the model vector) with absolute differences up to $\approx 0.15$.

llnltofi avoids the problem entirely by pre-converting the 44 layer text files into a single scipy.sparse CSR matrix with straightforward 0-based indexing (col = cj - 1). The filtering step becomes a single call to scipy.sparse.csr_matrix @ numpy.ndarray, delegating all index arithmetic to well-tested library code. A cross-validation test suite (tests/test_equivalence.py) confirms that the bundled R.npz is bit-for-bit identical to one freshly assembled from the original text files and that model.apply() reproduces the correct matrix-vector product.

Data

All required data files, including the grid coordinates and the resolution matrix, are hosted on S3 and downloaded automatically on first use. There is nothing to configure — just pip install the package and everything is fetched lazily when you first access model.R or the coordinate properties. Downloaded files are cached locally so subsequent runs are instant.

References

Simmons, N. A., Myers, S. C., Johannesson, G., Matzel, E., & Grand, S. P. (2015). Evidence for long-lived subduction of an ancient tectonic plate beneath the southern Indian Ocean. Geophysical Research Letters, 42(21), 9270-9278. https://doi.org/10.1002/2015GL066237

Simmons, N. A., Schuberth, B. S. A., Myers, S. C., & Knapp, D. R. (2019). Resolution and covariance of the LLNL-G3D-JPS global seismic tomography model: applications to travel time uncertainty and tomographic filtering of geodynamic models. Geophysical Journal International, 217(3), 1543-1557. https://doi.org/10.1093/gji/ggz102

License

License: GPL v3

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

llnltofi-0.2.0.tar.gz (33.1 kB view details)

Uploaded Source

Built Distribution

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

llnltofi-0.2.0-py3-none-any.whl (27.7 kB view details)

Uploaded Python 3

File details

Details for the file llnltofi-0.2.0.tar.gz.

File metadata

  • Download URL: llnltofi-0.2.0.tar.gz
  • Upload date:
  • Size: 33.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for llnltofi-0.2.0.tar.gz
Algorithm Hash digest
SHA256 67b13e34dbd22f58e1399418f2c74a18004331144efb64a5d571a32b623a3f5e
MD5 1acfa6412e8b46eb7fe68e75c5a743e5
BLAKE2b-256 835fcb0faa458445bcbd4bb99a822c9781b530a254f37a3c7eb14f9f58b4bd15

See more details on using hashes here.

Provenance

The following attestation bundles were made for llnltofi-0.2.0.tar.gz:

Publisher: release.yml on g-adopt/llnltofi

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

File details

Details for the file llnltofi-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: llnltofi-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 27.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for llnltofi-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 523cb01993293c4dcb8f5bdcd75812c102cf66cf55d111b27ee399738f28935c
MD5 e80806c483d72c4dc9b36f59de34912c
BLAKE2b-256 11f18127ee033ec0b7ad4d2f67af5988089b83232945db26bdc9ee26e296a734

See more details on using hashes here.

Provenance

The following attestation bundles were made for llnltofi-0.2.0-py3-none-any.whl:

Publisher: release.yml on g-adopt/llnltofi

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