tecio.AppendWrite#

class tecio.AppendWrite#

Bases: object

Write handle returned by tecio.open() with mode='a'.

Appends new zones to an existing Tecplot file. Internally the existing file is stream-copied zone-by-zone into a temporary sibling file, and the write handle is left open past all copied zones so new zones can be appended. On close() (or context-manager exit) the temporary file is atomically renamed over the original path — a POSIX rename on Unix, Path.replace() on Windows.

The copy step preserves the original title, variable list, file type, all zone data, all zone metadata (strand, solution time, aux data), and variable sharing. Connectivity is copied for FE zones.

Do not instantiate this class directly — use tecio.open().

Note

FEPOLYGON and FEPOLYHEDRON zones cannot be copied because the Write API does not yet expose a poly-zone writer. A NotImplementedError is raised during open() if such zones are present in the source file.

Example

>>> with tecio.open("flow.szplt", "a") as tec:
...     print(tec.variables)  # variable list from the existing file
...     print(tec.current_zone)  # number of zones already copied
...     tec.write_ijk_zone(
...         data=[x_new, y_new, p_new],
...         solution_time=10.0,
...         strand_id=1,
...     )
>>> # flow.szplt now contains the original zones plus the new one
__init__(original_path, tmp_path, writer)[source]#
add_auxdataset_dict(auxdict)[source]#

Buffer dataset-level auxiliary data.

add_auxvar_dict(auxdict)[source]#

Buffer variable-level auxiliary data.

close()[source]#

Finalise the temporary file and replace the original.

Safe to call more than once.

property current_zone#

Index of the most recently written zone (1-based).

flush_aux()[source]#

Flush buffered auxiliary data to disk.

property title#

Dataset title of the output file.

property variables#

Variable name list of the output file.

write_fe_zone(*args, **kwargs)[source]#

Append an unstructured finite-element zone.

Delegates to the underlying format writer’s write_fe_zone (e.g. tecio.szl.Write.write_fe_zone()). The variables parameter is not meaningful here — the variable list is fixed from the existing file. FEPOLYGON and FEPOLYHEDRON are not supported.

Parameters:
  • zone_type (ZoneType) – Element topology. One of: FELINESEG, FETRIANGLE, FEQUADRILATERAL, FETETRAHEDRON, or FEBRICK.

  • data (Sequence[ndarray]) – One 1-D array per active variable. NODAL arrays must have length num_nodes; CELL_CENTERED arrays must have length num_cells. Both are inferred from node_map.

  • node_map (array-like | None) – Integer array of shape (num_cells, nodes_per_cell) with 1-based node indices. num_nodes = node_map.max(). The 32- or 64-bit write path is chosen automatically.

  • title (str | None) – Zone title. Defaults to "FE_Zone_{n}".

  • value_locations (Sequence[ValueLocation] | None) – Per-variable value location for active variables. Defaults to all NODAL.

  • passive_vars (Sequence[bool | int] | None) – Per-variable passive flags for the full variable list. Defaults to all False.

  • var_sharing (Sequence[int] | None) – Per-variable share-from zone index (1-based). 0 = no sharing. Defaults to all 0.

  • con_sharing (int) – Zone index to share connectivity from (1-based). 0 = write connectivity directly. Cannot be used with GLOBAL face-neighbor modes. Defaults to 0.

  • face_neighbors (array-like | None) – Face-neighbor connectivity. When provided, num_face_cons is set automatically.

  • face_nbr_mode (FaceNeighborMode | None) – Face-neighbor mode. Defaults to LOCAL_ONE_TO_ONE. Ignored when face_neighbors is None.

  • solution_time (float) – Solution time. Defaults to 0.0.

  • strand_id (int) – Strand ID. Defaults to 0.

  • aux (dict[str, str] | None) – Zone-level auxiliary data.

Raises:

NotImplementedError – If zone_type is FEPOLYGON or FEPOLYHEDRON.

write_ijk_zone(*args, **kwargs)[source]#

Append a structured IJK-ordered zone.

Delegates to the underlying format writer’s write_ijk_zone (e.g. tecio.szl.Write.write_ijk_zone()). All parameters from that method are accepted here with one exception: variables is not meaningful because the variable list is fixed at open time from the existing file.

Parameters:
  • data (Sequence[ndarray]) – One NumPy array per active variable (non-passive, non-shared). Shape (imax[, jmax[, kmax]]) is inferred automatically. Fortran (column-major) order is assumed.

  • title (str | None) – Zone title. Defaults to "IJK_Zone_{n}".

  • value_locations (Sequence[ValueLocation] | None) – Per-variable ValueLocation for active variables. Defaults to all NODAL.

  • passive_vars (Sequence[bool | int] | None) – Per-variable passive flag for the full variable list (length = total variables in the file, not just active ones). Defaults to all False.

  • var_sharing (Sequence[int] | None) – Per-variable share-from zone index (1-based, counting all zones including those copied from the original file). 0 = no sharing. Defaults to all 0. Sharing grid coordinates from zone 1 is a common pattern for transient data to avoid duplicating large arrays.

  • solution_time (float) – Solution time for transient data. Defaults to 0.0.

  • strand_id (int) – Strand ID grouping related time steps. Zones with the same strand ID animate together in Tecplot 360. Defaults to 0 (static).

  • aux (dict[str, str] | None) – Zone-level auxiliary data as {name: value} pairs. Defaults to None.

Example

Append a time step, sharing the grid from zone 1:

>>> n = len(tec.variables)  # e.g. ["x", "y", "pressure"]
>>> tec.write_ijk_zone(
...     data=[p_new],  # only the non-shared variable
...     passive_vars=[False] * n,
...     var_sharing=[1, 1, 0],  # x and y shared from zone 1
...     solution_time=5.0,
...     strand_id=1,
... )