Data¶
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
orlist
ofstrings
) – Files to be read. - frame (
Frame
, optional) – TheFrame
to attach the resultingDataset
. IfNone
, the currently activeFrame
is used and the zones are appended by default. - append (
boolean
, optional) – Append the data to the existingDataset
. IfFalse
, the existing data attached to theFrame
is deleted and replaced. (default:True
) - reset_style (
boolean
, optional) – Reset the style for destinationFrame
, ifFalse
, theFrame
‘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 enabledZone
for the initial plot. This option is particularly useful if you have manyZones
and want to get the data into the Tecplot Engine and the firstZone
drawn as fast as possible. The inactiveZones
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 isTrue
. To have Tecplot 360 EX determine the most appropriate plot type for the data, usePlotType.Automatic
. Possible values are:PlotType.Automatic
(default),Cartesian3D
,Cartesian2D
,XYLine
,PlotType.Sketch
,PolarLine
. - zones (
Set displays
ofintegers
, optional) – Set ofZones
to load. UseNone
to load all zones. (default:None
) - variables (
Set displays
ofstrings
orintegers
, optional) – Set ofVariables
to load. UseNone
to load all variables. (default:None
) - collapse (
boolean
, optional) – ReindexZones
andVariables
if any are disabled. (default:False
) - skip – (3-
tuple
ofintegers
, 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 theZones
to matching strands, if they exist. Otherwise, if the new data specifies strands, new ones will be created beginning after the last strand in theDataset
. (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 toFalse
if you only want annotations such as text or geometries. (default:True
)
Returns: Raises: TecplotSystemError
– Internal error when loading data.TecplotTypeError
– In-valid input.
- filenames (
-
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
orlist
ofstrings
) – 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 viaos.getcwd()
. - frame (
Frame
, optional) – TheFrame
to attach the resultingDataset
. IfNone
, the currently activeFrame
is used and the zones are appended by default. - append (
boolean
, optional) – Append the data to the existingDataset
. IfFalse
, the existing data attached to theFrame
is deleted and replaced. (default:True
) - reset_style (
boolean
, optional) – Reset the style for destinationFrame
, ifFalse
, theFrame
‘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 enabledZone
for the initial plot. This option is particularly useful if you have manyZones
and want to get the data into the Tecplot Engine and the firstZone
drawn as fast as possible. The inactiveZones
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 isTrue
. To have Tecplot 360 EX determine the most appropriate plot type for the data, usePlotType.Automatic
. Possible values are:PlotType.Automatic
(default),Cartesian3D
,Cartesian2D
,XYLine
,PlotType.Sketch
,PolarLine
. - zones (
list
ofintegers
, optional) – List of zone indexes to load starting from zero.None
implies loading all zones. (default:None
) - variables (
list
ofintegers
, 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 theZones
to matching strands, if they exist. Otherwise, if the new data specifies strands, new ones will be created beginning after the last strand in theDataset
. (default:False
) - include_boundary_conditions (
boolean
, optional) – Load the boundary conditions along with the data. (default:False
)
Returns: Raises: TecplotSystemError
– Internal error when loading data.TecplotTypeError
– Invalid input.
- filenames (
-
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
orlist
ofstrings
, optional) – Case (.cas) files to be read. - data_filenames (
string
orlist
ofstrings
, optional) – Data (.dat, .xml etc.) files to be read. - frame (
Frame
, optional) – TheFrame
to attach the resultingDataset
. IfNone
, the currently activeFrame
is used and the zones are appended by default. - append (
boolean
, optional) – Append the data to the existingDataset
. IfFalse
, the existing data attached to theFrame
is deleted and replaced. (default:True
) - reset_style (
boolean
, optional) – Reset the style for destinationFrame
, ifFalse
, theFrame
‘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 enabledZone
for the initial plot. This option is particularly useful if you have manyZones
and want to get the data into the Tecplot Engine and the firstZone
drawn as fast as possible. The inactiveZones
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 isTrue
. To have Tecplot 360 EX determine the most appropriate plot type for the data, usePlotType.Automatic
. Possible values are:PlotType.Automatic
(default),Cartesian3D
,Cartesian2D
,XYLine
,PlotType.Sketch
,PolarLine
. - zones (
string
orlist
ofintegers
, 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 thevariables
option. (default: “CellsAndBoundaries”) - variables (
list
ofstrings
, 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. IfNone
, 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 theZones
to matching strands, if they exist. Otherwise, if the new data specifies strands, new ones will be created beginning after the last strand in theDataset
. (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 thedata_filenames
list. (default:False
)
Returns: Raises: TecplotSystemError
– Internal error when loading data.TecplotTypeError
– In-valid input.
Notes
The
zones
option takes either alist
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 thevariables
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])
- case_filenames (
-
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
orlist
ofstrings
, optional) – One or more grid file names to be read. - solution_filenames (
string
orlist
ofstrings
, optional) – One or more solution data file names to be read. - function_filenames (
string
orlist
ofstrings
, optional) – One or more function file names. - name_filename (
string
, optional) – Path to the name file. - frame (
Frame
, optional) – TheFrame
to attach the resultingDataset
. IfNone
, the currently activeFrame
is used and the zones are appended by default. - append (
boolean
, optional) – Append the data to the existingDataset
. IfFalse
, the existing data attached to theFrame
is deleted and replaced. (default:True
) - reset_style (
boolean
, optional) – Reset the style for destinationFrame
, ifFalse
, theFrame
‘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 enabledZone
for the initial plot. This option is particularly useful if you have manyZones
and want to get the data into the Tecplot Engine and the firstZone
drawn as fast as possible. The inactiveZones
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 isTrue
. To have Tecplot 360 EX determine the most appropriate plot type for the data, usePlotType.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 requiresis_multi_grid
andstyle
to be set as well. - is_multi_grid (
boolean
, optional) – Sets data as multi-grid and overrides the automatic data structure detection. Setting this requiresdata_structure
andstyle
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 requiresdata_structure
andis_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 theZones
to matching strands, if they exist. Otherwise, if the new data specifies strands, new ones will be created beginning after the last strand in theDataset
. (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: Raises: TecplotSystemError
– Internal error when loading data.TecplotValueError
– In-valid input.
Note
Data structure is automatically detected by default.
The options
data_structure
,is_multi_grid
andstyle
must be supplied together or not at all. When all of these areNone
, 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)
- grid_filenames (
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) – TheFrame
which holds theDataset
to be written. If this option and dataset are bothNone
, the currently activeFrame
is used. (default:None
) - dataset (
Dataset
, optional) – TheDataset
to write out. If this and frame are bothNone
, theDataset
of the currently activeFrame
is used. (default:None
) - zones (
list
ofZones
, optional) –Zones
to write out. IfNone
, allZones
will be saved. - variables (
list
ofVariables
, optional) –Variables
to write out. IfNone
, allVariables
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 toFalse
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. IfFalse
, 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 toFalse
to write the datafile without modifying Tecplot’s current data file to layout association. If version is set to anything other thanBinaryFileVersion.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
andBinaryFileVersion.Current
. (default:BinaryFileVersion.Current
)
Returns: 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])
- filename (
-
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) – TheFrame
which holds theDataset
to be written. If this option and dataset are bothNone
, the currently activeFrame
is used. (default:None
) - dataset (
Dataset
, optional) – TheDataset
to write out. If this and frame are bothNone
, theDataset
of the currently activeFrame
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 toFalse
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. IfFalse
, 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
ofZones
, optional) –Zones
to write out. UseNone
to write out allZones
. (default:None
) - variables (
list
ofVariables
, optional) –Variables
to write out. UseNone
to write out allVariables
. (default:None
) - precision (
integer
, optional) – ASCII decimal precision to use. (default: 12)
Returns: 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])
- filename (
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 theDataset
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
ofintegers
, optional) – The(i,j,k)
-index of the cell to start looking for the given position. This must be used withstarting_zone
. - starting_zone (
Zone
, required only whenstarting_cell
is given) – The first zone to start searching. - zones (
list
ofZones
, optional) – Limits the search to the given zones.None
implies searching all zones. (default:None
) - dataset (
Dataset
, optional) – TheDataset
to probe. (defaults to the activeDataset
.) - frame (
Frame
, optional) – TheFrame
which determines the spatial variable assignment(X,Y,Z)
. (defaults to the activeFrame
.)
Returns: (data, cell, zone)
:- x,y,z (
Data Operations¶
-
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. IfNone
, 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 ofZone
objects to operate on. May be a list, set, tuple, or any iterable container. IfNone
, the equation will be applied to all zones. - i_range (
Range
, optional) – Tuple of integers for I: (min, max, step). IfNone
, 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). IfNone
, 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). IfNone
, then the equation will operate on the entire range. Not used for finite element nodal data. - value_location (
ValueLocation
, optional) – VariableValueLocation
for the variable on the left hand side. This is used only if this variable is being created for the first time. IfNone
, 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. IfNone
, 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: 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))
- equation (
Data Access¶
Dataset¶
-
class
tecplot.data.
Dataset
(uid, frame)[source]¶ A matrix of
Zones
andVariables
.Parameters: This is the primary data-holding object within the Tecplot Engine. A
Dataset
can be shared among severalFrames
, though any particularDataset
object will have a handle to at least one of them. Any modification of a sharedDataset
will be reflected in allFrames
that use it.Though a
Dataset
is usually attached to aFrame
and the plot style associated with that, it can be thought of as independent from any style or plotting representation. EachDataset
consists of a list ofVariables
which are used by one or more of a list ofZones
. TheVariable
determines the data type while theZone
determines the layout such as shape and ordered vs unordered.The actual data are found at the intersection of a
Zone
andVariable
and the resulting object is anArray
. The data array can be obtained using either path:>>> # These two lines obtain the same object "x" >>> x = dataset.zone('My Zone').variable('X') >>> x = dataset.variable('X').zone('My Zone')
A
Dataset
is the object returned by most data-loading operation in PyTecplot:>>> dataset = tecplot.data.load_tecplot('my_data.plt')
Under
Dataset
, there are a number methods to create and deletezones
andvariables
.Attributes
VariablesNamedTuple
A collections.namedtuple
object using variable names.num_variables
Number of Variables
in thisDataset
.num_zones
Number of Zones
in thisDataset
.title
Title of this Dataset
.Methods
add_fe_zone
(zone_type, name, num_points, ...)add_ordered_zone
(name, shape[, dtypes, locs])add_poly_zone
(name, zone_type, num_points, ...)add_variable
(name[, dtypes, locations])Add a single Variable
to the activeDataset
.add_zone
(zone_type, name, shape[, dtypes, ...])Add a single Zone
to thisDataset
.copy_zones
(*zones)Copies Zones
within thisDataset
.delete_variables
(*variables)Remove Variables
from thisDataset
.delete_zones
(*zones)Remove Zones
from thisDataset
.variable
(pattern)Returns the Variable
by index or string pattern.variables
([pattern])Yields all Variables
matching a pattern.zone
(pattern)Returns Zone
by index or string pattern.zones
([pattern])Yields all Zones
matching a pattern.
-
Dataset.
VariablesNamedTuple
¶ A
collections.namedtuple
object using variable names.Note
The variable names are transformed to be unique, valid identifiers suitable for use as the key-list for a
collections.namedtuple
. This means that all invalid characters such as spaces and dashes are converted to underscores, leading numbers and Python keywords are prepended by underscores and duplicate variable names are indexed starting with zero.Examples
This example shows how one can use this n-tuple type with the result from a call to
tecplot.data.query.probe_at_position
:>>> from os import path >>> import tecplot as tp >>> examples_dir = tp.session.tecplot_examples_directory() >>> datafile = path.join(examples_dir,'3D_Volume','jetflow.plt') >>> dataset = tp.data.load_tecplot(datafile) >>> result = tp.data.query.probe_at_position(0,0.1,0.3) >>> data = dataset.VariablesNamedTuple(*result.data) >>> msg = '(RHO, E) = ({:.2f}, {:.2f})' >>> print(msg.format(data.RHO, data.E)) (RHO, E) = (1.17, 252930.37)
-
Dataset.
add_fe_zone
(zone_type, name, num_points, num_elements, dtypes=None, locs=None, **kwargs)[source]¶
-
Dataset.
add_variable
(name, dtypes=None, locations=None)[source]¶ Add a single
Variable
to the activeDataset
.Parameters: - name (
string
) – The name of the newVariable
. This does not have to be unique. - dtypes (
FieldDataType
orlist
ofFieldDataType
, optional) – Data types of thisVariable
for eachZone
in the currently activeDataset
. Options are:FieldDataType.Float
,Double
,Int32
,Int16
,Byte
andBit
. If a single value, this will be duplicated for allZones
. (default:None
) - locations (
ValueLocation
orlist
ofValueLocation
, optional) – Point locations of thisVariable
for eachZone
in the currently activeDataset
. Options are:Nodal
andCellCentered
. If a single value, this will be duplicated for allZones
. (default:None
)
Raises: - name (
-
Dataset.
add_zone
(zone_type, name, shape, dtypes=None, locations=None, **kwargs)[source]¶ Add a single
Zone
to thisDataset
.Parameters: - zone_type (
ZoneType
) – The type ofZone
to be created. Possible values are:Ordered
,FETriangle
,FEQuad
,FETetra
,FEBrick
,FELineSeg
,FEPolyhedron
andFEPolygon
. - name (
string
) – Name of the newZone
. This does not have to be unique. - shape (
integer
orlist
ofintegers
) – Specifies the length and dimension (up to three) of the newZone
. A 1DZone
is assumed if a singleint
is given. This is (i, j, k) for orderedZones
, (num_points, num_elements) for finite-elementZones
and (num_points, num_elements, num_faces) for polytopeZones
where the number of faces is known. - dtypes (
FieldDataType
,list
ofFieldDataType
, optional) – Data types of thisZone
for eachVariable
in the currently activeDataset
. Options are:FieldDataType.Float
,Double
,Int32
,Int16
,Byte
andBit
. If a single value, this will be duplicated for allVariables
. IfNone
then the type of the firstVariable
, defaulting toFieldDataType.Float
, is used for all. (default:None
) - locations (
ValueLocation
,list
ofValueLocation
, optional) – Point locations of thisZone
for eachVariable
in the currently activeDataset
. Options are:Nodal
andCellCentered
. If a single value, this will be duplicated for allVariables
. IfNone
then the type of the firstVariable
, defaulting toNodal
, is used for all. (default:None
) - parent_zone (
Zone
, optional) – A parentZone
to be used when generating surface-restricted streamtraces. - solution_time (
float
, optional) – (default: 0) - strand_id (
integer
, optional) – Associate this newZone
with a particular strand.
Raises: - zone_type (
-
Dataset.
copy_zones
(*zones)[source]¶ Copies
Zones
within thisDataset
.Parameters: zones ( Zone
, optional) – Specificzones
to copy.Returns:
list
of the newly createdZones
.Example usage:
>>> zones = dataset.copy_zones()
-
Dataset.
delete_variables
(*variables)[source]¶ Remove
Variables
from thisDataset
.Parameters: *variables ( Variable
or indexinteger
) – 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 lastVariable
can not be deleted. This command deletes all but the firstVariable
in theDataset
(usuallyX
):>>> # Try to delete all variables: >>> dataset.delete_variables(dataset.variables()) >>> # Dataset requires at least one variable to >>> # exist, so it leaves the first one: >>> print([v.name for v in dataset.variables()]) ['X']
-
Dataset.
delete_zones
(*zones)[source]¶ Remove
Zones
from thisDataset
.Parameters: *zones ( Zone
or indexinteger
) – 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 lastZone
can not be deleted. This command deletes all but the firstZone
in theDataset
:dataset.delete_zones(dataset.zones())
-
Dataset.
num_variables
¶ Number of
Variables
in thisDataset
.Type: integer
Example usage:
>>> for i in range(dataset.num_variables): ... variable = dataset.variable(i)
-
Dataset.
num_zones
¶ Number of
Zones
in thisDataset
.Type: integer
Example usage:
>>> for i in range(dataset.num_zones): ... zone = dataset.zone(i)
-
Dataset.
title
¶ Title of this
Dataset
.Type: string
Raises: TecplotSystemError
Example usage:
>>> dataset.title = 'My Data'
-
Dataset.
variable
(pattern)[source]¶ Returns the
Variable
by index or string pattern.Parameters: pattern ( integer
orstring
) – Zero-based index orglob-style pattern
in which case, the first match is returned.Raises: TecplotIndexError
The
Variable.name
attribute is used to match the pattern to the desiredVariable
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.Parameters: pattern ( string
pattern, optional) –glob-style pattern
used to match variable names orNone
which will return all variables. (default:None
)Example usage:
>>> for variable in dataset.variables('A*'): ... array = variable.zone('My Zone')
-
Dataset.
zone
(pattern)[source]¶ Returns
Zone
by index or string pattern.Parameters: pattern ( integer
orstring
) – Zero-based index orglob-style pattern
in which case, the first match is returned.Raises: TecplotIndexError
The
Zone.name
attribute is used to match the pattern to the desiredZone
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.Parameters: pattern ( string
pattern, optional) –glob-style pattern
used to match zone names orNone
which will return all zones. (default:None
)Example usage:
>>> for zone in dataset.zones('A*'): ... x_array = zone.variable('X')
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 parentDataset
or (non-uniquely) by name. In general, aZone
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 parentDataset
.Methods
zone
(pattern)Returns Array
by index or string pattern.zones
([pattern])Yields all Arrays
matching a pattern.
-
Variable.
name
¶ Returns or sets the name.
Type: string
Raises: TecplotSystemError
-
Variable.
zone
(pattern)[source]¶ Returns
Array
by index or string pattern.Parameters: pattern ( integer
orstring
) – Zero-based index orglob-style pattern
in which case, the first match is returned.The
Zone.name
attribute is used to match the pattern to the desiredArray
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
Zone¶
-
class
tecplot.data.
Zone
(uid, dataset)[source]¶ Key value for a data array within a
Dataset
.Parameters: Zones
can be identified (uniquely) by the index with their parentDataset
or (non-uniquely) by name. In general, aVariable
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. num_variables
Number of Variables
in the parentDataset
.shape
The shape of the associated data arrays. solution_time
Returns the solution time. strand
Returns the StrandID. type
Returns the zone type. Methods
copy
()duplicate this Zone
in its currently held parentDataset
.variable
(pattern)Returns an Array
by index or string pattern.variables
([pattern])Yields all Arrays
matching a pattern.
-
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.
variable
(pattern)[source]¶ Returns an
Array
by index or string pattern.Parameters: pattern ( integer
orstring
) – Zero-based index orglob-style pattern
in which case, the first match is returned.The
Variable.name
attribute is used to match the pattern to the desiredArray
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
Array¶
-
class
tecplot.data.
Array
(dataset, zone, variable)[source]¶ Low-level accessor for underlying data within a
Dataset
.Attributes
c_type
data
data_type
minmax
shape
(i,j,k) shape size
value
current value Methods
as_numpy_array
(arr)copy
([offset, size])max
()min
()
-
Array.
as_numpy_array
(arr)¶
-
Array.
c_type
¶
-
Array.
data
¶
-
Array.
data_type
¶
-
Array.
minmax
¶
-
Array.
shape
¶ (i,j,k) shape
-
Array.
size
¶
-
Array.
value
¶ current value