Core Data Structures¶
The voids.core sub-package defines the three primary data containers that every
workflow depends on.
Network¶
voids.core.network.Network
dataclass
¶
Store pore-network topology, geometry, labels, and metadata.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
throat_conns
|
ndarray
|
Integer array with shape |
required |
pore_coords
|
ndarray
|
Floating-point array with shape |
required |
sample
|
SampleGeometry
|
Sample-scale geometry used by porosity and permeability calculations. |
required |
provenance
|
Provenance
|
Metadata describing how the network was created or imported. |
Provenance()
|
schema_version
|
str
|
Version tag used by the serialized network schema. |
'0.1.0'
|
pore
|
dict[str, ndarray]
|
Dictionaries mapping field names to pore-wise and throat-wise arrays. |
dict()
|
throat
|
dict[str, ndarray]
|
Dictionaries mapping field names to pore-wise and throat-wise arrays. |
dict()
|
pore_labels
|
dict[str, ndarray]
|
Dictionaries of boolean masks selecting pore and throat subsets. |
dict()
|
throat_labels
|
dict[str, ndarray]
|
Dictionaries of boolean masks selecting pore and throat subsets. |
dict()
|
extra
|
dict[str, Any]
|
Additional metadata not yet promoted to the formal schema. |
dict()
|
Notes
The class represents a pore network as a graph
G = (V, E)
where pores are vertices V and throats are edges E. The array
throat_conns is the primary topological object used to construct
adjacency matrices, incidence matrices, and transport operators.
Source code in src/voids/core/network.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 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 | |
Np
property
¶
Return the number of pores.
Returns:
| Type | Description |
|---|---|
int
|
Number of rows in :attr: |
Nt
property
¶
Return the number of throats.
Returns:
| Type | Description |
|---|---|
int
|
Number of rows in :attr: |
get_pore_array
¶
Return a pore field by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Key in :attr: |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Requested pore-wise array. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If the field is not present. |
Source code in src/voids/core/network.py
get_throat_array
¶
Return a throat field by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Key in :attr: |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Requested throat-wise array. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If the field is not present. |
Source code in src/voids/core/network.py
copy
¶
Return a deep-array copy of the network.
Returns:
| Type | Description |
|---|---|
Network
|
New network instance whose topology, coordinates, field arrays, and labels are copied. |
Notes
Array-valued data are copied to avoid in-place aliasing. Metadata
containers such as :class:SampleGeometry and :class:Provenance are
reused because they are treated as immutable records in current usage.
Source code in src/voids/core/network.py
SampleGeometry¶
voids.core.sample.SampleGeometry
dataclass
¶
Store sample-scale geometry needed for bulk property calculations.
Attributes:
| Name | Type | Description |
|---|---|---|
voxel_size |
float | tuple[float, float, float] | None
|
Scalar or anisotropic voxel spacing in physical units. |
bulk_shape_voxels |
tuple[int, int, int] | None
|
Image-domain shape used to derive bulk volume when a direct value is not available. |
bulk_volume |
float | None
|
Total bulk volume in physical units. |
lengths |
dict[str, float]
|
Representative sample lengths by axis. |
cross_sections |
dict[str, float]
|
Cross-sectional areas normal to each flow axis. |
axis_map |
dict[str, str]
|
Optional mapping from custom axis names to canonical identifiers. |
units |
dict[str, str]
|
Unit metadata used for reporting and serialization. |
Source code in src/voids/core/sample.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 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 | |
resolved_bulk_volume
¶
Return the bulk volume, deriving it from voxel metadata when needed.
Returns:
| Type | Description |
|---|---|
float
|
Bulk volume of the sample. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Notes
When bulk_volume is not explicitly stored, the method computes
V_bulk = nx * ny * nz * vx * vy * vz
using either an isotropic scalar voxel size or an anisotropic voxel-size
tuple (vx, vy, vz).
Source code in src/voids/core/sample.py
length_for_axis
¶
Return the representative sample length for one axis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
axis
|
str
|
Axis key such as |
required |
Returns:
| Type | Description |
|---|---|
float
|
Length associated with the requested axis. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If no length is registered for the requested axis. |
Source code in src/voids/core/sample.py
area_for_axis
¶
Return the sample cross-section normal to one axis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
axis
|
str
|
Axis key such as |
required |
Returns:
| Type | Description |
|---|---|
float
|
Cross-sectional area used in Darcy-type calculations. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If no cross-section is registered for the requested axis. |
Source code in src/voids/core/sample.py
to_metadata
¶
Serialize the sample geometry to a JSON-friendly dictionary.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Mapping suitable for HDF5 or JSON serialization. |
Source code in src/voids/core/sample.py
from_metadata
classmethod
¶
Reconstruct sample geometry from serialized metadata.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict[str, Any]
|
Metadata dictionary previously produced by :meth: |
required |
Returns:
| Type | Description |
|---|---|
SampleGeometry
|
Reconstructed sample-geometry record. |
Source code in src/voids/core/sample.py
Provenance¶
voids.core.provenance.Provenance
dataclass
¶
Store metadata describing the origin of a network.
Attributes:
| Name | Type | Description |
|---|---|---|
source_kind |
str
|
Broad category of origin, such as |
source_version |
str | None
|
Version string of the generating package or workflow, when known. |
extraction_method |
str | None
|
Short description of the extraction or construction procedure. |
segmentation_notes |
str | None
|
Free-form notes about segmentation or preprocessing assumptions. |
voxel_size_original |
float | tuple[float, float, float] | None
|
Original voxel spacing before any physical-unit conversion. |
image_hash, preprocessing_hash |
Optional hashes identifying input images or preprocessing recipes. |
|
random_seed |
int | None
|
Seed used by any stochastic preprocessing or synthetic generator. |
created_at |
str
|
UTC timestamp encoded as an ISO 8601 string. |
user_notes |
dict[str, Any]
|
Additional JSON-serializable metadata. |
Source code in src/voids/core/provenance.py
to_metadata
¶
Serialize the provenance record to a JSON-friendly mapping.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary suitable for storage in HDF5 attributes or JSON payloads. |
Source code in src/voids/core/provenance.py
from_metadata
classmethod
¶
Construct a provenance record from serialized metadata.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict[str, Any]
|
Metadata dictionary previously produced by :meth: |
required |
Returns:
| Type | Description |
|---|---|
Provenance
|
Reconstructed provenance record. |
Source code in src/voids/core/provenance.py
Validation¶
assert_finite
¶
Validate that an array contains only finite values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Descriptive name of the array, used in the error message. |
required |
arr
|
ndarray
|
Array to validate. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the array contains |
Source code in src/voids/core/validation.py
validate_network
¶
Validate network topology, field shapes, and basic geometric sanity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
net
|
Network
|
Network to validate. |
required |
allow_parallel_throats
|
bool
|
If |
True
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If topology, field shapes, or sign conventions are invalid. |
Warns:
| Type | Description |
|---|---|
RuntimeWarning
|
If parallel throats are detected while allowed, or if recommended pore and throat fields are missing. |
Notes
The checks enforce structural constraints such as
throat_conns.shape == (Nt, 2)
and
pore_coords.shape == (Np, 3)
together with sign and dimensionality checks for commonly used geometric quantities such as volume, area, and conduit lengths.
Source code in src/voids/core/validation.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 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 | |