I/O¶
The voids.io sub-package handles serialization and import/export for canonical
networks, PoreSpy interoperability, OpenPNM interoperability, and image-volume
cases.
Network I/O And Interoperability¶
voids supports network import/export through the canonical Network data
model. The native disk format is an HDF5 schema written by save_hdf5 and read
by load_hdf5. External network interoperability is handled by adapters that
normalize topology, geometry aliases, labels, sample metadata, and provenance
before numerical use.

Supported Network Paths¶
| Path | Direction | Primary API | Notes |
|---|---|---|---|
| Canonical HDF5 | read/write | save_hdf5, load_hdf5 |
Native voids round trip for Network, SampleGeometry, Provenance, labels, properties, and JSON-compatible extra metadata |
| PoreSpy/OpenPNM-style dictionary | import | from_porespy |
Imports flat mappings with keys such as pore.coords and throat.conns; common geometry aliases are normalized |
| PoreSpy voxel-unit geometry | preprocessing | scale_porespy_geometry |
Converts common length, area, volume, and perimeter fields from voxel units to physical units for isotropic voxels |
| Cartesian boundary labels | preprocessing | ensure_cartesian_boundary_labels |
Infers labels such as pore.inlet_xmin and pore.outlet_xmax from pore coordinates |
| OpenPNM-style dictionary | export | to_openpnm_dict |
Exports a Network to a flat dictionary suitable for OpenPNM/PoreSpy-style workflows |
| OpenPNM network object | export | to_openpnm_network |
Requires optional openpnm; constructor handling is version tolerant |
| Imperial CNM text files | import | load_pnflow_cnm |
Imports *_node1.dat, *_node2.dat, *_link1.dat, and *_link2.dat files into a canonical Network |
Canonical HDF5 Round Trip¶
Use HDF5 when the goal is a native round trip for later voids
calculations:
from voids.io import load_hdf5, save_hdf5
save_hdf5(net, "network.h5")
reloaded = load_hdf5("network.h5")
The HDF5 layout stores the schema version, sample geometry, provenance, pore and
throat arrays, boolean labels, and JSON-compatible net.extra metadata.
Importing PoreSpy/OpenPNM-Style Networks¶
PoreSpy and OpenPNM commonly represent networks as flat mappings. The minimal
required topology keys are pore.coords and throat.conns:
from voids.io import (
ensure_cartesian_boundary_labels,
from_porespy,
scale_porespy_geometry,
)
scaled = scale_porespy_geometry(network_dict, voxel_size=2.5e-6)
labeled = ensure_cartesian_boundary_labels(scaled, axes=("x",))
net = from_porespy(labeled, sample=sample, provenance=provenance)
The importer maps common aliases such as throat.cross_sectional_area,
throat.total_length, pore.inscribed_diameter, and
throat.conduit_lengths.* to canonical voids fields. Two-dimensional
coordinate arrays are embedded in 3-D as (x, y, 0).
Exporting To OpenPNM-Style Objects¶
Use to_openpnm_dict when a flat mapping is enough:
Use to_openpnm_network when an actual OpenPNM object is needed:
to_openpnm_network depends on the optional openpnm package. If OpenPNM is
not installed, use the dictionary export or install the optional stack required
for the target workflow.
Importing CNM Text Networks¶
load_pnflow_cnm imports the four-file CNM text layout used by
pnextract/pnflow workflows:
from voids.io import load_pnflow_cnm
imported = load_pnflow_cnm("case_dir/case_name")
net = imported.net
The prefix should omit the _node1.dat, _node2.dat, _link1.dat, and
_link2.dat suffixes. The importer attaches sample lengths, pore/throat
geometry, boundary labels, and import metadata. It currently supports the
x-directed boundary convention used by the committed CNM benchmark files.
voids does not currently provide a general CNM exporter. For external network
export, use either canonical HDF5 or the OpenPNM-style dictionary/object
adapters, depending on the downstream solver.
Network API Reference¶
HDF5¶
voids.io.hdf5
¶
save_hdf5
¶
Serialize a network to the project HDF5 interchange format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
net
|
Network
|
Network to store. |
required |
path
|
str | Path
|
Destination file path. Parent directories must already exist. |
required |
Notes
The file layout is intentionally explicit:
/metastores schema and provenance metadata./samplestores the sample geometry payload./network/poreand/network/throatstore arrays./labelsstores boolean pore and throat labels asuint8datasets./attributeextrastores JSON-compatible auxiliary metadata.
Source code in src/voids/io/hdf5.py
load_hdf5
¶
Load a network from the project HDF5 interchange format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
Path to an HDF5 file produced by :func: |
required |
Returns:
| Type | Description |
|---|---|
Network
|
Reconstructed network object. |
Notes
Boolean labels are stored on disk as uint8 arrays for portability and are
converted back to bool arrays during import.
Source code in src/voids/io/hdf5.py
PoreSpy Import¶
voids.io.porespy
¶
scale_porespy_geometry
¶
Scale common PoreSpy geometry fields from voxel units to physical units.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
network_dict
|
Mapping[str, object]
|
PoreSpy/OpenPNM-style mapping containing keys such as |
required |
voxel_size
|
float
|
Edge length of one voxel in physical units. |
required |
Returns:
| Type | Description |
|---|---|
dict of str to object
|
New mapping with common geometric fields rescaled. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Notes
This helper assumes isotropic voxels. The conversion factors are:
- lengths:
L_phys = L_vox * voxel_size - areas:
A_phys = A_vox * voxel_size**2 - volumes:
V_phys = V_vox * voxel_size**3 - perimeters:
P_phys = P_vox * voxel_size
When throat.volume is absent but throat.cross_sectional_area and
throat.total_length are available, a simple conduit approximation is used:
throat.volume = throat.cross_sectional_area * throat.total_length
This is convenient for manufactured examples and notebook workflows, but it is still a geometric approximation rather than an exact segmented volume.
Source code in src/voids/io/porespy.py
ensure_cartesian_boundary_labels
¶
Infer Cartesian inlet and outlet pore labels from coordinates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
network_dict
|
Mapping[str, object]
|
Mapping containing at least |
required |
axes
|
tuple[str, ...] | None
|
Axes to label. If omitted, all axes present in the coordinate array are used. |
None
|
tol_fraction
|
float
|
Fraction of the domain span used as a geometric tolerance near each boundary. |
0.05
|
Returns:
| Type | Description |
|---|---|
dict of str to object
|
Updated mapping with labels such as |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the coordinate array has invalid shape, if |
Notes
For each active axis, the helper marks pores satisfying
x <= x_min + tolas inlet poresx >= x_max - tolas outlet pores
where tol = tol_fraction * max(x_max - x_min, 1e-12).
Source code in src/voids/io/porespy.py
from_porespy
¶
from_porespy(
network_dict,
*,
sample=None,
provenance=None,
strict=True,
geometry_repairs=None,
repair_seed=0,
)
Build a :class:Network from a PoreSpy/OpenPNM-style mapping.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
network_dict
|
Mapping[str, object]
|
Mapping containing PoreSpy/OpenPNM keys such as |
required |
sample
|
SampleGeometry | None
|
Sample geometry metadata attached to the resulting network. If omitted,
a default empty :class: |
None
|
provenance
|
Provenance | None
|
Provenance metadata. If omitted, a default record with
|
None
|
strict
|
bool
|
If |
True
|
geometry_repairs
|
str | None
|
Optional extraction-style preprocessing mode. Set to
|
None
|
repair_seed
|
int | None
|
Seed for any stochastic repair branch. Only used when
|
0
|
Returns:
| Type | Description |
|---|---|
Network
|
Imported network in the canonical |
Raises:
| Type | Description |
|---|---|
KeyError
|
If the required topology keys are missing. |
Notes
The importer performs several normalizations:
- PoreSpy/OpenPNM aliases are mapped to canonical
voidsnames. - Two-dimensional coordinates are embedded into 3D as
(x, y, 0). - Basic missing geometry is derived when possible.
- Common boundary aliases such as
leftandrightare mirrored toinlet_xminandoutlet_xmax.
OpenPNM-style arrays that are not part of the formal schema, such as
throat.hydraulic_size_factors, are preserved in net.extra so that
information is not silently lost.
Source code in src/voids/io/porespy.py
665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 | |
OpenPNM Export¶
voids.io.openpnm
¶
from_porespy
¶
from_porespy(
network_dict,
*,
sample=None,
provenance=None,
strict=True,
geometry_repairs=None,
repair_seed=0,
)
Build a :class:Network from a PoreSpy/OpenPNM-style mapping.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
network_dict
|
Mapping[str, object]
|
Mapping containing PoreSpy/OpenPNM keys such as |
required |
sample
|
SampleGeometry | None
|
Sample geometry metadata attached to the resulting network. If omitted,
a default empty :class: |
None
|
provenance
|
Provenance | None
|
Provenance metadata. If omitted, a default record with
|
None
|
strict
|
bool
|
If |
True
|
geometry_repairs
|
str | None
|
Optional extraction-style preprocessing mode. Set to
|
None
|
repair_seed
|
int | None
|
Seed for any stochastic repair branch. Only used when
|
0
|
Returns:
| Type | Description |
|---|---|
Network
|
Imported network in the canonical |
Raises:
| Type | Description |
|---|---|
KeyError
|
If the required topology keys are missing. |
Notes
The importer performs several normalizations:
- PoreSpy/OpenPNM aliases are mapped to canonical
voidsnames. - Two-dimensional coordinates are embedded into 3D as
(x, y, 0). - Basic missing geometry is derived when possible.
- Common boundary aliases such as
leftandrightare mirrored toinlet_xminandoutlet_xmax.
OpenPNM-style arrays that are not part of the formal schema, such as
throat.hydraulic_size_factors, are preserved in net.extra so that
information is not silently lost.
Source code in src/voids/io/porespy.py
665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 | |
to_openpnm_dict
¶
Export a network to an OpenPNM/PoreSpy-style flat dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
net
|
Network
|
Network to export. |
required |
include_extra
|
bool
|
If |
False
|
Returns:
| Type | Description |
|---|---|
dict of str to Any
|
Flat mapping using keys such as |
Notes
The mapping preserves aliases expected by :func:voids.io.porespy.from_porespy.
Conduit-length fields are emitted both under their internal names
(for round-tripping within voids) and under OpenPNM-style names
such as throat.conduit_lengths.pore1.
Source code in src/voids/io/openpnm.py
to_openpnm_network
¶
Convert a :class:Network into an OpenPNM network object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
net
|
Network
|
Network to convert. |
required |
copy_properties
|
bool
|
If |
True
|
copy_labels
|
bool
|
If |
True
|
include_extra
|
bool
|
If |
False
|
Returns:
| Type | Description |
|---|---|
Any
|
OpenPNM network object. The precise class depends on the installed OpenPNM version. |
Raises:
| Type | Description |
|---|---|
ImportError
|
If OpenPNM is not installed. |
RuntimeError
|
If a compatible OpenPNM network object cannot be instantiated. |
Notes
OpenPNM's constructor signatures vary across versions. This helper tries a small
set of known call patterns and always assigns pore.coords and
throat.conns explicitly afterward so that topology transfer is version-robust.
Source code in src/voids/io/openpnm.py
CNM Import¶
voids.io.pnflow_cnm
¶
PnflowCNMImportResult
dataclass
¶
Container for an imported Imperial College CNM network.
Attributes:
| Name | Type | Description |
|---|---|---|
net |
Network
|
Imported network ready for |
prefix |
Path
|
File prefix used to locate the CNM text files. |
box_lengths |
dict[str, float]
|
Physical sample lengths encoded in the CNM header. |
n_physical_pores |
int
|
Number of pores listed in |
n_boundary_mirror_pores |
int
|
Number of helper pores added to mimic |
Source code in src/voids/io/pnflow_cnm.py
load_pnflow_cnm
¶
load_pnflow_cnm(
prefix,
*,
boundary_axis="x",
length_unit="m",
pressure_unit="Pa",
boundary_length_epsilon=_BOUNDARY_LENGTH_EPS,
boundary_radius_scale=1.1,
pnflow_solver_box_compat=False,
)
Import an Imperial College pnextract / pnflow CNM text network.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prefix
|
str | Path
|
File prefix for the four CNM text files. For a benchmark case stored as
|
required |
boundary_axis
|
str
|
Axis along which the inlet/outlet reservoir labels are attached. The
committed Imperial CNM format is x-directed, so |
'x'
|
length_unit
|
str
|
Unit metadata attached to the resulting |
'm'
|
pressure_unit
|
str
|
Unit metadata attached to the resulting |
'm'
|
boundary_length_epsilon
|
float
|
Small positive reservoir-side pore length used to reproduce the
near-zero boundary resistance applied internally by |
_BOUNDARY_LENGTH_EPS
|
boundary_radius_scale
|
float
|
Scale factor used for mirrored inlet/outlet helper pores. This follows
the |
1.1
|
pnflow_solver_box_compat
|
bool
|
If |
False
|
Returns:
| Type | Description |
|---|---|
PnflowCNMImportResult
|
Imported network together with import metadata. |
Notes
The CNM text files store internal pores only. To match pnflow's
single-phase boundary treatment more closely, this importer inserts one
zero-volume mirrored pore for each inlet/outlet connection throat and
collapses the reservoir-side pore segment length to a tiny positive value.
Source code in src/voids/io/pnflow_cnm.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 | |
Image Volume And Surface Mesh I/O¶
voids.io.volume provides the image-volume import/export surface used by the
synthetic image workflows. The central object is VolumeData, which couples a
2-D or 3-D image array to its physical voxel spacing, length units, and
provenance metadata.

