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 workflows using NumPy arrays
🔧 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, :])
write_group refuses to write files larger than 128 MiB by default. Pass
max_size_mib=... when a larger output is intentional.
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
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.
Release files for ndtbl 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ndtbl-0.3.0.tar.gz | 20.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ndtbl-0.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 36.4 kB
Release files / ndtbl-0.3.0.tar.gz
| Download URL | ndtbl-0.3.0.tar.gz |
|---|---|
| Size | 20.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8ce8d87618292d703be6a419f56d393715075459509010c08f32dcd5a0ce9880
|
|
BLAKE2b-256 checksum How to use checksums |
8930e6f5df47bd6b9b7c6d745afbaee2f875075d3cf771615fa4719e0de85b15
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","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}
|
Release files / ndtbl-0.3.0-py3-none-any.whl
| Download URL | ndtbl-0.3.0-py3-none-any.whl |
|---|---|
| Size | 16.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4d07389616feb7721dd5554b9bddc57653665be47864aaca35b17057dafe0467
|
|
BLAKE2b-256 checksum How to use checksums |
0dc38affd6e7f53991a9d5bdd363be6d104eb88451dfcc88048cb58b3bb76ca2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","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}
|