tecio.cli.tecscale

tecio.cli.tecscale#

Scale and/or offset variable arrays in a Tecplot data file.

CFD solvers and experimental data sources frequently produce output in differing unit systems, and converting between them (e.g.pressure in Pa to kPa, temperature in Kelvin to Celsius or lengths in meters to feet) is a routine step before visualisation or comparison. Performing these transformations would otherwise require loading the file in Tecplot or writing a dedicated script. tecscale applies the linear transformation

\[v' = a \cdot v + b\]

to every value in a selected variable array, where \(a\) is the scale factor and \(b\) is the additive offset. Variable transformations with -v/--variable are repeatable for multiple scale and offset operations to be applied in a single pass over the file. The transformation can be restricted to a single zone and the output format is controlled by the output file extension, allowing unit conversion and format conversion to be performed in a single step.

Usage:

tecscale [-h] -v INDEX_OR_NAME [-s SCALE] [--offset OFFSET]
         [-v ... [-s ...] [--offset ...]] [-z INDEX] [-o PATH] [-f] PATH
Positional Arguments:
PATH

Path to the input Tecplot binary file (.plt or .szplt) to transform.

Options:
-v INDEX_OR_NAME, --variable INDEX_OR_NAME

A variable to transform (index or name, case-insensitive), applied as new = old * scale + offset. Repeatable: give one -v per variable to transform several variables in one pass. Transformations applied to the same variable more than once keeps only the last occurrence.

-s SCALE, --scale SCALE

Multiplicative scale factor \(s\) for the most recent -v. Defaults to 1 (no scaling). Must follow the -v it applies to.

--offset OFFSET

Additive offset \(b\) for the most recent -v. Defaults to 0 (no shift). Must follow the -v it applies to.

-z INDEX, --zone INDEX

0-based zone index to restrict the transformation to. If omitted, all zones are processed.

-o PATH, --output PATH

Output file path. The extension controls the output format: .szplt, .plt, or .dat. Defaults to <stem>_scaled<ext> in the same directory as the input file.

-f, --force

Overwrite the output file if it already exists. Without this flag the command exits with an error rather than silently clobbering an existing file.

Returns:

A new Tecplot file written to the output path with the selected variable(s) transformed in all processed zones. Exit code 0 on success and non-zero if the input file cannot be read, a variable cannot be resolved, a SCALE/OFFSET isn’t a valid number, or the output file already exists and --force is not set.

Examples

Convert pressure from kPa to psi by index (scale only, offset 0):

$ tecscale -v 3 -s 0.145038 flow.szplt

Same conversion using the variable name:

$ tecscale -v Pressure -s 0.145038 flow.szplt

Shift temperature from Kelvin to Celsius in the second zone only (offset only):

$ tecscale -v Temperature --offset -273.15 -z 1 flow.szplt

Scale pressure and shift temperature in a single pass:

$ tecscale -v Pressure -s 0.145038 -v Temperature --offset -273.15 flow.szplt

Scale and offset in one step, writing to ASCII DAT:

$ tecscale -v 2 -s 0.3048 flow.szplt -o flow_ft.dat

Call directly from a Python session:

from tecio.cli.tecscale import main as tecscale

tecscale(["-v", "Pressure", "-s", "1e-3", "flow.szplt"])

See also

tecio.cli.teconvert - Convert between Tecplot file formats without applying any variable transformation.

Functions

main([argv])

Scale and/or offset one or more variables in a Tecplot file.