A C/Python package for solving eikonal equation using Fast Marching/Sweeping Method
Project description
PyFMM
欢迎Star!
PyFMM 是一个基于 Fast Marching/Sweeping Method 求解程函方程 $|\nabla T|^2 = s^2$ 的C/Python程序包,包括示例和注释。 其中 Fast Sweeping Method 包括了并行版本,详见在线文档或文献 (Zhao, 2007)。
PyFMM is a C/Python package for solving eikonal equation using Fast Marching/Sweeping Method, with examples and annotations.
At present, PyFMM can run on
- Linux
- macOS
- Windows
我还制作了一个简易图形界面 PyFMM-GUI 计算二维走时场,初学者可更好的理解射线追踪,也可更方便、直观地看到不同速度场下射线的扭曲形态。
我主要使用 PyFMM 计算地震波从震源出发在复杂介质中传播形成的初至波走时场, 并使用梯度下降获得满足费马原理的射线路径,故代码中的一些术语偏专业性。 类似的原理也可用于其它方面,如计算点到曲线/面的距离,或光学、电磁学等。
-
Python语言的便携、可扩展性与C语言的计算高效特点结合。 C程序被编译链接成动态库 libfmm.so ,PyFMM 再基于Python的 ctypes 标准库实现对C库函数的调用。再基于第三方库 NumPy、 SciPy 等可很方便地完成对C程序结果的数据整合;
-
C代码采取模块化编写,各功能分在不同代码文件中,方便移植到其它程序;
-
支持二维和三维情况;2D and 3D
-
支持直角坐标系和球坐标系;Cartesian and Spherical Coordinate
-
中文注释及示例;
文档 Documents
为方便使用,我建立了在线文档,包括简易安装、API的介绍以及使用示例。
安装 Installation
新版本已添加预编译的C动态库,无需本地再编译,支持pip命令一键安装:
pip install pyfmm-kit
使用示例 Usage Example
更多使用示例详见在线文档。
import pyfmm
import numpy as np
import matplotlib.pyplot as plt
from scipy import interpolate
pyfmm.logger.myLogger.setLevel('ERROR')
# 定义网格
nx, ny, nz = 401, 1, 101
xarr = np.linspace(0, 200, nx)
yarr = np.array([0.0])
zarr = np.linspace(0, 50, nz)
# 定义1D速度
vel1d = np.array([
[0.0, 3.2],
[5.0, 5.8],
[15.0, 6.5],
[30.0, 6.8],
[35.0, 8.1],
[80.0, 8.2]
])
# 插值1d分层速度
# _idxs = np.searchsorted(vel1d[:,0], zarr)
# velocity = vel1d[_idxs, 1]
# OR
# 插值1d梯度速度
velocity = interpolate.interpn((vel1d[:,0],), vel1d[:,1], zarr)
# 慢度数组
slowness = np.empty((nx, ny, nz))
slowness[...] = 1.0/velocity[None,None,:]
# 定义震源位置
srcloc = [0.0, 0.0, 0.0]
# 计算时间场
TT = pyfmm.travel_time_source(
srcloc,
xarr, yarr, zarr, slowness)
#====================================================================
# 绘制走时场和射线
fig, ax1 = plt.subplots(1, 1)
cs = ax1.contour(xarr, zarr, TT[:, 0, :].T, levels=30, linewidths=0.5)
ax1.clabel(cs)
for x in np.arange(5, 200, 5):
# 射线追踪
rcvloc = [x, 0, 0]
travt, rays = pyfmm.raytracing(
TT, srcloc, rcvloc, xarr, yarr, zarr, 0.1)
ax1.plot(rays[:,0], rays[:,2], c='r', lw=0.8, ls='--')
ax1.set_aspect('equal')
ax1.set_xlim(0, 200)
ax1.set_ylim(0, 50)
ax1.yaxis.set_inverted(True)
其它
代码是我在研二写的,如果遇到bug,欢迎联系我(zhudengda@mail.iggcas.ac.cn),我会完善! 也欢迎提出建议和更多示例!
基于PyFMM的体波走时反演以及面波反演后续也会开源。
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
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 pyfmm_kit-0.5.0-py3-none-win_amd64.whl.
File metadata
- Download URL: pyfmm_kit-0.5.0-py3-none-win_amd64.whl
- Upload date:
- Size: 587.3 kB
- Tags: Python 3, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cb1a046dad622bd9ba47375b5c8d4f02f4646c01042104c0146a95172b0f29a1
|
|
| MD5 |
38a977de86282466fabe27a34a06f489
|
|
| BLAKE2b-256 |
3449297a39dbb13285a097aef054640ef5ca5eb03158c69f29ccb2c317ace0d4
|
Provenance
The following attestation bundles were made for pyfmm_kit-0.5.0-py3-none-win_amd64.whl:
Publisher:
build.yml on Dengda98/PyFMM
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyfmm_kit-0.5.0-py3-none-win_amd64.whl -
Subject digest:
cb1a046dad622bd9ba47375b5c8d4f02f4646c01042104c0146a95172b0f29a1 - Sigstore transparency entry: 462076992
- Sigstore integration time:
-
Permalink:
Dengda98/PyFMM@e36015cacf3013ff8055e830a4ed84f61a9fd717 -
Branch / Tag:
refs/tags/v0.5.0 - Owner: https://github.com/Dengda98
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yml@e36015cacf3013ff8055e830a4ed84f61a9fd717 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pyfmm_kit-0.5.0-py3-none-manylinux2014_x86_64.whl.
File metadata
- Download URL: pyfmm_kit-0.5.0-py3-none-manylinux2014_x86_64.whl
- Upload date:
- Size: 132.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ae19d892dbe266452f275dd28f1673058c6220769a4fef00e84c868f7b55c617
|
|
| MD5 |
47842de12a4b4efee21ac0af582da8c3
|
|
| BLAKE2b-256 |
1129e9841db660a15966e0ba4e81b6f5ad8932a3cb20ea9dba9ea04214c3d201
|
Provenance
The following attestation bundles were made for pyfmm_kit-0.5.0-py3-none-manylinux2014_x86_64.whl:
Publisher:
build.yml on Dengda98/PyFMM
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyfmm_kit-0.5.0-py3-none-manylinux2014_x86_64.whl -
Subject digest:
ae19d892dbe266452f275dd28f1673058c6220769a4fef00e84c868f7b55c617 - Sigstore transparency entry: 462076948
- Sigstore integration time:
-
Permalink:
Dengda98/PyFMM@e36015cacf3013ff8055e830a4ed84f61a9fd717 -
Branch / Tag:
refs/tags/v0.5.0 - Owner: https://github.com/Dengda98
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yml@e36015cacf3013ff8055e830a4ed84f61a9fd717 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pyfmm_kit-0.5.0-py3-none-macosx_11_0_arm64.whl.
File metadata
- Download URL: pyfmm_kit-0.5.0-py3-none-macosx_11_0_arm64.whl
- Upload date:
- Size: 139.0 kB
- Tags: Python 3, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4e65a2b56a041f4c874098c232e0f8498e41a784e63849970741f1f0961535ea
|
|
| MD5 |
2bf2acc44ac9e0b96977e06f3cea07f4
|
|
| BLAKE2b-256 |
2ccecca2698668f09d1aa2f97acf21dae207832f0ec6d82bce2f6225ced00b74
|
Provenance
The following attestation bundles were made for pyfmm_kit-0.5.0-py3-none-macosx_11_0_arm64.whl:
Publisher:
build.yml on Dengda98/PyFMM
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyfmm_kit-0.5.0-py3-none-macosx_11_0_arm64.whl -
Subject digest:
4e65a2b56a041f4c874098c232e0f8498e41a784e63849970741f1f0961535ea - Sigstore transparency entry: 462077014
- Sigstore integration time:
-
Permalink:
Dengda98/PyFMM@e36015cacf3013ff8055e830a4ed84f61a9fd717 -
Branch / Tag:
refs/tags/v0.5.0 - Owner: https://github.com/Dengda98
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yml@e36015cacf3013ff8055e830a4ed84f61a9fd717 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pyfmm_kit-0.5.0-py3-none-macosx_10_9_x86_64.whl.
File metadata
- Download URL: pyfmm_kit-0.5.0-py3-none-macosx_10_9_x86_64.whl
- Upload date:
- Size: 141.4 kB
- Tags: Python 3, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
06b94e2712d9478e99a15300b3fe140dbb385c2ed5672c07ccd7b7c2f17c0af6
|
|
| MD5 |
863566909c41e4e0810e403c611c35f9
|
|
| BLAKE2b-256 |
96af297114c69ca35f8f1a8681df29461e1e43f1e7f3c97b2f10d120c7628a25
|
Provenance
The following attestation bundles were made for pyfmm_kit-0.5.0-py3-none-macosx_10_9_x86_64.whl:
Publisher:
build.yml on Dengda98/PyFMM
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyfmm_kit-0.5.0-py3-none-macosx_10_9_x86_64.whl -
Subject digest:
06b94e2712d9478e99a15300b3fe140dbb385c2ed5672c07ccd7b7c2f17c0af6 - Sigstore transparency entry: 462076971
- Sigstore integration time:
-
Permalink:
Dengda98/PyFMM@e36015cacf3013ff8055e830a4ed84f61a9fd717 -
Branch / Tag:
refs/tags/v0.5.0 - Owner: https://github.com/Dengda98
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yml@e36015cacf3013ff8055e830a4ed84f61a9fd717 -
Trigger Event:
push
-
Statement type: