Data Access and Manipulation

Dataset, Zone, Variable objects and data access/manipulation.

A Dataset consists of a matrix of Zones and Variables. Each Zone-Variable pair corresponds to a data object which can always be treated as a 1D array, but which may be interpreted as 2D or 3D in the case of ijk-ordered data.

Loading Data

tecplot.data.load_tecplot(filenames, frame=None, append=True, reset_style=None, initial_plot_first_zone_only=None, initial_plot_type=None, zones=None, variables=None, collapse=None, skip=None, assign_strand_ids=True, add_zones_to_existing_strands=None, include_text=None, include_geom=None, include_custom_labels=None, include_data=None)[source]

Read a tecplot data file.

Parameters:
  • filenames (string or list of strings) – Files to be read.
  • frame (Frame, optional) – The Frame to attach the resulting Dataset. If None, the currently active Frame is used and the zones are appended by default.
  • append (boolean, optional) – Append the data to the existing Dataset. If False, the existing data attached to the Frame is deleted and replaced. (default: True)
  • reset_style (boolean, optional) – Reset the style for destination Frame, if False, the Frame‘s current style is preserved. (default: True)
  • initial_plot_first_zone_only (boolean, optional) – Informs the Tecplot Engine that after the data is loaded it only needs to activate the first enabled Zone for the initial plot. This option is particularly useful if you have many Zones and want to get the data into the Tecplot Engine and the first Zone drawn as fast as possible. The inactive Zones can always be activated when needed. (default: False)
  • initial_plot_type (PlotType, optional) – Forces a specific type of plot upon loading of the data. Only used if resetstyle is True. To have Tecplot 360 EX determine the most appropriate plot type for the data, use PlotType.Automatic. Possible values are: PlotType.Automatic (default), Cartesian3D, Cartesian2D, XYLine, PlotType.Sketch, PolarLine.
  • zones (set of integers, optional) – Set of Zones to load. Use None to load all zones. (default: None)
  • variables (set of strings or integers, optional) – Set of Variables to load. Use None to load all variables. (default: None)
  • collapse (boolean, optional) – Reindex Zones and Variables if any are disabled. (default: False)
  • skip – (3-tuple of integers, optional) The ijk-skip. A value of (1,1,1) loads every data point in the (i,j,k) directions. A value of (2,2,2) loads every other data point and so forth. This only applies to ordered data. (default: (1,1,1))
  • assign_strand_ids (boolean, optional) – Assign strand ID’s to zones that have a strand ID of -1. (default: True)
  • add_zones_to_existing_strands (boolean, optional) – Add the Zones to matching strands, if they exist. Otherwise, if the new data specifies strands, new ones will be created beginning after the last strand in the Dataset. (default: False)
  • include_text (boolean, optional) – Load any text, geometries, or custom labels (default: True)
  • include_geom (boolean, optional) – Load geometries. (default: True)
  • include_custom_labels (boolean, optional) – (default: True)
  • include_data (boolean, optional) – Load data. Set this to False if you only want annotations such as text or geometries. (default: True)
Returns:

Dataset – The Dataset holding the loaded data.

Raises:
tecplot.data.load_cgns(filenames, frame=None, append=True, reset_style=None, initial_plot_first_zone_only=None, initial_plot_type=None, zones=None, variables=None, load_convergence_history=None, combine_fe_sections=None, average_to_nodes=None, uniform_grid=None, assign_strand_ids=None, add_zones_to_existing_strands=None, include_boundary_conditions=None)[source]

Read CGNS data files.

Parameters:
  • filenames (string or list of strings) – CGNS data files to be read. Note: Relative paths are considered to be from the running python script’s current working directory which can be obtained via os.getcwd().
  • frame (Frame, optional) – The Frame to attach the resulting Dataset. If None, the currently active Frame is used and the zones are appended by default.
  • append (boolean, optional) – Append the data to the existing Dataset. If False, the existing data attached to the Frame is deleted and replaced. (default: True)
  • reset_style (boolean, optional) – Reset the style for destination Frame, if False, the Frame‘s current style is preserved. (default: True)
  • initial_plot_first_zone_only (boolean, optional) – Informs the Tecplot Engine that after the data is loaded it only needs to activate the first enabled Zone for the initial plot. This option is particularly useful if you have many Zones and want to get the data into the Tecplot Engine and the first Zone drawn as fast as possible. The inactive Zones can always be activated when needed. (default: False)
  • initial_plot_type (PlotType, optional) – Forces a specific type of plot upon loading of the data. Only used if resetstyle is True. To have Tecplot 360 EX determine the most appropriate plot type for the data, use PlotType.Automatic. Possible values are: PlotType.Automatic (default), Cartesian3D, Cartesian2D, XYLine, PlotType.Sketch, PolarLine.
  • zones (list of integers, optional) – List of zone indexes to load starting from zero. None implies loading all zones. (default: None)
  • variables (list of integers, optional) – List of variable indexes, beyond the first coordinate variables, to load starting from zero. None implies loading all variables. The grid will always be loaded and an index of zero indicates the first non-coordinate variable. (default: None)
  • load_convergence_history (boolean, optional) – Load the global convergence history rather than any grid or solution data. (default: False)
  • combine_fe_sections (boolean, optional) – Combine all finite-element sections with the zone cell-dimension into one zone. (default: False)
  • average_to_nodes (string, optional) – Average cell-centered data to grid nodes using the specified method. (Options: None, “Arithmetic”, “Laplacian”)
  • uniform_grid (boolean, optional) – Indicates the grid structure is the same for all time steps. (default: True)
  • assign_strand_ids (boolean, optional) – Assign strand ID’s to zones that have a strand ID of -1. (default: True)
  • add_zones_to_existing_strands (boolean, optional) – Add the Zones to matching strands, if they exist. Otherwise, if the new data specifies strands, new ones will be created beginning after the last strand in the Dataset. (default: False)
  • include_boundary_conditions (boolean, optional) – Load the boundary conditions along with the data. (default: False)
Returns:

Dataset – The Dataset holding the loaded data.

Raises:
tecplot.data.load_fluent(case_filenames=None, data_filenames=None, frame=None, append=True, reset_style=None, initial_plot_first_zone_only=None, initial_plot_type=None, zones=None, variables=None, all_poly_zones=None, average_to_nodes=None, time_interval=None, assign_strand_ids=True, add_zones_to_existing_strands=None, include_particle_data=None)[source]

Read Fluent data files.

Parameters:
  • case_filenames (string or list of strings, optional) – Case (.cas) files to be read.
  • data_filenames (string or list of strings, optional) – Data (.dat, .xml etc.) files to be read.
  • frame (Frame, optional) – The Frame to attach the resulting Dataset. If None, the currently active Frame is used and the zones are appended by default.
  • append (boolean, optional) – Append the data to the existing Dataset. If False, the existing data attached to the Frame is deleted and replaced. (default: True)
  • reset_style (boolean, optional) – Reset the style for destination Frame, if False, the Frame‘s current style is preserved. (default: True)
  • initial_plot_first_zone_only (boolean, optional) – Informs the Tecplot Engine that after the data is loaded it only needs to activate the first enabled Zone for the initial plot. This option is particularly useful if you have many Zones and want to get the data into the Tecplot Engine and the first Zone drawn as fast as possible. The inactive Zones can always be activated when needed. (default: False)
  • initial_plot_type (PlotType, optional) – Forces a specific type of plot upon loading of the data. Only used if resetstyle is True. To have Tecplot 360 EX determine the most appropriate plot type for the data, use PlotType.Automatic. Possible values are: PlotType.Automatic (default), Cartesian3D, Cartesian2D, XYLine, PlotType.Sketch, PolarLine.
  • zones (string or list of integers, optional) – List of zone indexes (zero-based) to load or string specifying the type of zones to load. Possible values are: “CellsAndBoundaries”, “CellsOnly” and “BoundariesOnly”. Specifying one of these options is mutually exclusive with the variables option. (default: “CellsAndBoundaries”)
  • variables (list of strings, optional) – List of variable names to load. None implies loading all variables. (default: None)
  • all_poly_zones (boolean, optional) – Converts all zones to Tecplot polytope (polyhedral or polygonal) zones. (default: False)
  • average_to_nodes (string, optional) – Average cell-centered data to grid nodes using the specified method. (Options: None, “Arithmetic”, “Laplacian”)
  • time_interval (float, optional) – Use a constant time interval between each .dat file. If None, the flow-data parameter of each solution .dat file is used. (default: None)
  • assign_strand_ids (boolean, optional) – Assign strand ID’s to zones that have a strand ID of -1. (default: True)
  • add_zones_to_existing_strands (boolean, optional) – Add the Zones to matching strands, if they exist. Otherwise, if the new data specifies strands, new ones will be created beginning after the last strand in the Dataset. (default: False)
  • include_particle_data (boolean, optional) – Load particle data from the .dat files. If loading particle data from an XML file, the XML file should be included in the data_filenames list. (default: False)
Returns:

Dataset – The Dataset holding the loaded data.

Raises:

Notes

The zones option takes either a list of zone indexes to be imported or one of “CellsAndBoundaries”, “CellsOnly” or “BoundariesOnly” to indicate the type of zones the user wants to load, however these options are mutually exclusive with the variables option:

>>> import tecplot
>>> dataset = tecplot.data.load_fluent(['one.cas', 'two.cas'],
...     data_filenames=['one.dat', 'two.dat'],
...     variables = ['Pressure','Velocity'],
...     zones = [0,1,3])
tecplot.data.load_plot3d(grid_filenames=None, solution_filenames=None, function_filenames=None, name_filename=None, frame=None, append=True, reset_style=None, initial_plot_first_zone_only=None, initial_plot_type=None, data_structure=None, is_multi_grid=None, style=None, ascii_is_double=None, ascii_has_blanking=None, uniform_grid=None, assign_strand_ids=True, add_zones_to_existing_strands=True, append_function_variables=None, include_boundaries=True)[source]

Read Plot3D data files.

Parameters:
  • grid_filenames (string or list of strings, optional) – One or more grid file names to be read.
  • solution_filenames (string or list of strings, optional) – One or more solution data file names to be read.
  • function_filenames (string or list of strings, optional) – One or more function file names.
  • name_filename (string, optional) – Path to the name file.
  • frame (Frame, optional) – The Frame to attach the resulting Dataset. If None, the currently active Frame is used and the zones are appended by default.
  • append (boolean, optional) – Append the data to the existing Dataset. If False, the existing data attached to the Frame is deleted and replaced. (default: True)
  • reset_style (boolean, optional) – Reset the style for destination Frame, if False, the Frame‘s current style is preserved. (default: True)
  • initial_plot_first_zone_only (boolean, optional) – Informs the Tecplot Engine that after the data is loaded it only needs to activate the first enabled Zone for the initial plot. This option is particularly useful if you have many Zones and want to get the data into the Tecplot Engine and the first Zone drawn as fast as possible. The inactive Zones can always be activated when needed. (default: False)
  • initial_plot_type (PlotType, optional) – Forces a specific type of plot upon loading of the data. Only used if resetstyle is True. To have Tecplot 360 EX determine the most appropriate plot type for the data, use PlotType.Automatic. Possible values are: PlotType.Automatic (default), Cartesian3D, Cartesian2D, XYLine, PlotType.Sketch, PolarLine.
  • data_structure (string, optional) – Specifies the data structure and overrides the automatic detection. Options are: 1D, 2D, 3DP, 3DW, UNSTRUCTURED. Setting this requires is_multi_grid and style to be set as well.
  • is_multi_grid (boolean, optional) – Sets data as multi-grid and overrides the automatic data structure detection. Setting this requires data_structure and style to be set as well.
  • style (boolean, optional) – Specifies the data style and overrides the automatic data structure detection. Options are: PLOT3DCLASSIC, PLOT3DFUNCTION, OVERFLOW. Setting this requires data_structure and is_multi_grid to be set as well.
  • ascii_is_double (boolean, optional) – Indicates that floating-point numbers found in the text data files should be store with 64-bit precision. (default: False)
  • ascii_has_blanking (boolean, optional) – Indicates that the text data files contain blanking. (default: False)
  • uniform_grid (boolean, optional) – Indicates the grid structure is the same for all time steps. (default: True)
  • assign_strand_ids (boolean, optional) – Assign strand ID’s to zones that have a strand ID of -1. (default: True)
  • add_zones_to_existing_strands (boolean, optional) – Add the Zones to matching strands, if they exist. Otherwise, if the new data specifies strands, new ones will be created beginning after the last strand in the Dataset. (default: True)
  • append_function_variables (boolean, optional) – Append variables in function files to those found in solution files. (default: False)
  • include_boundaries (boolean, optional) – Loads boundary zones found in the ”.g.fvbnd” file located in the same directory as the grid file, if available. (default: True)
Returns:

