tecio-python 0.2.0__py3-none-any.whl → 0.2.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- tecio/_containers.py +2 -2
- tecio/_io.py +46 -38
- tecio/_meta.py +4 -4
- tecio/cli/__init__.py +3 -3
- tecio/cli/tec2mat.py +21 -21
- tecio/cli/tecaux.py +971 -0
- tecio/cli/tecdump.py +4 -4
- tecio/cli/tecextract.py +6 -6
- tecio/cli/tecfix.py +4 -4
- tecio/cli/tecmerge.py +12 -12
- tecio/cli/teconvert.py +3 -3
- tecio/cli/tecscale.py +7 -7
- tecio/cli/tecslice.py +12 -12
- tecio/cli/tecstats.py +4 -4
- tecio/dat/__init__.py +1 -1
- tecio/dat/_read.py +33 -21
- tecio/dat/_write.py +22 -22
- tecio/libtecio.py +73 -16
- tecio/plt/_read.py +21 -21
- tecio/plt/_write.py +35 -35
- tecio/szl/_read.py +3 -3
- tecio/szl/_write.py +50 -28
- {tecio_python-0.2.0.dist-info → tecio_python-0.2.2.dist-info}/METADATA +1 -1
- tecio_python-0.2.2.dist-info/RECORD +33 -0
- {tecio_python-0.2.0.dist-info → tecio_python-0.2.2.dist-info}/entry_points.txt +1 -0
- {tecio_python-0.2.0.dist-info → tecio_python-0.2.2.dist-info}/licenses/NOTICE +2 -2
- tecio_python-0.2.0.dist-info/RECORD +0 -32
- {tecio_python-0.2.0.dist-info → tecio_python-0.2.2.dist-info}/WHEEL +0 -0
- {tecio_python-0.2.0.dist-info → tecio_python-0.2.2.dist-info}/licenses/LICENSE +0 -0
- {tecio_python-0.2.0.dist-info → tecio_python-0.2.2.dist-info}/top_level.txt +0 -0
tecio/dat/_write.py
CHANGED
|
@@ -250,9 +250,9 @@ def _stage_point_rows(
|
|
|
250
250
|
) -> None:
|
|
251
251
|
"""Write *cols* as ``DATAPACKING=POINT`` rows into *buf*.
|
|
252
252
|
|
|
253
|
-
Each element of *cols* is the flat value array for one variable.
|
|
253
|
+
Each element of *cols* is the flat value array for one variable. One tab-separated
|
|
254
254
|
row is written per point (node or cell): all variable values for that point appear
|
|
255
|
-
on the same line.
|
|
255
|
+
on the same line. All column arrays must have the same length. Does nothing when
|
|
256
256
|
*cols* is empty.
|
|
257
257
|
|
|
258
258
|
Example:
|
|
@@ -288,12 +288,12 @@ class Write:
|
|
|
288
288
|
path:
|
|
289
289
|
Destination file path.
|
|
290
290
|
title:
|
|
291
|
-
Dataset title.
|
|
291
|
+
Dataset title. Defaults to ``"untitled"``.
|
|
292
292
|
variables:
|
|
293
293
|
Variable name list. ``None`` defers file creation until the first
|
|
294
294
|
zone-writing call (lazy open).
|
|
295
295
|
file_type:
|
|
296
|
-
:class:`FileType` enum.
|
|
296
|
+
:class:`FileType` enum. Defaults to :attr:`FileType.FULL`.
|
|
297
297
|
precision:
|
|
298
298
|
Uniform floating point precision for the whole file. :attr:`DataType.FLOAT`
|
|
299
299
|
(default; ``"single"``) or :attr:`DataType.DOUBLE` (``"double"``). Also
|
|
@@ -509,24 +509,24 @@ class Write:
|
|
|
509
509
|
Zone dimensions are inferred from the shape of the first NODAL array.
|
|
510
510
|
|
|
511
511
|
Args:
|
|
512
|
-
data: One NumPy array per dataset variable.
|
|
512
|
+
data: One NumPy array per dataset variable. Array shape is used
|
|
513
513
|
to infer ``imax``, ``jmax``, and ``kmax``; Fortran
|
|
514
|
-
(column-major) order is assumed.
|
|
514
|
+
(column-major) order is assumed. Pass ``None`` to write a
|
|
515
515
|
zone header only.
|
|
516
|
-
title: Zone title.
|
|
517
|
-
variables: Variable name list.
|
|
516
|
+
title: Zone title. Defaults to ``"IJK_Zone_{current_zone + 1}"``.
|
|
517
|
+
variables: Variable name list. Required on the first call when the
|
|
518
518
|
file has not been opened yet (lazy-open path); ignored once
|
|
519
519
|
the file is already initialised. Default to ``[V1, V2, V3,
|
|
520
520
|
...]`` if not provided in open or zone call.
|
|
521
|
-
value_locations: Per-variable :class:`~libtecio.ValueLocation`.
|
|
521
|
+
value_locations: Per-variable :class:`~libtecio.ValueLocation`. Defaults to
|
|
522
522
|
all ``NODAL``.
|
|
523
|
-
passive_vars: Per-variable passive flags.
|
|
523
|
+
passive_vars: Per-variable passive flags. Defaults to all active
|
|
524
524
|
(``False``).
|
|
525
|
-
var_sharing: Per-variable share-from zone index (1-based).
|
|
525
|
+
var_sharing: Per-variable share-from zone index (1-based). Defaults to
|
|
526
526
|
no sharing (all zeros).
|
|
527
|
-
solution_time: Solution time for transient data.
|
|
527
|
+
solution_time: Solution time for transient data. Use ``0.0`` for static
|
|
528
528
|
zones. Default to ``0.0`` if not defined.
|
|
529
|
-
strand_id: Strand ID for transient data.
|
|
529
|
+
strand_id: Strand ID for transient data. Use ``0`` for static
|
|
530
530
|
zones. Default to ``0`` (static) if not defined.
|
|
531
531
|
aux: Zone-level auxiliary data as ``{name: value}`` string
|
|
532
532
|
pairs.
|
|
@@ -795,12 +795,12 @@ class Write:
|
|
|
795
795
|
``FEPOLYGON`` and ``FEPOLYHEDRON`` raise :exc:`NotImplementedError`.
|
|
796
796
|
|
|
797
797
|
Args:
|
|
798
|
-
data: Sequence of 1-D arrays, one per dataset variable.
|
|
798
|
+
data: Sequence of 1-D arrays, one per dataset variable. NODAL
|
|
799
799
|
arrays must have length ``num_nodes``; CELL_CENTERED arrays
|
|
800
800
|
must have length ``num_cells``. ``num_nodes`` and
|
|
801
801
|
``num_cells`` are inferred from ``node_map`` (or from the
|
|
802
802
|
``con_sharing`` source zone when ``node_map`` is omitted).
|
|
803
|
-
zone_type: FE zone type from the ZoneType enum.
|
|
803
|
+
zone_type: FE zone type from the ZoneType enum. Must be one of the
|
|
804
804
|
types in ``_FE_SIMPLE``.
|
|
805
805
|
node_map: Integer array of shape ``(num_cells, nodes_per_cell)``
|
|
806
806
|
containing 1-based node indices. 32- or 64-bit write is
|
|
@@ -808,17 +808,17 @@ class Write:
|
|
|
808
808
|
Required unless ``con_sharing`` is set, in which case the
|
|
809
809
|
connectivity -- and the node/cell counts derived from it --
|
|
810
810
|
are inherited from the source zone instead.
|
|
811
|
-
title: Zone title string.
|
|
811
|
+
title: Zone title string. Defaults to ``"FE_Zone_{current_zone +
|
|
812
812
|
1}"`` if not provided.
|
|
813
|
-
variables: Variable name list.
|
|
814
|
-
been opened yet (lazy-open path).
|
|
813
|
+
variables: Variable name list. Required only when the file has not
|
|
814
|
+
been opened yet (lazy-open path). Ignored on subsequent
|
|
815
815
|
zones once the file is already initialised. Default to
|
|
816
816
|
``[V1, V2, V3, ...]`` if not provided in open or zone call.
|
|
817
|
-
value_locations: Per-variable ValueLocation.
|
|
818
|
-
passive_vars: Per-variable passive flags.
|
|
817
|
+
value_locations: Per-variable ValueLocation. Defaults to all NODAL.
|
|
818
|
+
passive_vars: Per-variable passive flags. Defaults to all active
|
|
819
819
|
(False).
|
|
820
|
-
var_sharing: Per-variable share from zone index.
|
|
821
|
-
sharing.
|
|
820
|
+
var_sharing: Per-variable share from zone index. Defaults to no
|
|
821
|
+
sharing. Cross-checked against ``node_map`` /
|
|
822
822
|
``con_sharing`` for a consistent node/cell count.
|
|
823
823
|
con_sharing: Optional zone index that the connectivity is shared from.
|
|
824
824
|
``None`` or ``0`` indicates no sharing (this zone owns its
|
tecio/libtecio.py
CHANGED
|
@@ -234,7 +234,7 @@ class DataPacking(Enum):
|
|
|
234
234
|
"""Zone data packing order for ASCII (``.dat``) files.
|
|
235
235
|
|
|
236
236
|
Controls whether data is laid out variable-by-variable or point-by-point
|
|
237
|
-
in the ASCII file.
|
|
237
|
+
in the ASCII file. The ``DATAPACKING`` keyword in a zone header takes one
|
|
238
238
|
of these two values.
|
|
239
239
|
|
|
240
240
|
.. list-table::
|
|
@@ -693,6 +693,12 @@ lib.tecFileWriterClose.restype = ctypes.c_int32
|
|
|
693
693
|
lib.tecFileWriterClose.argtypes = [
|
|
694
694
|
ctypes.POINTER(ctypes.c_void_p),
|
|
695
695
|
]
|
|
696
|
+
lib.tecFileWriterFlush.restype = ctypes.c_int32
|
|
697
|
+
lib.tecFileWriterFlush.argtypes = [
|
|
698
|
+
ctypes.c_void_p, # fileHandle
|
|
699
|
+
ctypes.c_int32, # numZonesToRetain
|
|
700
|
+
ctypes.POINTER(ctypes.c_int32), # zonesToRetain
|
|
701
|
+
]
|
|
696
702
|
|
|
697
703
|
# Write Zone Headers
|
|
698
704
|
lib.tecZoneCreateIJK.restype = ctypes.c_int32
|
|
@@ -1071,7 +1077,7 @@ lib.tecusr142.argtypes = [
|
|
|
1071
1077
|
# --------------------------------------------------------------------------------------
|
|
1072
1078
|
|
|
1073
1079
|
|
|
1074
|
-
# Reading SZL files
|
|
1080
|
+
# -- Reading SZL files -----------------------------------------------------------------
|
|
1075
1081
|
def tec_file_reader_open(file_name: str) -> ctypes.c_void_p:
|
|
1076
1082
|
"""Open an SZL file for reading.
|
|
1077
1083
|
|
|
@@ -1204,7 +1210,7 @@ def tec_data_set_get_num_zones(handle: ctypes.c_void_p) -> int:
|
|
|
1204
1210
|
return num_zones.value
|
|
1205
1211
|
|
|
1206
1212
|
|
|
1207
|
-
# Reading SZL zones
|
|
1213
|
+
# -- Reading SZL zones -----------------------------------------------------------------
|
|
1208
1214
|
def tec_zone_get_ijk(handle: ctypes.c_void_p, zone_index: int) -> tuple[int, int, int]:
|
|
1209
1215
|
"""Get zone dimensions (ORDERED) or node/element counts (FE).
|
|
1210
1216
|
|
|
@@ -1488,7 +1494,7 @@ def tec_zone_node_map_get(
|
|
|
1488
1494
|
return np.ctypeslib.as_array(nodemap).reshape(num_elements, nodes_per_cell)
|
|
1489
1495
|
|
|
1490
1496
|
|
|
1491
|
-
# Reading SZL variable data
|
|
1497
|
+
# -- Reading SZL variable data ---------------------------------------------------------
|
|
1492
1498
|
def tec_var_get_name(handle: ctypes.c_void_p, var_index: int) -> str:
|
|
1493
1499
|
"""Get a variable name by index.
|
|
1494
1500
|
|
|
@@ -1962,7 +1968,7 @@ def tec_zone_var_get_uint8_values(
|
|
|
1962
1968
|
return np.ctypeslib.as_array(values)
|
|
1963
1969
|
|
|
1964
1970
|
|
|
1965
|
-
# Reading SZL aux data
|
|
1971
|
+
# -- Reading SZL aux data --------------------------------------------------------------
|
|
1966
1972
|
def tec_data_set_aux_data_get_num_items(handle: ctypes.c_void_p) -> int:
|
|
1967
1973
|
"""Get the number of dataset-level auxiliary data items.
|
|
1968
1974
|
|
|
@@ -2157,7 +2163,7 @@ def tec_zone_aux_data_get_item(
|
|
|
2157
2163
|
# --------------------------------------------------------------------------------------
|
|
2158
2164
|
|
|
2159
2165
|
|
|
2160
|
-
# Initialization and File Handling
|
|
2166
|
+
# -- Initialization and File Handling --------------------------------------------------
|
|
2161
2167
|
def tec_file_writer_open(
|
|
2162
2168
|
filename: str,
|
|
2163
2169
|
variables: Sequence[str],
|
|
@@ -2225,7 +2231,58 @@ def tec_file_writer_close(handle: ctypes.c_void_p) -> None:
|
|
|
2225
2231
|
)
|
|
2226
2232
|
|
|
2227
2233
|
|
|
2228
|
-
|
|
2234
|
+
def tec_file_writer_flush(
|
|
2235
|
+
handle: ctypes.c_void_p,
|
|
2236
|
+
num_zones_to_retain: int = 0,
|
|
2237
|
+
zones_to_retain: Sequence[int] | None = None,
|
|
2238
|
+
) -> None:
|
|
2239
|
+
"""Flush written zone data to a temporary intermediate file.
|
|
2240
|
+
|
|
2241
|
+
Args:
|
|
2242
|
+
handle (ctypes.c_void_p): Writer handle.
|
|
2243
|
+
num_zones_to_retain (int): Number of zones to keep in memory.
|
|
2244
|
+
zones_to_retain (Sequence[int] | None): 1-based zone indices to retain.
|
|
2245
|
+
|
|
2246
|
+
Raises:
|
|
2247
|
+
TecioError: On C library error.
|
|
2248
|
+
|
|
2249
|
+
Important:
|
|
2250
|
+
SZL Only!
|
|
2251
|
+
|
|
2252
|
+
Note:
|
|
2253
|
+
Used to reduce memory usage for large files. All zone data written so far, other
|
|
2254
|
+
than any zones listed in ``zones_to_retain``, is written out to a temporary file
|
|
2255
|
+
on disk and released from memory.
|
|
2256
|
+
|
|
2257
|
+
Note:
|
|
2258
|
+
Retained zones can still be modified.
|
|
2259
|
+
|
|
2260
|
+
Note:
|
|
2261
|
+
Temporary files created by flushing are merged into the final output file when
|
|
2262
|
+
:func:`tec_file_writer_close` is called.
|
|
2263
|
+
"""
|
|
2264
|
+
zones_ptr = None
|
|
2265
|
+
if zones_to_retain is not None and len(zones_to_retain) > 0:
|
|
2266
|
+
zones_array = (ctypes.c_int32 * len(zones_to_retain))(*zones_to_retain)
|
|
2267
|
+
zones_ptr = ctypes.cast(zones_array, ctypes.POINTER(ctypes.c_int32))
|
|
2268
|
+
else:
|
|
2269
|
+
zones_ptr = ctypes.POINTER(ctypes.c_int32)()
|
|
2270
|
+
|
|
2271
|
+
ret = lib.tecFileWriterFlush(
|
|
2272
|
+
handle,
|
|
2273
|
+
ctypes.c_int32(num_zones_to_retain),
|
|
2274
|
+
zones_ptr,
|
|
2275
|
+
)
|
|
2276
|
+
if ret != 0:
|
|
2277
|
+
raise TecioError(
|
|
2278
|
+
f"tecFileWriterFlush Error: handle={handle}, "
|
|
2279
|
+
f"num_zones_to_retain={num_zones_to_retain}, "
|
|
2280
|
+
f"zones_to_retain={zones_to_retain}, "
|
|
2281
|
+
f"return_code={ret}"
|
|
2282
|
+
)
|
|
2283
|
+
|
|
2284
|
+
|
|
2285
|
+
# -- Write Zone Headers ----------------------------------------------------------------
|
|
2229
2286
|
def tec_zone_create_ijk(
|
|
2230
2287
|
handle: ctypes.c_void_p,
|
|
2231
2288
|
zone_title: str,
|
|
@@ -2417,7 +2474,7 @@ def tec_zone_create_fe(
|
|
|
2417
2474
|
return zone_out.value
|
|
2418
2475
|
|
|
2419
2476
|
|
|
2420
|
-
# Optional fields
|
|
2477
|
+
# -- Optional fields -------------------------------------------------------------------
|
|
2421
2478
|
def tec_zone_set_unsteady_options(
|
|
2422
2479
|
handle: ctypes.c_void_p, zone: int, strand: int = 0, solution_time: float = 0.0
|
|
2423
2480
|
) -> None:
|
|
@@ -2532,7 +2589,7 @@ def tec_zone_add_aux_data(
|
|
|
2532
2589
|
)
|
|
2533
2590
|
|
|
2534
2591
|
|
|
2535
|
-
#
|
|
2592
|
+
# -- Write variable value functions ----------------------------------------------------
|
|
2536
2593
|
def tec_zone_var_write_double_values(
|
|
2537
2594
|
handle: ctypes.c_void_p, zone: int, var: int, values: npt.ArrayLike
|
|
2538
2595
|
) -> None:
|
|
@@ -2690,7 +2747,7 @@ def tec_zone_var_write_uint8_values(
|
|
|
2690
2747
|
)
|
|
2691
2748
|
|
|
2692
2749
|
|
|
2693
|
-
# Write Zone Connectivity (FE zones only)
|
|
2750
|
+
# -- Write Zone Connectivity (FE zones only) -------------------------------------------
|
|
2694
2751
|
def tec_zone_node_map_write32(
|
|
2695
2752
|
handle: ctypes.c_void_p,
|
|
2696
2753
|
zone: int,
|
|
@@ -2889,7 +2946,7 @@ def tec_zone_face_nbr_write_connections64(
|
|
|
2889
2946
|
# --------------------------------------------------------------------------------------
|
|
2890
2947
|
|
|
2891
2948
|
|
|
2892
|
-
# File initialization and finalization
|
|
2949
|
+
# -- File initialization and finalization ----------------------------------------------
|
|
2893
2950
|
def tecini142(
|
|
2894
2951
|
filename: str,
|
|
2895
2952
|
variables: Sequence[str],
|
|
@@ -3039,7 +3096,7 @@ def tecforeign142(output_foreign_byte_order: int) -> None:
|
|
|
3039
3096
|
raise TecioError(f"tecforeign142 Error: return_code={ret}")
|
|
3040
3097
|
|
|
3041
3098
|
|
|
3042
|
-
# Zone creation
|
|
3099
|
+
# -- Zone creation ---------------------------------------------------------------------
|
|
3043
3100
|
def teczne142(
|
|
3044
3101
|
zone_title: str,
|
|
3045
3102
|
zone_type: int | ZoneType,
|
|
@@ -3329,7 +3386,7 @@ def tecznefemixed142(
|
|
|
3329
3386
|
)
|
|
3330
3387
|
|
|
3331
3388
|
|
|
3332
|
-
# Data writing
|
|
3389
|
+
# -- Data writing ----------------------------------------------------------------------
|
|
3333
3390
|
def tecdat142(
|
|
3334
3391
|
field_data: npt.ArrayLike,
|
|
3335
3392
|
is_double: bool = True,
|
|
@@ -3379,7 +3436,7 @@ def tecdat142(
|
|
|
3379
3436
|
)
|
|
3380
3437
|
|
|
3381
3438
|
|
|
3382
|
-
# Connectivity writing
|
|
3439
|
+
# -- Connectivity writing --------------------------------------------------------------
|
|
3383
3440
|
def tecnode142(nodes: npt.ArrayLike) -> None:
|
|
3384
3441
|
"""Write node connectivity for an FE zone (classic API).
|
|
3385
3442
|
|
|
@@ -3538,7 +3595,7 @@ def tecpolybconn142(
|
|
|
3538
3595
|
)
|
|
3539
3596
|
|
|
3540
3597
|
|
|
3541
|
-
# Auxiliary data
|
|
3598
|
+
# -- Auxiliary data --------------------------------------------------------------------
|
|
3542
3599
|
def tecauxstr142(name: str, value: str) -> None:
|
|
3543
3600
|
"""Add dataset-level auxiliary data (classic API).
|
|
3544
3601
|
|
|
@@ -3613,7 +3670,7 @@ def teczauxstr142(name: str, value: str) -> None:
|
|
|
3613
3670
|
)
|
|
3614
3671
|
|
|
3615
3672
|
|
|
3616
|
-
# User-defined data (custom records)
|
|
3673
|
+
# -- User-defined data (custom records) ------------------------------------------------
|
|
3617
3674
|
def tecusr142(user_rec: str) -> None:
|
|
3618
3675
|
"""Write a user-defined data record (classic API).
|
|
3619
3676
|
|
tecio/plt/_read.py
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
r"""Native binary reader for Tecplot PLT (``.plt``) files.
|
|
2
2
|
|
|
3
3
|
This module provides a pure-Python / NumPy reader for Tecplot PLT binary files (format
|
|
4
|
-
versions v112 and v191).
|
|
4
|
+
versions v112 and v191). It is a **standalone debugging module** intended to be
|
|
5
5
|
integrated into the existing :mod:`plt` module once validated.
|
|
6
6
|
|
|
7
7
|
Notes:
|
|
8
8
|
* **No byte-swapping boilerplate.** The INT32 value of ``1`` written immediately
|
|
9
|
-
after the magic number is used to detect endianness at open time.
|
|
9
|
+
after the magic number is used to detect endianness at open time. All subsequent
|
|
10
10
|
reads use the correct NumPy byte-order prefix (``"<"`` or ``">"``).
|
|
11
11
|
* **Lazy variable data.** Zone and variable *metadata* is parsed during ``__init__``
|
|
12
|
-
and stored as lightweight dataclass attributes.
|
|
12
|
+
and stored as lightweight dataclass attributes. Actual numeric data is read from
|
|
13
13
|
disk only when ``.values`` (or ``.get_values()``) is called, matching the
|
|
14
14
|
behaviour of :class:`szl.ReadVariable`.
|
|
15
15
|
* **No text / geometry support.** Header records with markers 399.0 (geometry) and
|
|
16
16
|
499.0 (text) are detected and skipped without parsing their contents.
|
|
17
17
|
* **v112 and v191 zone headers.** Zone marker ``299.0`` → v112 header; ``298.0`` →
|
|
18
|
-
v191 header.
|
|
18
|
+
v191 header. Both are fully supported.
|
|
19
19
|
|
|
20
20
|
Limitations
|
|
21
21
|
* FEPOLYGON and FEPOLYHEDRON zones are parsed for metadata but face-map reading is
|
|
@@ -92,7 +92,7 @@ _DATATYPE_DTYPE: dict[DataType, str] = {
|
|
|
92
92
|
DataType.BYTE: "u1",
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
# PLT format variable location integers → ValueLocation enum.
|
|
95
|
+
# PLT format variable location integers → ValueLocation enum. The PLT spec uses 0 =
|
|
96
96
|
# Node, 1 = Cell Centered (format guide §IV.iv), which is the opposite of the
|
|
97
97
|
# ValueLocation enum (CELL_CENTERED=0, NODAL=1).
|
|
98
98
|
_PLT_VALUELOCATION_MAP: dict[int, ValueLocation] = {
|
|
@@ -155,7 +155,7 @@ def _read_string(fp: io.BufferedIOBase, byte_order: str) -> str:
|
|
|
155
155
|
"""Read a null-terminated string stored as INT32 code-points.
|
|
156
156
|
|
|
157
157
|
The PLT format stores each character as a 4-byte integer (see Note 1 of the format
|
|
158
|
-
spec).
|
|
158
|
+
spec). The string is terminated by a zero INT32.
|
|
159
159
|
"""
|
|
160
160
|
chars: list[str] = []
|
|
161
161
|
while True:
|
|
@@ -250,7 +250,7 @@ class _ZoneMeta:
|
|
|
250
250
|
class ReadAuxData:
|
|
251
251
|
"""Dictionary-like interface for PLT auxiliary data.
|
|
252
252
|
|
|
253
|
-
Values are stored as plain Python strings.
|
|
253
|
+
Values are stored as plain Python strings. Convenience converters ``as_int``,
|
|
254
254
|
``as_float``, and ``as_bool`` are provided to match the :class:`szl.ReadAuxData`
|
|
255
255
|
API.
|
|
256
256
|
"""
|
|
@@ -376,11 +376,11 @@ class ReadVariable:
|
|
|
376
376
|
def _resolve_data_meta(self) -> _ZoneMeta | None:
|
|
377
377
|
"""Return the :class:`_ZoneMeta` that owns this variable's data.
|
|
378
378
|
|
|
379
|
-
For a variable this zone stores itself this is simply ``self._meta``.
|
|
379
|
+
For a variable this zone stores itself this is simply ``self._meta``. For a
|
|
380
380
|
shared variable, the chain of per-variable ``shared_zone`` references is
|
|
381
381
|
followed to the owning zone (with a cycle/range guard against malformed
|
|
382
382
|
files) -- the variable-level analogue of
|
|
383
|
-
:meth:`ReadZone._resolve_connectivity_meta`.
|
|
383
|
+
:meth:`ReadZone._resolve_connectivity_meta`. Returns ``None`` when the
|
|
384
384
|
share cannot be resolved, e.g. when ``all_metas`` was not supplied at
|
|
385
385
|
construction.
|
|
386
386
|
"""
|
|
@@ -511,7 +511,7 @@ class ReadVariable:
|
|
|
511
511
|
return None
|
|
512
512
|
|
|
513
513
|
# Resolve to the zone that actually owns this variable's data (self for unshared
|
|
514
|
-
# variables, the share-chain source otherwise).
|
|
514
|
+
# variables, the share-chain source otherwise). The resolved meta describes the
|
|
515
515
|
# on-disk block being read, so it also drives the count, dtype, and ordered-zone
|
|
516
516
|
# reshape/ghost-trim logic below.
|
|
517
517
|
meta = self._resolve_data_meta()
|
|
@@ -561,7 +561,7 @@ class ReadVariable:
|
|
|
561
561
|
if full_read and meta.zone_type == ZoneType.ORDERED:
|
|
562
562
|
ni, nj, nk = meta.i_max, meta.j_max, meta.k_max
|
|
563
563
|
if meta.value_locations[self.var_index - 1] == ValueLocation.CELL_CENTERED:
|
|
564
|
-
# On disk: i * j * (k-1) values in Fortran order.
|
|
564
|
+
# On disk: i * j * (k-1) values in Fortran order. Ghost padding
|
|
565
565
|
# occupies the last row in I and J after reshape, so reshape to (ni, nj,
|
|
566
566
|
# nk-1) then slice to (ni-1, nj-1, nk-1) to discard the ghost values and
|
|
567
567
|
# return only significant cells.
|
|
@@ -727,7 +727,7 @@ class ReadZone:
|
|
|
727
727
|
) -> npt.NDArray | None | tuple[npt.NDArray | None, ...]:
|
|
728
728
|
"""Return variable data array(s) for this zone.
|
|
729
729
|
|
|
730
|
-
A single key (0-based index or exact name) returns one array.
|
|
730
|
+
A single key (0-based index or exact name) returns one array. A list of exact
|
|
731
731
|
names returns a tuple of arrays in the order given, suitable for unpacking::
|
|
732
732
|
|
|
733
733
|
p = zone.get_array("p")
|
|
@@ -735,7 +735,7 @@ class ReadZone:
|
|
|
735
735
|
|
|
736
736
|
Returns:
|
|
737
737
|
One array (or ``None`` if the variable is passive or shared) for a scalar
|
|
738
|
-
key; a tuple of such arrays for a list of names.
|
|
738
|
+
key; a tuple of such arrays for a list of names. A single-element list
|
|
739
739
|
yields a 1-tuple, not a bare array.
|
|
740
740
|
|
|
741
741
|
Raises:
|
|
@@ -750,10 +750,10 @@ class ReadZone:
|
|
|
750
750
|
def _resolve_connectivity_meta(self) -> _ZoneMeta | None:
|
|
751
751
|
"""Return the :class:`_ZoneMeta` that owns this zone's connectivity.
|
|
752
752
|
|
|
753
|
-
For a zone with its own connectivity this is simply ``self._meta``.
|
|
753
|
+
For a zone with its own connectivity this is simply ``self._meta``. For a zone
|
|
754
754
|
that shares connectivity, the chain of ``connectivity_shared_zone`` references
|
|
755
755
|
is followed to the owning zone (with a cycle/range guard against malformed
|
|
756
|
-
files).
|
|
756
|
+
files). Returns ``None`` when the share cannot be resolved -- e.g. when
|
|
757
757
|
``all_metas`` was not supplied at construction.
|
|
758
758
|
"""
|
|
759
759
|
meta = self._meta
|
|
@@ -839,7 +839,7 @@ class ReadZone:
|
|
|
839
839
|
class _PltParser:
|
|
840
840
|
"""Low-level PLT binary parser.
|
|
841
841
|
|
|
842
|
-
Called once from :class:`Read.__init__`.
|
|
842
|
+
Called once from :class:`Read.__init__`. After construction the following
|
|
843
843
|
attributes are available:
|
|
844
844
|
|
|
845
845
|
=================== ===============================================
|
|
@@ -1137,7 +1137,7 @@ class _PltParser:
|
|
|
1137
1137
|
def _parse_data_section(self, fp: io.BufferedIOBase) -> None:
|
|
1138
1138
|
"""Parse the data section and record variable file offsets.
|
|
1139
1139
|
|
|
1140
|
-
The EOHMARKER has already been consumed by :meth:`_parse_header`.
|
|
1140
|
+
The EOHMARKER has already been consumed by :meth:`_parse_header`. We iterate
|
|
1141
1141
|
over zones in declaration order, matching each data block to the corresponding
|
|
1142
1142
|
:class:`_ZoneMeta` in ``self.zones``.
|
|
1143
1143
|
"""
|
|
@@ -1201,7 +1201,7 @@ class _PltParser:
|
|
|
1201
1201
|
"""Record file offsets for each active variable data block.
|
|
1202
1202
|
|
|
1203
1203
|
Data is stored in **block** order (all values for variable 0, then all values
|
|
1204
|
-
for variable 1, …).
|
|
1204
|
+
for variable 1, …). We seek rather than read so we do not load the data into
|
|
1205
1205
|
memory.
|
|
1206
1206
|
"""
|
|
1207
1207
|
for v in range(num_vars):
|
|
@@ -1228,7 +1228,7 @@ class _PltParser:
|
|
|
1228
1228
|
"""Return the number of values on disk for variable *var_idx*.
|
|
1229
1229
|
|
|
1230
1230
|
For cell-centered variables in ORDERED zones the PLT format writes ``IMax * JMax
|
|
1231
|
-
* (KMax - 1)`` values on disk (see Note 5 of the format spec).
|
|
1231
|
+
* (KMax - 1)`` values on disk (see Note 5 of the format spec). The significant
|
|
1232
1232
|
cell count is ``(I-1) * (J-1) * (K-1)``; the remainder are ghost (zero-padded)
|
|
1233
1233
|
values that are trimmed in :meth:`ReadVariable.get_values` after reshaping.
|
|
1234
1234
|
|
|
@@ -1242,7 +1242,7 @@ class _PltParser:
|
|
|
1242
1242
|
j = max(meta.j_max, 1)
|
|
1243
1243
|
k = max(meta.k_max, 1)
|
|
1244
1244
|
if loc == ValueLocation.CELL_CENTERED:
|
|
1245
|
-
# PLT Note 5: IMax * JMax * (KMax - 1) values on disk.
|
|
1245
|
+
# PLT Note 5: IMax * JMax * (KMax - 1) values on disk. Only K is
|
|
1246
1246
|
# reduced; I and J retain their full extent as ghost padding in the
|
|
1247
1247
|
# Fortran-order layout.
|
|
1248
1248
|
return i * j * max(k - 1, 1)
|
|
@@ -1427,7 +1427,7 @@ class Read:
|
|
|
1427
1427
|
"""Context manager protocol for read-only file interfaces.
|
|
1428
1428
|
|
|
1429
1429
|
Read classes hold no open file handle between accesses, so there is nothing to
|
|
1430
|
-
release on exit.
|
|
1430
|
+
release on exit. Provided for API consistency with the Write classes and to
|
|
1431
1431
|
support the ``with tecio.open(...) as r:`` pattern.
|
|
1432
1432
|
"""
|
|
1433
1433
|
pass
|