def add_xylinemap(plot=None, **args): ''' Add and configure a linmap to an XYLinePlot ''' linemap_types = { 'name': str, 'show': bool, 'show_in_legend': bool, 'x_axis_index': int, 'x_variable': _Variable, 'x_variable_index': int, 'y_axis_index': int, 'y_variable': _Variable, 'y_variable_index': int, 'zone': _Zone, 'zone_index': int, } line_types = { 'color': _Color, 'line_pattern': _Pattern, 'line_thickness': float, 'pattern_length': float, 'show': bool, } symbols_types = { 'color': _Color, 'fill_color': _Color, 'fill_mode': _FillMode, 'line_thickness': float, 'show': bool, 'size': float, 'step': float, 'step_mode': _StepMode, # shape... must be handled special (polymophic) } # PyTecplot has no way to instantiate line or symbols types, # so need to manually assign attributes. line_args = args.pop('line', {}) symbols_args = args.pop('symbols', {}) shape_arg = _SymbolShape(symbols_args.pop('shape', 'Circle')) # Set all the attributes if not plot: plot = tp.active_frame().plot(tpc.PlotType.XYLine) plot.activate() linemap = plot.add_linemap() set_attributes(linemap, args, linemap_types) set_attributes(linemap.line, line_args, line_types) set_attributes(linemap.symbols, symbols_args, symbols_types) linemap.symbols.symbol().shape = shape_arg return linemap
def to_tecplot(df, var_list): try: import tecplot as tp except ImportError: print(f"Pytecplot package not installed.") exit() tp.session.connect() dataset = tp.active_frame().create_dataset("Data", var_list) shape = _get_2D_shape(df, "r", "z") numerical_zone = dataset.add_ordered_zone("Numerical", shape=shape) _export_variables_from_dataframe(df, var_list, numerical_zone) print("Finished exporting to tecplot.")
def __init__(self, file_name): self.dataset = tp.data.load_tecplot( file_name, read_data_option=tp.constant.ReadDataOption.ReplaceInActiveFrame) self.frame = tp.active_frame() self.plot = self.frame.plot() try: self.dataset.variable('Z') self.model_type = '3D' except tp.exception.TecplotPatternMatchError: self.model_type = '2D' self.setup_fake_plane() self.base_zones = self.frame.active_zones()
def create_rect_zone(imax, jmax, xminmax, yminmax): """ Creates a rectangular zone and returns the zone object """ cmd = """$!CreateRectangularZone IMAX = {} JMAX = {} X1 = {} X2 = {} Y1 = {} Y2 = {}""".format(imax,jmax,xminmax[0], xminmax[1], yminmax[0], yminmax[1]) tp.macro.execute_command(cmd) return tp.active_frame().dataset.zone(-1)
def prepareSceneIce(): global plot # Change Aspect Ratio tecplot.macro.execute_file('changePaperSize.mcr') tecplot.active_frame().plot().frame.width = 14 tecplot.active_frame().plot().frame.height = 8 tecplot.active_frame().plot().frame.position = (0, 0) tecplot.active_frame().plot_type = PlotType.Cartesian3D plot = tecplot.active_frame().plot() # Rotate Data tecplot.macro.execute_command('''$!AxialDuplicate ZoneList = [''' + str(1) + '-' + str(wallRegions) + '''] Angle = 180 NumDuplicates = 1 XVar = 1 YVar = 2 ZVar = 3''') tecplot.macro.execute_command('$!GlobalThreeD RotateOrigin{X = 0}') tecplot.macro.execute_command('$!GlobalThreeD RotateOrigin{Y = 0}') tecplot.macro.execute_command('$!GlobalThreeD RotateOrigin{Z = 0}')
def plot_data(plot): """Plot Isosurface of constant Pressure, contouring on Temperature""" T = plot.frame.dataset.variable('Temperature') P = plot.frame.dataset.variable('Pressure') plot = tp.active_frame().plot(PlotType.Cartesian3D) plot.show_shade = False plot.show_slices = True plot.show_isosurfaces = True contour = plot.slice(0).contour.flood_contour_group contour.variable = T contour.legend.auto_resize = True contour.levels.reset_levels(np.linspace(280, 380, 201)) isosurf = plot.isosurface(0) isosurf.definition_contour_group_index = 1 isosurf.definition_contour_group.variable = P isosurf.isosurface_values = -6000 isosurf.contour.flood_contour_group = contour slice = tp.active_frame().plot().slice(0) slice.effects.use_translucency = True slice.effects.surface_translucency = 40 plot.view.psi = 68.2286 plot.view.theta = -124.114 plot.view.position = 2.95931, 2.15999, 1.45886 plot.view.width = 0.339885
def load(filename): ''' Load tecplot surface file into the workspace''' global _dataset try: _dataset = (tecplot.data.load_tecplot( filenames=filename, read_data_option=tecplot.constant.ReadDataOption.Replace) ) except (tecplot.exception.TecplotSystemError, tecplot.exception.TecplotTypeError ): print('-> Error loading file %s' % filename) raise SystemExit tecplot.active_frame().plot_type = tecplot.constant.PlotType.Cartesian3D print('-> Loaded File: %s.' % filename)
def probe_index_through_time(zone, variable, index_number): """ Follows a specific index in a zone/variable through time and returns a list of tuples. The length of the list is equivalent to the number of zones in the strand associated with the input zone. Each tuple is (solution_time, element_value) zone - Any Zone in the strand you want to interrogate. All zones must have the same number of points/elements variable - The Variable you want to interrogate. All Zone/Vars must have the same value location (cell-centered/node-centered) index_number - 0-based node/element number you want to follow through time. For cell-centered variables this should be an element number. For node-centered variables this should be a node number. Example: import tecplot as tp import tpplot import tpprobe tp.session.connect() ds = tp.active_frame().dataset zone = ds.zone(0) var = ds.variable("salinity") element_num = 128 result = tpprobe.probe_element_through_time(zone, var, element_num) tpplot.plot_line_data(result, "Time vs {}".format(var.name), "Time", var.name) """ result = [] zones = [ z for z in tp.active_frame().dataset.zones() if z.strand == zone.strand ] vals = zone.values(variable) num_vals = len(vals) var_location = vals.location for z in zones: vals = z.values(variable.name) if len(vals) != num_vals: raise Exception("All zones must have the same number of points.") if vals.location != var_location: raise Exception( "The variable must have the same value location (cell-centered or nodal)." ) result.append((z.solution_time, vals[index_number])) return result
def generateinterpolatedGrid(layfile, numpoints, coords): """ Function to create and save an interpolated tecplot simulation grid for radio emission calculation This will only work with Tecplot 360 installed on your system. :param layfile: Tecplot .lay file to be interpolated :param numpoints: Number of points in each spatial dimension :param coords: Size of the grid in Rstar :return: """ cwd = os.getcwd() tp.load_layout(layfile) frame1 = tp.active_frame() cur_dataset = frame1.dataset zone1 = cur_dataset.zone( 0) # zone1 is what tecplot uses for plotting in the layfile tp.macro.execute_command('''$!CreateRectangularZone IMax = {0:} JMax = {0:} KMax = {0:} X1 = -{1:} Y1 = -{1:} Z1 = -{1:} X2 = {1:} Y2 = {1:} Z2 = {1:} XVar = 1 YVar = 2 ZVar = 3'''.format(numpoints, coords)) zone2 = cur_dataset.zone(1) # name second zone for interpolation tp.data.operate.interpolate_linear(zone2, source_zones=zone1, variables=[3, 10, 22]) # create second zone and fill with variables tp.data.save_tecplot_ascii( cwd + '/interpol_grid_{0:}Rstar_{1:}points.dat'.format(coords, numpoints), zones=[zone2], variables=[0, 1, 2, 3, 10, 22], include_text=False, precision=9, include_geom=False, use_point_format=True) return
def setup_plot(): """ Load the F-18 dataset from Tecplot 360's examples and show the jet surface in 3D. """ tp.new_layout() exdir = tp.session.tecplot_examples_directory() datafile = os.path.join(exdir, 'SimpleData', 'F18.plt') ds = tp.data.load_tecplot(datafile) frame = tp.active_frame() frame.show_border = False plot = frame.plot(PlotType.Cartesian3D) plot.activate() plot.contour(0).variable = ds.variable('S') plot.show_contour = True return plot
def create_surface_dataset(extracted_surface_list, label, variables): '''Create a tecplot dataset with all the sections arguments: extracted_section_list - (list of SectionData objects) label - (str) dataset name variables - (list of str) ''' new_dataset = tecplot.active_frame().create_dataset(label, variables, True) for boundary in extracted_surface_list: srf_name = 'S0%d%d' % (boundary.block + 1, boundary.face) dimensions = (boundary.imax, boundary.jmax, 1) z = new_dataset.add_ordered_zone(name=srf_name, shape=dimensions) for i, v in enumerate(variables): z.values(v)[:] = boundary.data[:, i] return new_dataset
def get_zones_by_strand_in_active_frame(): """Returns a dictionary of strands to zone list for the active frame""" ptr = _tecutil.DataSetGetStrandIDs() strands = ctypes.cast(ptr, tp.tecutil.IndexSet) strands = [s + 1 for s in strands] strands.dealloc() zones_by_strand = {} dataset = tp.active_frame().dataset for s in strands: ptr = _tecutil.DataSetGetZonesForStrandID(s) zone_indices = ctypes.cast(ptr, tp.tecutil.IndexSet) zones = [dataset.zone(z) for z in zone_indices] zone_indices.dealloc() zones_by_strand[s] = zones return zones_by_strand
def add_line_zone(data, zone_name, x_var_name, y_var_name): """ Adds data to the existing dataset. The data is expected to be a list of 2-valued tuples: data = [ (x1, y1), (x2, y2), ... (xn, yn) ] returns a newly created zone """ ds = tp.active_frame().dataset add_variable_to_dataset(ds, x_var_name) add_variable_to_dataset(ds, y_var_name) zone = ds.add_ordered_zone(zone_name, (len(data),1,1), locations=[ValueLocation.Nodal]*ds.num_variables) zone.values(x_var_name)[:] = [n[0] for n in data] zone.values(y_var_name)[:] = [n[1] for n in data] return zone
def mul_zone2tec_plt(path, filename, FileId, df, time=None, option=1): if option == 1: tp.session.connect() tp.new_layout() # page = tp.active_page() # page.name = 'page1' # frame = page.active_frame() # frame.name = 'frame1' # dataset = frame.create_dataset('data1') # add variable name # for j in range(np.shape(df)[1]): # var = df.columns[j] # dataset.add_variable(var) # link data dataset = tp.active_frame().create_dataset('data1', df.columns) with tp.session.suspend(): # with timer("save data as tecplot .plt"): for i in range(np.shape(FileId)[0]): file = FileId.iloc[i] ind1 = int(file['id1']) ind2 = int(file['id2']) nx = int(file['nx']) ny = int(file['ny']) nz = int(file['nz']) zonename = 'B' + '{:010}'.format(i) # print('creating tecplot zone: '+zonename) zone = dataset.add_ordered_zone(zonename, (nx, ny, nz)) # zone = dataset.add_zone('Ordered', zonename, (nx, ny, nz), # solution_time=time, strand_id=1) if time is not None: zone.strand = 1 zone.solution_time = np.float64(time) data = df.iloc[ind1:ind2 + 1] data = data.sort_values(by=['z', 'y', 'x']) for j in range(np.shape(data)[1]): var = data.columns[j] zone.values(var)[:] = data[var][:] tp.data.save_tecplot_plt(path + filename + '.plt', dataset=dataset) else: dataset = tp.data.load_tecplot(path + filename + '.dat', read_data_option=2) tp.data.save_tecplot_plt(path + filename + '.plt', dataset=dataset)
def load_eqn_frame_save(dataset_path,eqn_path,frame_styles,save_paths,annotation=''): """ Load the data, run an equations file, run a set of frame styles, and export the plots. The function will save images as EPS or PNG depending on the file extension used in save_path. The default is PNG. Keyword Arguments --- dataset_path: the path to the dataset (plt) eqn_path : the path to the equation macro file (eqn) frame_styles: a list of the paths to the frame style files (sty) save_paths : a list of the pathnames of the images to save (png) annotation : (optional) a string which will be printed in the upper left corner of the plots """ ## load the data tp_data = tecplot.data.load_tecplot(dataset_path,read_data_option=tecplot.constant.ReadDataOption.Replace) print('Loaded ' + dataset_path) ## parse and run these equations print('Executing:') with open(eqn_path,'r') as f: eqns = '' for line in f: if line[0] == ' ': eqnstr = line.split("'")[1] tecplot.data.operate.execute_equation(eqnstr) print(eqnstr) print('Successfully applied equations') for i in range(len(frame_styles)): ## apply frame styles frame = tecplot.active_frame() frame.load_stylesheet(frame_styles[i]) frame.add_text(annotation,position=(7,93), size=20) print('Applied '+frame_styles[i]) ## export the plot ext = save_paths[i].split('.')[-1] if ext == 'eps': tecplot.export.save_eps(save_paths[i]) else: tecplot.export.save_png(save_paths[i],width=1200,supersample=8) print('Saved '+save_paths[i])
def load_solution(g_file, q_file): '''Load the Plot3D data into _dataset module variable arguments: g_file - (str) .g file path q_file - (str) .q file path ''' global _dataset try: _dataset = tecplot.data.load_plot3d(g_file, q_file, append=False, include_boundaries=False) except (tecplot.exception.TecplotSystemError, tecplot.exception.TecplotTypeError): print('-> Error loading file %s, or %s' % (g_file, q_file)) raise SystemExit tecplot.active_frame().plot_type = tecplot.constant.PlotType.Cartesian3D print('Loaded %s and %s' % (g_file, q_file))
def create_section_dataset(extracted_section_list, variables): '''Create a tecplot dataset with all the sections Arguments: extracted_section_list - (list of SectionData objects variables - (tuple of str) ''' new_dataset = tecplot.active_frame().create_dataset( 'Surface CPCF', variables, True) for section in extracted_section_list: sec_name = '%s_y/b=%.3f' % (section.label, section.location) z = new_dataset.add_fe_zone(tecplot.constant.ZoneType.FELineSeg, name=sec_name, num_points=len(section.data), num_elements=len(section.nodemap)) for i, v in enumerate(variables): z.values(v)[:] = section.data[:, i] z.nodemap[:] = section.nodemap return new_dataset
def create_spanwise_dataset(extracted_section_list, labels, tc_locations): '''Create a tecplot dataset with the twist and thickness distribution arguments: extracted_section_list - (list of SectionData objects) labels - (list of str) tc_locations - (list of float) ''' variables = ['y/b', 'twist', 'tcmax'] for x in tc_locations: variables.append('tc %4.2f' % x) new_dataset = (tecplot.active_frame().create_dataset( 'Spanwise twist and thickness distribution', variables, True)) for name in labels: sub_section_list = [ s for s in extracted_section_list if s.label == name ] n = len(sub_section_list) yb = np.zeros(n) twist = np.zeros(n) tcmax = np.zeros(n) thick = np.zeros(n) for i, section in enumerate(sub_section_list): yb[i] = section.location twist[i] = section.twist / np.pi * 180.0 tcmax[i] = section.max_thickness() zone = new_dataset.add_ordered_zone(name=name, shape=(n, 1, 1)) zone.values('y/b')[:] = yb[:] zone.values('twist')[:] = twist[:] zone.values('tcmax')[:] = tcmax[:] for x in tc_locations: for i, section in enumerate(sub_section_list): thick[i] = section.thickness(x) zone.values('tc %4.2f' % x)[:] = thick[:] return new_dataset
def write_tp_grouped(filename, data, data_shared, old=False, order='C'): print('Writing ' + filename + '...') logging.basicConfig(level=logging.INFO) tp.new_layout() frame = tp.active_frame() ## useful params sorted_keys = sorted(data.keys()) varname_data = list(next(iter(data.values())).keys()) varname_shared = list(data_shared.keys()) varname_all = varname_data + varname_shared shape = data_shared[varname_shared[0]].shape ## create dset dset = frame.create_dataset('data', var_names=varname_all) ## create data by zone zone_list = [] for zonename in sorted_keys: subdata = data[zonename] zone = dset.add_ordered_zone(zonename, shape) zone_list.append(zone) for name, var in subdata.items(): try: zone.values(name)[:] = var.ravel(order=order) except: print('Failed to write %s ...' % name) ## share variables for name, var in data_shared.items(): zone_list[0].values(name)[:] = var.ravel(order=order) variables_shared = [dset.variable(varname) for varname in varname_shared] dset.share_variables(zone_list[0], zone_list[1:], variables_shared) ## out if old: tp.data.save_tecplot_plt(filename + '.plt') else: tp.data.save_tecplot_szl(filename + '.szplt') print('Finished writing ' + filename + '.')
def createSlices(numPts, direction, minPos, maxPos): """ Defines and extracts numPts slices equally spaced from min to max in the given direction """ p = tp.active_frame().plot() p.show_slices = False sl = p.slice(0) sl.show_primary_slice = False sl.show_start_and_end_slices = True sl.slice_source = SliceSource.SurfaceZones if direction == "X": sl.orientation = SliceSurface.XPlanes sl.start_position = (minPos, 0, 0) sl.end_position = (maxPos, 0, 0) elif direction == "Y": sl.orientation = SliceSurface.YPlanes sl.start_position = (0, minPos, 0) sl.end_position = (0, maxPos, 0) elif direction == "Z": sl.orientation = SliceSurface.ZPlanes sl.start_position = (0, 0, minPos) sl.end_position = (0, 0, maxPos) else: print("{} is not a valid direction (X,Y,Z) for the planes creation.". format(direction)) sl.show_intermediate_slices = True sl.num_intermediate_slices = numPts - 2 #Extract the slices to zones sl.show = True p.show_slices = True tp.macro.execute_command('''$!ExtractSlices Group = 1 ExtractMode = SingleZone''') p.show_slices = False
def write_tp(filename, data, old=False, order='C'): if old: filename += '.plt' else: filename += '.szplt' print('Writing ' + filename + '...') logging.basicConfig(level=logging.INFO) tp.new_layout() frame = tp.active_frame() varname = list(data.keys()) dset = frame.create_dataset('data', var_names=varname) zone = dset.add_ordered_zone('zone', data[varname[0]].shape) for name in varname: zone.values(name)[:] = data[name].ravel(order=order) if old: tp.data.save_tecplot_plt(filename) else: tp.data.save_tecplot_szl(filename) print('Finished writing ' + filename + '.')
def ExportStreamLine(workdir, file1, zonename): # workdir = "E:\\Research\\CFD\\RAMCII\\GridConvergence\\91x100" datafile = os.path.join(workdir, file1) file2 = 'streamline.dat' dataset = tp.data.load_tecplot(datafile) frame = tp.active_frame() frame.plot_type = tp.constant.PlotType.Cartesian2D # Setup up vectors and background contour plot = frame.plot() plot.vector.u_variable = dataset.variable('u') plot.vector.v_variable = dataset.variable('v') plot.contour(0).variable = dataset.variable('t') plot.contour(1).variable = dataset.variable('tv') plot.contour(2).variable = dataset.variable('p') # get starting point of stagnation streamline x = dataset.zone(0).values('x') y = dataset.zone(0).values('y') x0 = x[0] y0 = y[0] plot.show_streamtraces = True plot.show_contour = True plot.fieldmap(1).contour.show = True # extract the data from streamline streamtraces = plot.streamtraces streamtraces.add(seed_point=[x0, y0], stream_type=Streamtrace.TwoDLine) tp.macro.execute_command('$!ExtractStreamtraces') dataset.zone(1).name = zonename tp.data.save_tecplot_ascii(os.path.join(workdir, file2), zones=[1], include_text=False, precision=9, include_geom=False, use_point_format=True)
def convert_vtk_file(vtk_file, plt_file, strand=None, solution_time=None): reader = None if vtk_file.endswith(".vtu"): reader = vtk.vtkXMLUnstructuredGridReader() elif vtk_file.endswith(".vtp"): reader = vtk.vtkXMLPolyDataReader() elif vtk_file.endswith(".vts"): reader = vtk.vtkXMLStructuredGridReader() elif vtk_file.endswith(".vti"): reader = vtk.vtkXMLImageDataReader() reader.SetFileName(vtk_file) reader.Update() vtk_dataset = reader.GetOutput() tp.new_layout() tecplot_dataset = tp.active_frame().dataset add_vtk_dataset(vtk_dataset, tecplot_dataset) for z in tecplot_dataset.zones(): z.name = os.path.basename(vtk_file) if strand and solution_time: z.strand = strand z.solution_time = solution_time tp.data.save_tecplot_plt(plt_file, dataset=tecplot_dataset)
def create_dataset(filename): reader = vtk.vtkXMLStructuredGridReader() reader.SetFileName(filename) reader.Update() output = reader.GetOutput() dims = output.GetDimensions() fd = output.GetFieldData() cd = output.GetCellData() pd = output.GetPointData() tp.new_layout() ds = tp.active_frame().create_dataset(name=os.path.basename(filename)) # Add the XYZ variables - a dataset needs one variable before you can add a zone ds.add_variable('x', dtypes = [FieldDataType.Float]) ds.add_variable('y', dtypes = [FieldDataType.Float]) ds.add_variable('z', dtypes = [FieldDataType.Float]) zone_name = os.path.basename(filename) zone = ds.add_ordered_zone(zone_name, dims) # Not sure how to get solution time from VTS files yet #solution_time = float(filename.split('_')[-1].split('.')[0]) #strand = 1 #zone.solution_time = solution_time #zone.strand = strand # Write XYZ values xyz_points = get_points(output) zone.values(0)[:] = xyz_points[0] zone.values(1)[:] = xyz_points[1] zone.values(2)[:] = xyz_points[2] add_point_data(pd, zone) return ds
def load_data(self, *a): with tp.session.suspend(): tp.new_layout() # Load the Mach 0.1 Dataset and capture the associated zones self.dataset = tp.data.load_tecplot("mach_0.1.plt") self.ds1 = list(self.dataset.zones()) for z in self.ds1: z.solution_time = 0.1 # Load the Mach 0.2 Dataset and capture the associated zones tp.data.load_tecplot("mach_0.2.plt") self.ds2 = list(self.dataset.zones())[len(self.ds1):] for z in self.ds2: z.solution_time = 0.2 # Create a 'result' set of zones and capture the associated zones self.ds_result = self.dataset.copy_zones(self.ds1) for z in self.ds_result: z.solution_time = 0 # Set up some default style plot = tp.active_frame().plot(PlotType.Cartesian3D) plot.activate() plot.show_contour = True plot.contour(0).levels.reset_levels( [-1500, -1200, -900, -600, -300, 0, 300, 600, 900, 1200, 1500]) plot.contour(0).colormap_name = 'Diverging - Blue/Red' plot.contour( 0 ).colormap_filter.distribution = ColorMapDistribution.Continuous plot.contour(0).colormap_filter.continuous_min = -1500 plot.contour(0).colormap_filter.continuous_max = 1500 plot.view.rotate_to_angles(115, 115, -80) plot.view.position = (-65, 33.5, -35.4) plot.view.width = 6
def main(shapefilename, outfilename): # define index from record for zone name s = sf.Reader(shapefilename) shape_records = s.shapeRecords() conversion_option = get_conversion_option(shape_records) if get_var_names() == 0: x_var_name = 'x' y_var_name = 'y' else: x_var_name = 'lon' y_var_name = 'lat' dataset = tp.active_frame().create_dataset("Shapefile", [x_var_name, y_var_name]) if conversion_option == 1: # Single Zone start = time.time() convert_to_single_zone(s, os.path.basename(shapefilename), dataset) else: # One Zone per Shape name_index = get_name_index(s) start = time.time() convert_to_one_zone_per_shape(s, name_index, dataset) tp.data.save_tecplot_plt(outfilename) print("Elapsed time: ", time.time() - start)
from os import path import tecplot as tp from tecplot.constant import LinePattern, Color examples_dir = tp.session.tecplot_examples_directory() datafile = path.join(examples_dir, 'SimpleData', 'Sphere.lpk') dataset = tp.load_layout(datafile) plot = tp.active_frame().plot() plot.axes.grid_area.fill_color = Color.Grey for axis in (plot.axes.x_axis, plot.axes.y_axis): axis.show = True #{DOC:highlight}[ grid_lines = axis.grid_lines grid_lines.show = True grid_lines.line_pattern = LinePattern.LongDash grid_lines.color = Color.Cyan #] plot.view.fit() tp.export.save_png('grid_lines.png', 600, supersample=3)
from os import path import tecplot as tp from tecplot.constant import PlotType, LinePattern, Color examples_dir = tp.session.tecplot_examples_directory() datafile = path.join(examples_dir, 'SimpleData', 'RainierElevation.plt') dataset = tp.data.load_tecplot(datafile) plot = tp.active_frame().plot(PlotType.Cartesian2D) plot.activate() plot.show_contour = True plot.contour(0).colormap_name = 'Elevation - Above Ground Level' xaxis = plot.axes.x_axis plot.axes.preserve_scale = True xaxis.max = xaxis.variable.values(0).max() #{DOC:highlight}[ grid = plot.axes.precise_grid grid.show = True grid.size = 0.05 #] # ensure consistent output between interactive (connected) and batch plot.contour(0).levels.reset_to_nice() tp.export.save_png('precise_grid.png', 600, supersample=3)
parser.add_argument("-supersample", help="Supersample factor to use for image export", type=int, default=2) parser.add_argument("-imagebasename", help="Basename for exported PNG images", default="image") args = parser.parse_args() # Get the solution times over which to iterate. Stop PyTecplot in # the main process to free up the license for the workers. PyTecplot # cannot be restarted once stopped! tp.new_layout() tp.load_layout(args.layoutfile) solution_times = tp.active_frame().dataset.solution_times tp.session.stop() # !!! IMPORTANT !!! # On Linux systems, Python's multiprocessing start method # defaults to "fork" which is incompatible with PyTecplot # and must be set to "spawn" multiprocessing.set_start_method('spawn') # Set up the pool with initializing function and associated arguments pool = multiprocessing.Pool(processes=args.numprocs, initializer=initialize_process, initargs=(args.layoutfile, )) try: job_args = []
def save_image(args): solution_time, width, supersample, image_file = args tp.active_frame().plot().solution_time = solution_time tp.export.save_png(image_file, width=width, supersample=supersample) return image_file