Dataset – The Dataset holding the loaded data.

Raises:

Note

Data structure is automatically detected by default.

The options data_structure, is_multi_grid and style must be supplied together or not at all. When all of these are None, the data structure is automatically detected.

The variables from the function files can be appended to the dataset upon loading:

>>> import tecplot as tp
>>> dataset = tp.data.load_plot3d(
...     grid_filenames = 'data.g',
...     solution_filenames = ['t0.q', 't1.q'],
...     function_filenames = ['t0.f', 't1.f'],
...     append_function_variables = True)

Saving Data

tecplot.data.save_tecplot_binary(filename, frame=None, dataset=None, zones=None, variables=None, version=None, include_text=None, include_geom=None, include_data=None, include_data_share_linkage=None, include_autogen_face_neighbors=None, associate_with_layout=None)[source]

Write tecplot binary data file.

Parameters:
  • filename (string) – Name of the data file to write.
  • frame (Frame, optional) – The Frame which holds the Dataset to be written. If this option and dataset are both None, the currently active Frame is used. (default: None)
  • dataset (Dataset, optional) – The Dataset to write out. If this and frame are both None, the Dataset of the currently active Frame is used. (default: None)
  • zones (list of Zones, optional) – Zones to write out. If None, all Zones will be saved.
  • variables (list of Variables, optional) – Variables to write out. If None, all Variables will be saved.
  • include_text (boolean, optional) – Write out all text, geometries and custom labels. (default: True)
  • include_geom (boolean, optional) – Write out all geometries. (default: True)
  • include_data (boolean, optional) – Write out the data. Set this to False if you only want to write out annotations. (default: True)
  • include_data_share_linkage (boolean, optional) – Conserve space and write the variable and connectivity linkage wherever possible. If False, this will write out all data, losing the connectivity sharing linkage for future dataset reads of the file. (default: True)
  • include_autogen_face_neighbors (boolean, optional) – Save the face neighbor connectivity. This may produce very large data files. (default: False)
  • associate_with_layout (boolean, optional) – Associate this data file with the current layout. Set to False to write the datafile without modifying Tecplot’s current data file to layout association. If version is set to anything other than BinaryFileVersion.Current, this association is not possible, and this parameter will be ignored. (default: True)
  • version (BinaryFileVersion, optional) – Specifies the file version to write. Note that some data may be excluded from the file if it cannot be supported in the specified version. Possible values are: Tecplot2006, Tecplot2008, Tecplot2009 and BinaryFileVersion.Current. (default: BinaryFileVersion.Current)
Returns:

Dataset – The Dataset read from when saving.

Raises:

Example

In this example, we load sample data and save the data in Tecplot binary format.

from os import path
import tecplot
examples_directory = tecplot.session.tecplot_examples_directory()
infile = path.join(examples_directory,
                   'OneraM6wing', 'OneraM6_SU2_RANS.plt')
dataset = tecplot.data.load_tecplot(infile)
variables_to_save = [dataset.variable(V)
                     for V in ('x', 'y', 'z', 'Pressure_Coefficient')]

zone_to_save = dataset.zone('WingSurface')
# write data out to a binary file
tecplot.data.save_tecplot_binary('wing.plt', dataset=dataset,
                                variables=variables_to_save,
                                zones=[zone_to_save])
tecplot.data.save_tecplot_ascii(filename, frame=None, dataset=None, zones=None, variables=None, include_text=None, precision=None, include_geom=None, include_data=None, include_data_share_linkage=None, include_autogen_face_neighbors=None, use_point_format=None)[source]

Write tecplot ASCII data file.

Parameters:
  • filename (string) – Name of the data file to write.
  • frame (Frame, optional) – The Frame which holds the Dataset to be written. If this option and dataset are both None, the currently active Frame is used. (default: None)
  • dataset (Dataset, optional) – The Dataset to write out. If this and frame are both None, the Dataset of the currently active Frame is used. (default: None)
  • include_text (boolean, optional) – Write out all text, geometries and custom labels. (default: True)
  • include_geom (boolean, optional) – Write out all geometries. (default: True)
  • include_data (boolean, optional) – Write out the data. Set this to False if you only want to write out annotations. (default: True)
  • include_data_share_linkage (boolean, optional) – Conserve space and write the variable and connectivity linkage wherever possible. If False, this will write out all data, losing the connectivity sharing linkage for future dataset reads of the file. (default: True)
  • include_autogen_face_neighbors (boolean, optional) – Save the face neighbor connectivity. This may produce very large data files. (default: False)
  • use_point_format (boolean, optional) – Write out point format, otherwise use block format. (default: False)
  • zones (list of Zones, optional) – Zones to write out. Use None to write out all Zones. (default: None)
  • variables (list of Variables, optional) – Variables to write out. Use None to write out all Variables. (default: None)
  • precision (integer, optional) – ASCII decimal precision to use. (default: 12)
