跳转到主要内容

一个高效地在Python中读取fortran-record文件的包。

项目描述

Cython fortran-file

Build and Test PyPI Conda-forge

此包是一个快速且易于使用的基于记录的二进制格式读取器,由Fortran编写。

安装

此包需要在您的系统上安装编译器。如果您使用Linux或MacOSX,应该没问题。如果您使用Windows,请与我联系或打开一个问题。

pip install cython_fortran_file

这就全部了!

使用方法

以下是一个简单的演示

from cython_fortran_file import FortranFile as FF

f = FF("/path/to/my/fortran/file.dat", mode="r")

# Skip 5 records
f.skip(5)

# Read one record (an array of `double`)
data = f.read_vector("d")
assert data.dtype == np.float64

# Read one record (an array of signed `int`)
data = f.read_vector("i")
assert data.dtype == np.int32

# Read one *single* int. This will fail if there is more to read!
v = f.read_int()

# f _looks_ like a regular file descriptor
f.tell()
f.seek(0)
f.close()

它还支持with语句,这样您就不会忘记关闭文件处理器

with FF("/path/to/my/fortran/file.dat") as f:
    f.skip(5)

    data = f.read_vector("d")  # Read a vector of doubles (as usual)

数据类型

read_vector的参数遵循Python struct包的约定(C约定)。有关完整列表,请参阅https://docs.pythonlang.cn/3.5/library/struct.html#format-characters。这里是一个简短的版本

参数 Fortran类型 C类型 Numpy数据类型
d real(8) double np.float64
f real(4) float np.float32
i integer int np.int32
l integer(8) long np.int64

项目详情


下载文件

下载适用于您平台的文件。如果您不确定选择哪个,请了解有关 安装包 的更多信息。

源分布

cython_fortran_file-0.2.7.tar.gz (104.9 kB 查看哈希值)

上传时间

构建分布

cython_fortran_file-0.2.7-cp313-cp313-macosx_11_0_arm64.whl (49.5 kB 查看哈希值)

上传时间 CPython 3.13 macOS 11.0+ ARM64

cython_fortran_file-0.2.7-cp312-cp312-win_amd64.whl (47.4 kB 查看哈希值)

上传时间 CPython 3.12 Windows x86-64

cython_fortran_file-0.2.7-cp312-cp312-win32.whl (43.3 kB 查看哈希值)

上传时间 CPython 3.12 Windows x86

cython_fortran_file-0.2.7-cp312-cp312-musllinux_1_1_x86_64.whl (302.4 kB 查看哈希值)

上传时间 CPython 3.12 musllinux: musl 1.1+ x86-64

cython_fortran_file-0.2.7-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (303.1 kB 查看哈希值)

上传时间 CPython 3.12 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

cython_fortran_file-0.2.7-cp312-cp312-macosx_11_0_arm64.whl (50.4 kB 查看哈希值)

上传时间 CPython 3.12 macOS 11.0+ ARM64

cython_fortran_file-0.2.7-cp312-cp312-macosx_10_9_x86_64.whl (53.8 kB 查看哈希值)

上传时间 CPython 3.12 macOS 10.9+ x86-64

cython_fortran_file-0.2.7-cp311-cp311-win_amd64.whl (47.8 kB 查看哈希值)

上传时间 CPython 3.11 Windows x86-64

cython_fortran_file-0.2.7-cp311-cp311-win32.whl (44.2 kB 查看哈希值)

上传时间 CPython 3.11 Windows x86

cython_fortran_file-0.2.7-cp311-cp311-musllinux_1_1_x86_64.whl (293.7 kB 查看哈希值)

上传时间 CPython 3.11 musllinux: musl 1.1+ x86-64

cython_fortran_file-0.2.7-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (292.9 kB 查看哈希值)

上传时间 CPython 3.11 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

cython_fortran_file-0.2.7-cp311-cp311-macosx_11_0_arm64.whl (50.6 kB 查看哈希值)

上传时间 CPython 3.11 macOS 11.0+ ARM64

cython_fortran_file-0.2.7-cp311-cp311-macosx_10_9_x86_64.whl (54.3 kB 查看哈希值)

上传时间 CPython 3.11 macOS 10.9+ x86-64

cython_fortran_file-0.2.7-cp310-cp310-win_amd64.whl (47.1 kB 查看哈希值)

上传时间 CPython 3.10 Windows x86-64

cython_fortran_file-0.2.7-cp310-cp310-win32.whl (44.4 kB 查看哈希值)

上传时间 CPython 3.10 Windows x86

cython_fortran_file-0.2.7-cp310-cp310-musllinux_1_1_x86_64.whl (269.7 kB 查看哈希值)

上传时间 CPython 3.10 musllinux: musl 1.1+ x86-64

cython_fortran_file-0.2.7-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (269.3 kB 查看哈希值)

上传时间 CPython 3.10 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

cython_fortran_file-0.2.7-cp310-cp310-macosx_11_0_arm64.whl (50.5 kB 查看哈希值)

上传于 CPython 3.10 macOS 11.0+ ARM64

cython_fortran_file-0.2.7-cp310-cp310-macosx_10_9_x86_64.whl (54.0 kB 查看哈希值)

上传于 CPython 3.10 macOS 10.9+ x86-64

cython_fortran_file-0.2.7-cp39-cp39-win_amd64.whl (47.7 kB 查看哈希值)

上传于 CPython 3.9 Windows x86-64

cython_fortran_file-0.2.7-cp39-cp39-win32.whl (45.1 kB 查看哈希值)

上传于 CPython 3.9 Windows x86

cython_fortran_file-0.2.7-cp39-cp39-musllinux_1_1_x86_64.whl (272.7 kB 查看哈希值)

上传于 CPython 3.9 musllinux: musl 1.1+ x86-64

cython_fortran_file-0.2.7-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (272.3 kB 查看哈希值)

上传于 CPython 3.9 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

cython_fortran_file-0.2.7-cp39-cp39-macosx_11_0_arm64.whl (51.1 kB 查看哈希值)

上传于 CPython 3.9 macOS 11.0+ ARM64

cython_fortran_file-0.2.7-cp39-cp39-macosx_10_9_x86_64.whl (54.6 kB 查看哈希值)

上传于 CPython 3.9 macOS 10.9+ x86-64

由以下机构支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误记录 StatusPage StatusPage 状态页面