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 (
stringorlistofstrings) – Files to be read. - frame (
Frame, optional) – TheFrameto attach the resultingDataset. IfNone, the currently activeFrameis used and the zones are appended by default. - append (
boolean, optional) – Append the data to the existingDataset. IfFalse, the existing data attached to theFrameis 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 enabledZonefor the initial plot. This option is particularly useful if you have manyZonesand want to get the data into the Tecplot Engine and the firstZonedrawn as fast as possible. The inactiveZonescan 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 (
setofintegers, optional) – Set ofZonesto load. UseNoneto load all zones. (default:None) - variables (
setofstringsorintegers, optional) – Set ofVariablesto load. UseNoneto load all variables. (default:None) - collapse (
boolean, optional) – ReindexZonesandVariablesif any are disabled. (default:False) - skip – (3-
tupleofintegers, 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 theZonesto 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 toFalseif 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 (
stringorlistofstrings) – 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) – TheFrameto attach the resultingDataset. IfNone, the currently activeFrameis used and the zones are appended by default. - append (
boolean, optional) – Append the data to the existingDataset. IfFalse, the existing data attached to theFrameis 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 enabledZonefor the initial plot. This option is particularly useful if you have manyZonesand want to get the data into the Tecplot Engine and the firstZonedrawn as fast as possible. The inactiveZonescan 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 (
listofintegers, optional) – List of zone indexes to load starting from zero.Noneimplies loading all zones. (default:None) - variables (
listofintegers, optional) – List of variable indexes, beyond the first coordinate variables, to load starting from zero.Noneimplies 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 theZonesto 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 (
stringorlistofstrings, optional) – Case (.cas) files to be read. - data_filenames (
stringorlistofstrings, optional) – Data (.dat, .xml etc.) files to be read. - frame (
Frame, optional) – TheFrameto attach the resultingDataset. IfNone, the currently activeFrameis used and the zones are appended by default. - append (
boolean, optional) – Append the data to the existingDataset. IfFalse, the existing data attached to theFrameis 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 enabledZonefor the initial plot. This option is particularly useful if you have manyZonesand want to get the data into the Tecplot Engine and the firstZonedrawn as fast as possible. The inactiveZonescan 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 (
stringorlistofintegers, 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 thevariablesoption. (default: “CellsAndBoundaries”) - variables (
listofstrings, optional) – List of variable names to load.Noneimplies 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 theZonesto 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_filenameslist. (default:False)
Returns: Raises: TecplotSystemError– Internal error when loading data.TecplotTypeError– In-valid input.
Notes
The
zonesoption takes either alistof 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 thevariablesoption:>>> 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 (
stringorlistofstrings, optional) – One or more grid file names to be read. - solution_filenames (
stringorlistofstrings, optional) – One or more solution data file names to be read. - function_filenames (
stringorlistofstrings, optional) – One or more function file names. - name_filename (
string, optional) – Path to the name file. - frame (
Frame, optional) – TheFrameto attach the resultingDataset. IfNone, the currently activeFrameis used and the zones are appended by default. - append (
boolean, optional) – Append the data to the existingDataset. IfFalse, the existing data attached to theFrameis 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 enabledZonefor the initial plot. This option is particularly useful if you have manyZonesand want to get the data into the Tecplot Engine and the firstZonedrawn as fast as possible. The inactiveZonescan 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_gridandstyleto be set as well. - is_multi_grid (
boolean, optional) – Sets data as multi-grid and overrides the automatic data structure detection. Setting this requiresdata_structureandstyleto 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_structureandis_multi_gridto 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 theZonesto 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_gridandstylemust 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) – TheFramewhich holds theDatasetto be written. If this option and dataset are bothNone, the currently activeFrameis used. (default:None) - dataset (
Dataset, optional) – TheDatasetto write out. If this and frame are bothNone, theDatasetof the currently activeFrameis used. (default:None) - zones (
listofZones, optional) –Zonesto write out. IfNone, allZoneswill be saved. - variables (
listofVariables, optional) –Variablesto write out. IfNone, allVariableswill 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 toFalseif 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 toFalseto 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,Tecplot2009andBinaryFileVersion.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) – TheFramewhich holds theDatasetto be written. If this option and dataset are bothNone, the currently activeFrameis used. (default:None) - dataset (
Dataset, optional) – TheDatasetto write out. If this and frame are bothNone, theDatasetof the currently activeFrameis 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 toFalseif 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 (
listofZones, optional) –Zonesto write out. UseNoneto write out allZones. (default:None) - variables (
listofVariables, optional) –Variablesto write out. UseNoneto 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
Framewhich may be any of the associated variables in theDatasetand 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-
tupleofintegers, 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_cellis given) – The first zone to start searching. - zones (
listofZones, optional) – Limits the search to the given zones.Noneimplies searching all zones. (default:None) - dataset (
Dataset, optional) – TheDatasetto probe. (defaults to the activeDataset.) - frame (
Frame, optional) – TheFramewhich determines the spatial variable assignment(X,Y,Z). (defaults to the activeFrame.)
Returns: (data, cell, zone):- x,y,z (
Data Operations¶
-
class
tecplot.data.operate.Range(min, max, step)¶ Limit the data altered by the
execute_equationfunction.The Range specification of I,J,K range indices for
execute_equationfollow 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
Zoneobjects 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
Zoneobjects, optional): Iterable container ofZoneobjects 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) – VariableValueLocationfor 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) –boolvalue 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 (
Dataset¶
-
class
tecplot.data.Dataset(uid, frame)[source]¶ A matrix of
ZonesandVariables.Parameters: A
Datasetcan be shared among severalFrames, though any particularDatasetobject will have a handle to at least one of them. Any modification of a sharedDatasetwill be reflected in allFramesthat use it.Attributes
num_variablesNumber of Variablesin thisDataset.num_zonesNumber of Zonesin thisDataset.titleTitle of this Dataset.Methods
add_ordered_zoneadd_fe_zoneadd_poly_zoneadd_variableAdd a single Variableto the activeDataset.add_zoneAdd a single Zoneto the activeDataset.copy_zonesCopies Zoneswithin thisDataset.delete_variablesRemove Variablesfrom thisDataset.delete_zonesRemove Zonesfrom thisDataset.variableReturns the Variableby index or string pattern.variablesYields all Variablesmatching a pattern.zoneReturns Zoneby index or string pattern.zonesYields all Zonesmatching 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: stringRaises: TecplotSystemError
-
Dataset.variable(pattern)[source]¶ Returns the
Variableby index or string pattern.Parameters: pattern ( integerorstring) – Zero-based index orglob-style patternin which case, the first match is returned.Raises: TecplotIndexErrorThe
Variable.nameattribute is used to match the pattern to the desiredVariablethough 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.zone(pattern)[source]¶ Returns
Zoneby index or string pattern.Parameters: pattern ( integerorstring) – Zero-based index orglob-style patternin which case, the first match is returned.Raises: TecplotIndexErrorThe
Zone.nameattribute is used to match the pattern to the desiredZonethough 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.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
Variableto the activeDataset.Parameters: - name (
string) – The name of the newVariable. This does not have to be unique. - dtypes (
FieldDataTypeorlistofFieldDataType, optional) – Data types of thisVariablefor eachZonein the currently activeDataset. Options are:FieldDataType.Float,Double,Int32,Int16,ByteandBit. If a single value, this will be duplicated for allZones. (default:None) - locations (
ValueLocationorlistofValueLocation, optional) – Point locations of thisVariablefor eachZonein the currently activeDataset. Options are:NodalandCellCentered. 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
Zoneto the activeDataset.Parameters: - zone_type (
ZoneType) – The type ofZoneto be created. Possible values are:Ordered,FETriangle,FEQuad,FETetra,FEBrick,FELineSeg,FEPolyhedronandFEPolygon. - name (
string) – Name of the newZone. This does not have to be unique. - shape (
integerorlistofintegers) – Specifies the length and dimension (up to three) of the newZone. A 1DZoneis assumed if a singleintis given. This is (i, j, k) for orderedZones, (num_points, num_elements) for finite-elementZonesand (num_points, num_elements, num_faces) for polytopeZoneswhere the number of faces is known. - dtypes (
FieldDataType,listofFieldDataType, optional) – Data types of thisZonefor eachVariablein the currently activeDataset. Options are:FieldDataType.Float,Double,Int32,Int16,ByteandBit. If a single value, this will be duplicated for allVariables. IfNonethen the type of the firstVariable, defaulting toFieldDataType.Float, is used for all. (default:None) - locations (
ValueLocation,listofValueLocation, optional) – Point locations of thisZonefor eachVariablein the currently activeDataset. Options are:NodalandCellCentered. If a single value, this will be duplicated for allVariables. IfNonethen the type of the firstVariable, defaulting toNodal, is used for all. (default:None) - parent_zone (
Zone, optional) – A parentZoneto be used when generating surface-restricted streamtraces. - solution_time (
float, optional) – (default: 0) - strand_id (
integer, optional) – Associate this newZonewith a particular strand.
Raises: - zone_type (
-
Dataset.delete_variables(*variables)[source]¶ Remove
Variablesfrom thisDataset.Parameters: *variables ( Variableor 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
Variablescan be deleted at once, though the lastVariablecan not be deleted. This command deletes all but the firstVariablein theDataset(usuallyX):dataset.delete_variables(dataset.variables())
-
Dataset.delete_zones(*zones)[source]¶ Remove
Zonesfrom thisDataset.Parameters: *zones ( Zoneor 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
Zonescan be deleted at once, though the lastZonecan not be deleted. This command deletes all but the firstZonein theDataset:dataset.delete_zones(dataset.zones())
-
Dataset.__str__()[source]¶ Brief string representation.
Returns: string– Brief representation of thisDataset, showingZonesandVariables.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 thisDataset.The string returned can be executed to generate a clone of this
Datasetobject:>>> 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
Variable¶
-
class
tecplot.data.Variable(uid, dataset)[source]¶ Key value for a data array within a
Dataset.Parameters: Variablescan be identified (uniquely) by the index with their parentDatasetor (non-uniquely) by name. In general, aZonemust be selected to access the underlying data array.Attributes
indexZero-based position within the parent Dataset.nameReturns or sets the name. num_zonesNumber of Zonesin the parentDataset.Methods
zoneReturns Arrayby index or string pattern.zonesYields all Arraysmatching a pattern.Special Methods
__str__Brief string representation. __repr__Executable string representation. __eq__Checks for equality in the Tecplot Engine.
-
Variable.name¶ Returns or sets the name.
Type: stringRaises: TecplotSystemError
-
Variable.zone(pattern)[source]¶ Returns
Arrayby index or string pattern.Parameters: pattern ( integerorstring) – Zero-based index orglob-style patternin which case, the first match is returned.The
Zone.nameattribute is used to match the pattern to the desiredArraythough 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.__str__()[source]¶ Brief string representation.
Returns: string– Brief representation of thisVariable, showingZones.Example:
>>> x = dataset.variable('x') >>> print(x) Variable: x Zones: ['Rectangular zone']
-
Variable.__repr__()[source]¶ Executable string representation.
Returns: string– Internal representation of thisVariable.The string returned can be executed to generate a clone of this
Variableobject:>>> 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
Zone¶
-
class
tecplot.data.Zone(uid, dataset)[source]¶ Key value for a data array within a
Dataset.Parameters: Zonescan be identified (uniquely) by the index with their parentDatasetor (non-uniquely) by name. In general, aVariablemust be selected to access the underlying data array.Attributes
indexZero-based position within the parent Dataset.nameReturns or sets the name. num_pointsNumber of elements in the associated data array. shapeThe shape of the associated data arrays. num_variablesNumber of Variablesin the parentDataset.Methods
variableReturns an Arrayby index or string pattern.variablesYields all Arraysmatching a pattern.copyduplicate this Zonein its currently held parentDataset.Special Methods
__str__Brief string representation. __repr__Executable string representation. __eq__Checks for equality in the Tecplot Engine.
-
Zone.name¶ Returns or sets the name.
Type: stringRaises: 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
Arrayby index or string pattern.Parameters: pattern ( integerorstring) – Zero-based index orglob-style patternin which case, the first match is returned.The
Variable.nameattribute is used to match the pattern to the desiredArraythough 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.__str__()[source]¶ Brief string representation.
Returns: string– Brief representation of thisZone, showing a list of associatedVariables.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 thisZone.The string returned can be executed to generate a clone of this
Zoneobject:>>> 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