This package provides a pure-Python way to create, inspect, and validate .ndtbl files without depending on the C++ binaries.
Project description
ndtbl
Pure-Python tools for reading, writing, inspecting, and generating .ndtbl
files without depending on the C++ binaries.
The package is useful when you want to:
- inspect an existing table on a machine without the C++ toolchain
- generate small synthetic tables for tests, examples, and development
- query one concrete grid point from the command line
- read or write
.ndtblfiles directly from Python or NumPy workflows
🔧 Features
- Read
.ndtblmetadata or full payloads - Write
.ndtblfiles compatible with the current C++ implementation - Inspect files from the command line with metadata and sample values
- Query one point in a table by zero-based grid indices
- Generate small predefined linear tables for development workflows
⚙️ Installation
Install from the package directory:
python -m pip install .
Or install from PyPI:
python -m pip install ndtbl
For development:
python -m pip install -v -e .[lint,tests]
🐍 Python API
The core API revolves around FieldGroup, UniformAxis, ExplicitAxis, read_group, and write_group.
import numpy as np
from ndtbl import FieldGroup, UniformAxis, ExplicitAxis, read_group, write_group
group = FieldGroup(
axes=(ExplicitAxis([0.0, 0.1, 1.0]), UniformAxis(10.0, 20.0, 2)),
field_names=("A", "B"),
values=np.array(
[
[[1.0, 10.0], [2.0, 20.0]],
[[3.0, 30.0], [4.0, 40.0]],
[[5.0, 50.0], [6.0, 60.0]],
],
dtype=np.float64,
),
)
write_group("example.ndtbl", group)
loaded = read_group("example.ndtbl")
print(loaded.field_names)
print(loaded.values[1, 0, :])
The values array shape is axis_0 x axis_1 x ... x field.
Demo notebook
Use the demo notebook to test the Python functionality of ndtbl and see how it can be used to read and write binary .ndtbl files.
💻 CLI
The package installs one executable, ndtbl, with three subcommands:
inspectprints metadata and a configurable number of sample valuesqueryprints the field values at one point addressed by zero-based indicesgeneratecreates a simple synthetic table with linear fields
Show the top-level help:
ndtbl --help
inspect
Inspect an existing file:
ndtbl inspect example.ndtbl
inspect prints an ASCII-art header by default after the file is read
successfully. Suppress it when needed:
ndtbl inspect example.ndtbl --no-banner
Limit the number of printed sample points:
ndtbl inspect example.ndtbl --samples 3
query
Query one point in the table using zero-based indices in axis order:
ndtbl query example.ndtbl 1 0
Print metadata before the queried values:
ndtbl query --metadata example.ndtbl 1 0
For a 3D table, provide three indices:
ndtbl query example-3d.ndtbl 1 2 0
generate
Generate a small linear table:
ndtbl generate output.ndtbl \
--axis 0 1 3 \
--axis 10 20 2 \
--field-linear A 1.0 2.0 0.0 \
--field-linear B 5.0 0.0 -1.0
Use float32 output instead of the default float64:
ndtbl generate output.ndtbl \
--axis 0 1 3 \
--field-linear A 1.0 2.0 \
--dtype float32
Raise or lower the generation safety limit:
ndtbl generate output.ndtbl \
--axis 0 1 100 \
--axis 0 1 100 \
--field-linear A 0.0 1.0 1.0 \
--max-size-mib 32
--field-linear expects NAME OFFSET C0 [C1 ...], with one coefficient per
axis in storage order.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
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 ndtbl-0.2.0.tar.gz.
File metadata
- Download URL: ndtbl-0.2.0.tar.gz
- Upload date:
- Size: 19.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3d56798ba84fbe427b2b7dcc309b983adcd8c0dd23f08f393e400381cd5f3af8
|
|
| MD5 |
af21c63ae5bc851cc60c3ce98a4b311d
|
|
| BLAKE2b-256 |
92e9875c767ade0707d38968390a5c281c723b3001d046363f521025f922aba9
|
File details
Details for the file ndtbl-0.2.0-py3-none-any.whl.
File metadata
- Download URL: ndtbl-0.2.0-py3-none-any.whl
- Upload date:
- Size: 15.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7f5f84c8c9241771bbece5d5bdcddc6b432efc96714fc131f9a23beeba1747b7
|
|
| MD5 |
55c2c5c693b6b18b3f2403ffdda75922
|
|
| BLAKE2b-256 |
fe93545c75f29a7cc2d5a8b8f7a23b1fdcee8d25f6bef8d1d91a005bafa17248
|