Use VolumeData when the image is intended to leave Python or feed a
continuum/FEM workflow:
from voids.io import VolumeData, save_volume_bundle
case_data = VolumeData(
values=void_image,
voxel_size=(40.0e-6, 40.0e-6, 40.0e-6),
units={"length": "m"},
metadata={"case": "macro_micro_vug"},
)
written = save_volume_bundle(
case_data,
"outputs/synthetic_case",
stem="macro_micro_vug",
formats=("raw", "npy", "h5", "nc", "tiff", "stl", "obj"),
)
Supported Formats¶
| Format | Kind | Metadata handling |
|---|---|---|
.raw |
voxel field | Written with a .raw.json sidecar containing shape, dtype, voxel size, units, and provenance metadata |
.npy |
voxel field | NumPy-native array plus .npy.json sidecar for voxel size, units, and provenance metadata |
.h5 |
voxel field | HDF5 dataset /volume plus JSON metadata attributes |
.nc |
voxel field | Basic netCDF variable volume plus metadata attributes |
.tif, .tiff |
voxel field | TIFF stack plus .tif.json or .tiff.json sidecar for voxel size, units, and provenance metadata |
.stl |
surface mesh | 3-D binary interface extracted by marching cubes using voxel_size as physical spacing |
.obj |
surface mesh | 3-D binary interface extracted by marching cubes using voxel_size as physical spacing |
STL and OBJ exports require a 3-D binary volume containing both void and solid voxels. The binary volume must be a boolean array or a numeric array whose values are limited to 0 and 1. These exports represent the void/solid interface as a triangular surface, not the full voxel field.
Loading Voxel Volumes¶
Use load_volume when only the array is needed:
Use load_volume_data when physical resolution matters for porosity maps,
permeability maps, surface exports, or external FEM/continuum solvers:
from voids.io import load_volume_data
volume_data = load_volume_data("outputs/synthetic_case/macro_micro_vug.tiff")
TIFF files may contain some resolution tags in particular software workflows,
but they should not be treated as a reliable source of 3-D voxel spacing. If the
TIFF was not written by voids with its JSON sidecar, pass the voxel size
explicitly:
external_scan = load_volume_data(
"micro_ct_stack.tiff",
voxel_size=(40.0e-6, 40.0e-6, 40.0e-6),
units={"length": "m"},
)
Raw binary files have no self-describing shape, dtype, or voxel resolution. If
the voids sidecar is absent, provide shape, dtype, and voxel size explicitly
when those quantities matter:
volume_data = load_volume_data(
"macro_micro_vug.raw",
shape=(160, 160, 160),
dtype="uint8",
voxel_size=(40.0e-6, 40.0e-6, 40.0e-6),
units={"length": "m"},
)
Loading Surface Meshes¶
Surface meshes can be read back with:
from voids.io import load_surface_mesh
mesh = load_surface_mesh("outputs/synthetic_case/macro_micro_vug.obj")
Surface files are geometric interchange files. They do not replace the voxel field when voxel-wise phase information is needed.
voids.io.volume
¶
SurfaceMesh
dataclass
¶
Triangular surface mesh used for STL/OBJ interchange.
Attributes:
| Name | Type | Description |
|---|---|---|
vertices |
ndarray
|
Floating-point vertex coordinates with shape |
faces |
ndarray
|
Integer triangular face connectivity with shape |
metadata |
dict[str, Any]
|
JSON-serializable provenance metadata. |
Source code in src/voids/io/volume.py
VolumeData
dataclass
¶
Voxel image together with physical spacing and provenance metadata.
Attributes:
| Name | Type | Description |
|---|---|---|
values |
ndarray
|
Two- or three-dimensional image array. |
voxel_size |
float | Sequence[float]
|
Physical spacing along each image axis. A scalar means isotropic spacing; a sequence must have one entry per array dimension. |
units |
dict[str, str]
|
Unit metadata for the spacing. By convention, |
metadata |
dict[str, Any]
|
JSON-serializable provenance metadata. |
Source code in src/voids/io/volume.py
save_volume
¶
save_volume(
volume,
path,
*,
file_format=None,
metadata=None,
raw_dtype=None,
hdf5_dataset="volume",
netcdf_variable="volume",
voxel_size=None,
units=None,
)
Save a 2D/3D synthetic image volume or surface mesh.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
volume
|
VolumeData | ndarray
|
Two- or three-dimensional image, or :class: |
required |
path
|
str | Path
|
Destination path. Supported suffixes are |
required |
file_format
|
str | None
|
Optional explicit format when the suffix is ambiguous. |
None
|
metadata
|
dict[str, Any] | None
|
JSON-serializable provenance metadata stored by metadata-capable formats. |
None
|
raw_dtype
|
str | dtype[Any] | None
|
Storage dtype for raw binary export. Defaults to |
None
|
hdf5_dataset
|
str
|
Dataset/variable names for HDF5 and netCDF. |
'volume'
|
netcdf_variable
|
str
|
Dataset/variable names for HDF5 and netCDF. |
'volume'
|
voxel_size
|
float | Sequence[float] | None
|
Physical voxel spacing. A scalar means isotropic spacing; a sequence must have one entry per image axis. The value is stored in metadata for voxel formats and used as marching-cubes spacing for STL/OBJ surfaces. |
None
|
units
|
dict[str, str] | None
|
Unit metadata for |
None
|
Returns:
| Type | Description |
|---|---|
Path
|
Path written. |
Notes
Raw, NumPy, and TIFF files do not reliably carry the physical voxel spacing
needed by downstream solvers, so a JSON sidecar with suffix .<ext>.json
is written next to those files.
Source code in src/voids/io/volume.py
339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 | |
load_volume
¶
load_volume(
path,
*,
file_format=None,
shape=None,
dtype=None,
hdf5_dataset="volume",
netcdf_variable="volume",
)
Load a 2D/3D image volume from raw, NumPy, HDF5, netCDF, or TIFF.
Source code in src/voids/io/volume.py
load_volume_data
¶
load_volume_data(
path,
*,
file_format=None,
shape=None,
dtype=None,
hdf5_dataset="volume",
netcdf_variable="volume",
voxel_size=None,
units=None,
metadata=None,
)
Load a volume together with voxel spacing, units, and metadata.
load_volume intentionally returns only the image array. Use this helper
whenever physical voxel resolution matters, especially for external TIFF,
NumPy, or raw files that may not have a reliable sidecar.
Source code in src/voids/io/volume.py
surface_mesh_from_binary_volume
¶
Extract a triangular surface mesh from a 3D binary void image.
The surface is the interface between True void voxels and False solid
voxels, computed with marching cubes. Coordinates are scaled by
voxel_size.
Source code in src/voids/io/volume.py
save_surface_mesh
¶
Save a triangular surface mesh as ASCII STL or OBJ.
mesh can be a :class:SurfaceMesh or a 3D binary volume, in which case
marching cubes is applied first.
Source code in src/voids/io/volume.py
load_surface_mesh
¶
Load an STL or OBJ triangular surface mesh.
Source code in src/voids/io/volume.py
save_volume_bundle
¶
save_volume_bundle(
volume,
directory,
*,
stem="synthetic_case",
formats=("raw", "npy", "h5", "stl", "obj"),
metadata=None,
voxel_size=None,
units=None,
)
Export one synthetic case to several interchange formats.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
volume
|
VolumeData | ndarray
|
2D or 3D image. STL/OBJ formats require a 3D binary volume. |
required |
directory
|
str | Path
|
Destination directory. |
required |
stem
|
str
|
Base filename without suffix. |
'synthetic_case'
|
formats
|
Sequence[str]
|
Iterable of format labels such as |
('raw', 'npy', 'h5', 'stl', 'obj')
|
metadata
|
dict[str, Any] | None
|
Forwarded to :func: |
None
|
voxel_size
|
dict[str, Any] | None
|
Forwarded to :func: |
None
|
units
|
dict[str, Any] | None
|
Forwarded to :func: |
None
|