Returns:

Dataset – The Dataset read from when saving.

Raises:

Example

In this example, we load sample data and save the data in Tecplot ASCII format.

from os import path
import tecplot
examples_directory = tecplot.session.tecplot_examples_directory()
infile = path.join(examples_directory,
                   'OneraM6wing', 'OneraM6_SU2_RANS.plt')
dataset = tecplot.data.load_tecplot(infile)
variables_to_save = [dataset.variable(V)
                     for V in ('x','y','z','Pressure_Coefficient')]

zone_to_save = dataset.zone('WingSurface')
# write data out to an ascii file
tecplot.data.save_tecplot_ascii('wing.dat', dataset=dataset,
                                variables=variables_to_save,
                                zones=[zone_to_save])

Data Queries

tecplot.data.query.probe_at_position(x, y, z=None, nearest=False, starting_cell=None, starting_zone=None, zones=None, dataset=None, frame=None)[source]

Returns field values at a point in space.

Note

The position is taken according the axis assignments of the Frame which may be any of the associated variables in the Dataset and not necessarily (X, Y, Z). See: Cartesian3DFieldAxis.variable.

Parameters:
  • x,y,z (float, z is optional) – position to probe for field values.
  • nearest (bool) – Returns the values at the nearest node to the given position.
  • starting_cell (3-tuple of integers, optional) – The (i,j,k)-index of the cell to start looking for the given position. This must be used with starting_zone.
  • starting_zone (Zone, required only when starting_cell is given) – The first zone to start searching.
  • zones (list of Zones, optional) – Limits the search to the given zones. None implies searching all zones. (default: None)
  • dataset (Dataset, optional) – The Dataset to probe. (defaults to the active Dataset.)
  • frame (Frame, optional) – The Frame which determines the spatial variable assignment (X,Y,Z). (defaults to the active Frame.)
Returns:

namedtuple

(data, cell, zone):

data (list of floats)

The values of each variable in the dataset at the given position.

cell (3-tuple of integers)

(i,j,k) of the cell containing the given position.

zone (Zone)

Zone containing the given position

Data Operations

class tecplot.data.operate.Range(min, max, step)

Limit the data altered by the execute_equation function.

The Range specification of I,J,K range indices for execute_equation follow these rules:

  • All indices start with 0 and go to some maximum index m.
  • Negative values represent the indexes starting with the maximum at -1 and continuing back to the beginning of the range.
  • A step of None, 0 and 1 are all equivalent and mean that no elements are skipped.
  • A negative step indicates a skip less than the maximum.

Example

Add one to variable ‘X’ for a zone ‘Rectangular’ for data points in I Range 1 to max, skipping every three points:

>>> execute_equation('{X} = {X}+1', i_range=Range(min=1, max=None, step=3),
...                  zone_set='Rectangular')
tecplot.data.operate.execute_equation(equation, zones=None, i_range=None, j_range=None, k_range=None, value_location=None, variable_data_type=None, ignore_divide_by_zero=None)[source]

The execute_equation function operates on a data set within the Tecplot Engine using FORTRAN-like equations.

Parameters:
  • equation (string) –

    String containing the equation. Multiple equations can be processed by separating each equation with a newline. See Section 20 - 1 “Data Alteration through Equations” in the Tecplot User’s Manual for more information on using equations. Iterable container of Zone objects to operate on. May be a list, set, tuple, or any iterable container. If None, the equation will be applied to all zones.

    Note

    In the equation string, variable names should be enclosed in curly braces. For example, ‘{X} = {X} + 1’

  • zones – (Iterable container of Zone objects, optional): Iterable container of Zone objects to operate on. May be a list, set, tuple, or any iterable container. If None, the equation will be applied to all zones.
  • i_range (Range, optional) – Tuple of integers for I: (min, max, step). If None, then the equation will operate on the entire range. Not used for finite element nodal data.
  • j_range (Range, optional) – Tuple of integers for J: (min, max, step). If None, then the equation will operate on the entire range. Not used for finite element nodal data.
  • k_range (Range, optional) – Tuple of integers for K: (min, max, step). If None, then the equation will operate on the entire range. Not used for finite element nodal data.
  • value_location (ValueLocation, optional) – Variable ValueLocation for the variable on the left hand side. This is used only if this variable is being created for the first time. If None, Tecplot Engine will choose the location for you.
  • variable_data_type (FieldDataType, optional) – Data type for the variable on the left hand side. This is used only if this variable is being created for the first time. If None, Tecplot Engine will choose the type for you.
  • ignore_divide_by_zero (bool, optional) – bool value which instructs Tecplot Engine to ignore divide by zero errors. The result is clamped such that 0/0 is clamped to zero and (+/-N)/0 where N != 0 clamps to +/-maximum value for the given type.
Raises:

TecplotSystemError

Add one to variable ‘X’ for zones ‘Rectangular’ and ‘Circular’ for every data point: >>> import tecplot >>> dataset = tecplot.active_frame().dataset >>> execute_equation(‘{X} = {X} + 1’, zones=[dataset.zone(‘Rectangular’), >>> dataset.zone(‘Circular’)])

Create a new, double precision variable called DIST:

>>> execute_equation('{DIST} = SQRT({X}**2 + {Y}**2)',
...                  variable_data_type=FieldDataType.double)

Set a variable called P to zero along the boundary of an IJ-ordered zone:

>>> execute_equation('{P} = 0', i_range=Range(step=-1))
>>> execute_equation('{P} = 0', j_range=Range(step=-1))

Dataset

class tecplot.data.Dataset(uid, frame)[source]

A matrix of Zones and Variables.

Parameters:
  • uid (integer) – This must be a valid unique ID number pointing internally to a Dataset object.
  • frame (Frame) – A Frame to which this Dataset is attached.

A Dataset can be shared among several Frames, though any particular Dataset object will have a handle to at least one of them. Any modification of a shared Dataset will be reflected in all Frames that use it.

Attributes

num_variables Number of Variables in this Dataset.
num_zones Number of Zones in this Dataset.
title Title of this Dataset.

Methods

add_ordered_zone
add_fe_zone
add_poly_zone
add_variable Add a single Variable to the active Dataset.
add_zone Add a single Zone to the active Dataset.
copy_zones Copies Zones within this Dataset.
delete_variables Remove Variables from this Dataset.
delete_zones Remove Zones from this Dataset.
variable Returns the Variable by index or string pattern.
variables Yields all Variables matching a pattern.
zone Returns Zone by index or string pattern.
zones Yields all Zones matching a pattern.

Special Methods

__str__ Brief string representation.
__repr__ Executable string representation.
__eq__ Checks for equality in the Tecplot Engine.
Dataset.title

Title of this Dataset.

Type:string
Raises:TecplotSystemError
Dataset.num_variables

Number of Variables in this Dataset.

Type:integer
Dataset.num_zones

Number of Zones in this Dataset.

Type:integer
Dataset.variable(pattern)[source]

Returns the Variable by index or string pattern.

Parameters:pattern (integer or string) – Zero-based index or glob-style pattern in which case, the first match is returned.
Raises:TecplotIndexError

The Variable.name attribute is used to match the pattern to the desired Variable though this is not necessarily unique:

>>> ds = frame.dataset
>>> print(ds)
Dataset:
  Zones: ['Rectangular zone']
  Variables: ['x', 'y', 'z']
>>> x = ds.variable('x')
>>> x == ds.variable(0)
True
Dataset.variables(pattern=None)[source]

Yields all Variables matching a pattern.

Dataset.zone(pattern)[source]

Returns Zone by index or string pattern.

Parameters:pattern (integer or string) – Zero-based index or glob-style pattern in which case, the first match is returned.
Raises:TecplotIndexError

The Zone.name attribute is used to match the pattern to the desired Zone though this is not necessarily unique:

>>> ds = frame.dataset
>>> print(ds)
Dataset:
  Zones: ['Rectangular zone']
  Variables: ['x', 'y', 'z']
>>> rectzone = ds.zone('Rectangular zone')
>>> rectzone == ds.zone(0)
True
Dataset.zones(pattern=None)[source]

Yields all Zones matching a pattern.

Dataset.copy_zones(*zones)[source]

Copies Zones within this Dataset.

Dataset.add_ordered_zone(name, shape, dtypes=None, locs=None, **kwargs)[source]
Dataset.add_fe_zone(zone_type, name, num_points, num_elements, dtypes=None, locs=None, **kwargs)[source]
Dataset.add_poly_zone(name, zone_type, num_points, num_elements, num_faces, **kwargs)[source]
Dataset.add_variable(name, dtypes=None, locations=None)[source]

Add a single Variable to the active Dataset.

Parameters:
Raises:

TecplotSystemError

Dataset.add_zone(zone_type, name, shape, dtypes=None, locations=None, **kwargs)[source]

Add a single Zone to the active Dataset.

Parameters:
Raises:

TecplotSystemError

Dataset.delete_variables(*variables)[source]

Remove Variables from this Dataset.

Parameters:*variables (Variable or index integer) – Variables to remove from this dataset.
>>> print([v.name for v in dataset.variables()])
['X','Y','Z']
>>> dataset.delete_variables(dataset.variable('Z'))
>>> print([v.name for v in dataset.variables()])
['X','Y']

Notes

Multiple Variables can be deleted at once, though the last Variable can not be deleted. This command deletes all but the first Variable in the Dataset (usually X):

dataset.delete_variables(dataset.variables())
Dataset.delete_zones(*zones)[source]

Remove Zones from this Dataset.

Parameters:*zones (Zone or index integer) – Zones to remove from this dataset.
>>> print([z.name for z in dataset.zones()])
['Zone 1', 'Zone 2']
>>> dataset.delete_zones(dataset.zone('Zone 2'))
>>> print([z.name for z in dataset.zones()])
['Zone 1']

Notes

Multiple Zones can be deleted at once, though the last Zone can not be deleted. This command deletes all but the first Zone in the Dataset:

dataset.delete_zones(dataset.zones())
Dataset.__str__()[source]

Brief string representation.

Returns:string – Brief representation of this Dataset, showing Zones and Variables.

Example:

>>> dataset = frame.dataset
>>> print(dataset)
Dataset:
  Zones: ['Rectangular zone']
  Variables: ['x', 'y', 'z']
Dataset.__repr__()[source]

Executable string representation.

Returns:string – Internal representation of this Dataset.

The string returned can be executed to generate a clone of this Dataset object:

>>> dataset = frame.dataset
>>> print(repr(dataset))
Dataset(uid=21, frame=Frame(uid=11, page=Page(uid=1)))
>>> exec('dataset_clone = '+repr(dataset))
>>> dataset_clone
Dataset(uid=21, frame=Frame(uid=11, page=Page(uid=1)))
>>> dataset == dataset_clone
True
Dataset.__eq__(other)[source]

Checks for equality in the Tecplot Engine.

Returns:boolTrue if the unique ID numbers are the same for both Datasets.

This can be useful for determining if two Frames are holding on to the same Dataset:

>>> frame1.dataset == frame2.dataset
True

Variable

class tecplot.data.Variable(uid, dataset)[source]

Key value for a data array within a Dataset.

Parameters:

Variables can be identified (uniquely) by the index with their parent Dataset or (non-uniquely) by name. In general, a Zone must be selected to access the underlying data array.

Attributes

index Zero-based position within the parent Dataset.
name Returns or sets the name.
num_zones Number of Zones in the parent Dataset.

Methods

zone Returns Array by index or string pattern.
zones Yields all Arrays matching a pattern.

Special Methods

__str__ Brief string representation.
__repr__ Executable string representation.
__eq__ Checks for equality in the Tecplot Engine.
Variable.index

Zero-based position within the parent Dataset.

Type:Index
Variable.name

Returns or sets the name.

Type:string
Raises:TecplotSystemError
Variable.num_zones

Number of Zones in the parent Dataset.

Type:integer
Variable.zone(pattern)[source]

Returns Array by index or string pattern.

Parameters:pattern (integer or string) – Zero-based index or glob-style pattern in which case, the first match is returned.

The Zone.name attribute is used to match the pattern to the desired Array though this is not necessarily unique:

>>> ds = frame.dataset
>>> print(ds)
Dataset:
  Zones: ['Rectangular zone']
  Variables: ['x', 'y', 'z']
>>> x = ds.variable('x')
>>> rectzone = x.zone('Rectangular zone')
>>> rectzone == x.zone(0)
True
Variable.zones(pattern=None)[source]

Yields all Arrays matching a pattern.

Variable.__str__()[source]

Brief string representation.

Returns:string – Brief representation of this Variable, showing Zones.

Example:

>>> x = dataset.variable('x')
>>> print(x)
Variable: x
  Zones: ['Rectangular zone']
Variable.__repr__()[source]

Executable string representation.

Returns:string – Internal representation of this Variable.

The string returned can be executed to generate a clone of this Variable object:

>>> x = dataset.variable('x')
>>> print(repr(x))
Variable(uid=41, Dataset(uid=21, frame=Frame(uid=11,
page=Page(uid=1)))
>>> exec('x_clone = '+repr(x))
>>> x_clone
Variable(uid=41, Dataset(uid=21, frame=Frame(uid=11,
page=Page(uid=1)))
>>> x == x_clone
True
Variable.__eq__(other)[source]

Checks for equality in the Tecplot Engine.

Returns:boolTrue if the unique ID numbers are the same for both Variables.

Zone

class tecplot.data.Zone(uid, dataset)[source]

Key value for a data array within a Dataset.

Parameters:
  • uid (integer) – This must be a valid unique ID number pointing internally to a Zone object in the given Dataset.
  • dataset (Dataset) – A Dataset to which this Zone is contained.

Zones can be identified (uniquely) by the index with their parent Dataset or (non-uniquely) by name. In general, a Variable must be selected to access the underlying data array.

Attributes

index Zero-based position within the parent Dataset.
name Returns or sets the name.
num_points Number of elements in the associated data array.
shape The shape of the associated data arrays.
num_variables Number of Variables in the parent Dataset.

Methods

variable Returns an Array by index or string pattern.
variables Yields all Arrays matching a pattern.
copy duplicate this Zone in its currently held parent Dataset.

Special Methods

__str__ Brief string representation.
__repr__ Executable string representation.
__eq__ Checks for equality in the Tecplot Engine.
Zone.index

Zero-based position within the parent Dataset.

Type:Index
Zone.name

Returns or sets the name.

Type:string
Raises:TecplotSystemError
Zone.num_points

Number of elements in the associated data array.

Zone.shape

The shape of the associated data arrays.

Returns:`tuple` (int) – (i,j,k) for ordered data or (len,) for unordered data.
Zone.num_variables

Number of Variables in the parent Dataset.

Type:integer
Zone.variable(pattern)[source]

Returns an Array by index or string pattern.

Parameters:pattern (integer or string) – Zero-based index or glob-style pattern in which case, the first match is returned.

The Variable.name attribute is used to match the pattern to the desired Array though this is not necessarily unique:

>>> ds = frame.dataset
>>> print(ds)
Dataset:
  Zones: ['Rectangular zone']
  Variables: ['x', 'y', 'z']
>>> zone = ds.zone('Rectangular zone')
>>> x = zone.variable('x')
>>> x == zone.variable(0)
True
Zone.variables(pattern=None)[source]

Yields all Arrays matching a pattern.

Zone.copy()[source]

duplicate this Zone in its currently held parent Dataset.

Zone.__str__()[source]

Brief string representation.

Returns:string – Brief representation of this Zone, showing a list of associated Variables.

Example:

>>> rect_zone = dataset.zone('Rectangular zone')
>>> print(rect_zone)
Zone: Rectangular zone
  Variables: ['x', 'y', 'z']
Zone.__repr__()[source]

Executable string representation.

Returns:string – Internal representation of this Zone.

The string returned can be executed to generate a clone of this Zone object:

>>> rectzone = dataset.zone('Rectangular zone')
>>> print(repr(rectzone))
Zone(uid=31, Dataset(uid=21, frame=Frame(uid=11, page=Page(uid=1)))
>>> exec('rectzone_clone = '+repr(rectzone))
>>> rectzone_clone
Zone(uid=31, Dataset(uid=21, frame=Frame(uid=11, page=Page(uid=1)))
>>> rectzone == rectzone_clone
True
Zone.__eq__(other)[source]

Checks for equality in the Tecplot Engine.

Returns:boolTrue if the unique ID numbers are the same for both Zones.

Array

class tecplot.data.Array(dataset, zone, variable)[source]

Low-level accessor for underlying data within a Dataset.

shape

(i,j,k) shape