tecio.dat.Write#

class tecio.dat.Write#

Bases: object

Context-manager writer for Tecplot 360 ASCII (.dat) files.

The public interface is identical to szl.Write and plt.Write.

Parameters:
  • path – Destination file path.

  • title – Dataset title. Defaults to "untitled".

  • variables – Variable name list. None defers file creation until the first zone-writing call (lazy open).

  • file_typeFileType enum. Defaults to FileType.FULL.

  • sig_digits – Significant digits for scientific-notation float output. Default is 9; use 17 for full float64 round-trip fidelity.

auxdataset#

dict[str, str] Dataset-level auxiliary data buffer.

auxvar#

dict[int | str, dict[str, str]] Variable-level auxiliary data buffer.

current_zone#

int Count of successfully written zones.

Type:

int

__enter__()[source]#

Support with statement.

__exit__(exc_type, exc_value, traceback)[source]#

Close the file on context-manager exit.

__init__(path, title='untitled', variables=None, file_type=FileType.FULL, sig_digits=None)[source]#

Store configuration; open the file immediately if variables given.

add_auxdataset_dict(auxdict)[source]#

Buffer dataset-level auxiliary data from input dictionary.

add_auxvar_dict(auxdict)[source]#

Buffer variable-level auxiliary data from input dictionary.

close()[source]#

Flush and close the output file (safe to call more than once).

flush_aux()[source]#

Write buffered dataset- and variable-level aux data to the file.

Called automatically before the first zone.

Raises:

IOError – If the file has not been opened yet.

write_fe_zone(data, zone_type, *, node_map=None, title=None, variables=None, value_locations=None, passive_vars=None, var_sharing=None, con_sharing=0, face_neighbors=None, face_nbr_mode=FaceNeighborMode.LOCAL_ONE_TO_ONE, solution_time=0.0, strand_id=0, aux=None, datapacking=DataPacking.BLOCK)[source]#

Write a complete finite-element zone.

Warning

FEPOLYGON and FEPOLYHEDRON raise NotImplementedError.

Parameters:
  • data – Sequence of 1-D arrays, one per dataset variable. NODAL arrays must have length num_nodes; CELL_CENTERED arrays must have length num_cells. num_nodes and num_cells are inferred from node_map.

  • zone_type – FE zone type from the ZoneType enum. Must be one of the types in _FE_SIMPLE.

  • node_map – Integer array of shape (num_cells, nodes_per_cell) containing 1-based node indices. 32- or 64-bit write is chosen automatically based on the maximum index value.

  • title – Zone title string. Defaults to "FE_Zone_{current_zone + 1}" if not provided.

  • variables – Variable name list. Required only when the file has not been opened yet (lazy-open path). Ignored on subsequent zones once the file is already initialised. Default to [V1, V2, V3, ...] if not provided in open or zone call.

  • value_locations – Per-variable ValueLocation. Defaults to all NODAL.

  • passive_vars – Per-variable passive flags. Defaults to all active (False).

  • var_sharing – Per-variable share from zone index. Defaults to no sharing.

  • con_sharing – Optional zone index that the connectivity is shared from Pass 0 to indicate no connectivity. You must pass 0 for the first zone in a dataset. Connectivity cannot be shared when face neighbor mode is set to global. Connectivity cannot be shared between cell-based and face-based finite element zones.

  • face_neighbors – Optional face-neighbor connectivity array. num_face_cons in the zone header is set to len(face_neighbors) automatically when this is supplied.

  • face_nbr_mode – Face-neighbor mode, used only when face_neighbors is provided. Defaults to LOCAL_ONE_TO_ONE.

  • solution_time – Solution time for transient data (0.0 = static).

  • strand_id – Strand ID for transient data (0 = static).

  • aux – Zone-level auxiliary data as {name: value} strings.

  • datapacking – Must be BLOCK (the default). POINT is an ASCII-only layout and is not supported by the SZL binary format. Defined only for parity with ASCII writer.

Raises:
  • NotImplementedError – For FEPOLYGON, FEPOLYHEDRON, or if datapacking is POINT.

  • ValueError – On variable count or array length mismatch.

  • ValueError – If I/O operation attempted on closed or None file handle.

  • RuntimeError – If attempting to write variable aux before variables are defined.

write_ijk_zone(data, *, title=None, variables=None, value_locations=None, passive_vars=None, var_sharing=None, solution_time=0.0, strand_id=0, aux=None, datapacking=DataPacking.BLOCK)[source]#

Write a complete IJK-ordered zone.

Zone dimensions are inferred from the shape of the first NODAL array.

Parameters:
  • data – One NumPy array per dataset variable. Array shape is used to infer imax, jmax, and kmax; Fortran (column-major) order is assumed. Pass None to write a zone header only.

  • title – Zone title. Defaults to "IJK_Zone_{current_zone + 1}".

  • variables – Variable name list. Required on the first call when the file has not been opened yet (lazy-open path); ignored once the file is already initialised. Default to [V1, V2, V3, ...] if not provided in open or zone call.

  • value_locations – Per-variable ValueLocation. Defaults to all NODAL.

  • passive_vars – Per-variable passive flags. Defaults to all active (False).

  • var_sharing – Per-variable share-from zone index (1-based). Defaults to no sharing (all zeros).

  • solution_time – Solution time for transient data. Use 0.0 for static zones. Default to 0.0 if not defined.

  • strand_id – Strand ID for transient data. Use 0 for static zones. Default to 0 (static) if not defined.

  • aux – Zone-level auxiliary data as {name: value} string pairs.

  • datapacking – Must be BLOCK (the default). POINT is an ASCII-only layout and is not supported by the SZL binary format. Defined only for parity with ASCII writer.

Raises:
  • NotImplementedError – If datapacking is POINT.

  • ValueError – If I/O operation attempted on closed or None file handle.

  • RuntimeError – If attempting to write variable aux before variables are defined.