tecio.AppendWrite#

class tecio.AppendWrite(original_path, tmp_path, writer)#

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 and poly zones.

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

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_ordered_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
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#

0-based index of the most recently written zone, -1 before any write.

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.TecplotWriter.write_fe_zone()). The variables parameter is not meaningful here — the variable list is fixed from the existing file. FEPOLYGON and FEPOLYHEDRON are face-based, use write_poly_zone().

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 0-based node indices. num_nodes = node_map.max() + 1. 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 (list | tuple | set | None) – Variables to mark passive: a list, tuple, or set of variable names, or of 0-based indices. Defaults to all active.

  • var_sharing (dict[str | int, int] | None) – Variables to share from another zone: a {variable: source zone} mapping (name or 0-based index to 0-based zone index). Defaults to no sharing.

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

  • 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:

ValueError – If zone_type is FEPOLYGON or FEPOLYHEDRON.

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

Append a FEMIXED (mixed finite-element) zone.

Delegates to the underlying format writer’s write_femixed_zone (e.g. tecio.TecplotSzlWriter.write_femixed_zone()). The variables parameter is not meaningful here, the variable list is fixed from the existing file. All indices are 0-based.

Parameters:
  • data (Sequence[ndarray]) – One 1-D array per active variable. NODAL arrays need num_nodes values, CELL_CENTERED arrays the total cell count over all sections, both inferred from the node maps.

  • cell_shapes (Sequence[FeCellShape] | None) – Cell shape of each section (1 to 16), all of one spatial dimension.

  • node_maps (Sequence[array-like] | None) – One (num_cells, nodes_per_cell) 0-based integer array per section.

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

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

  • passive_vars (list | tuple | set | None) – Variables to mark passive.

  • var_sharing (dict[str | int, int] | None) – {variable: source zone}.

  • con_sharing (int | None) – FEMIXED zone to share connectivity from (0-based), in which case cell_shapes and node_maps must be omitted.

  • 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:
write_ordered_zone(*args, **kwargs)[source]#

Append a structured IJK-ordered zone.

Delegates to the underlying format writer’s write_ordered_zone (e.g. tecio.TecplotWriter.write_ordered_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 (list | tuple | set | None) – Variables to mark passive: a list, tuple, or set of variable names, or of 0-based indices. Defaults to all active.

  • var_sharing (dict[str | int, int] | None) – Variables to share from another zone: a {variable: source zone} mapping (name or 0-based index to 0-based zone index, counting all zones including those copied from the original file). Defaults to no sharing. Sharing grid coordinates from zone 0 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 0:

>>> tec.write_ordered_zone(
...     data=[p_new],  # only the non-shared variable
...     var_sharing={"x": 0, "y": 0},
...     solution_time=5.0,
...     strand_id=1,
... )
write_poly_zone(*args, **kwargs)[source]#

Append a polygon or polyhedron (face-based) zone.

Delegates to the underlying format writer’s write_poly_zone (e.g. tecio.TecplotPltWriter.write_poly_zone()). The variables parameter is not meaningful here, the variable list is fixed from the existing file. All indices are 0-based.

Parameters:
  • zone_type (ZoneType) – FEPOLYGON or FEPOLYHEDRON.

  • data (Sequence[ndarray]) – One 1-D array per active variable. NODAL arrays need num_nodes values, CELL_CENTERED arrays num_elements, both inferred from the face map.

  • face_nodes (array-like | None) – Flat node indices of all faces.

  • face_node_counts (array-like | None) – Nodes per face. Required for polyhedra, optional for polygons (always 2).

  • face_left_elements (array-like | None) – Element left of each face, -1 for none, -(b + 2) for boundary face b.

  • face_right_elements (array-like | None) – Element right of each face.

  • boundary_connection_counts (array-like | None) – Connections per boundary face.

  • boundary_connection_elements (array-like | None) – Flat neighbor elements.

  • boundary_connection_zones (array-like | None) – Flat zone of each neighbor.

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

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

  • passive_vars (list | tuple | set | None) – Variables to mark passive.

  • var_sharing (dict[str | int, int] | None) – {variable: source zone}.

  • con_sharing (int | None) – Zone to share the face map from (0-based).

  • 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: