simple.io Module

paraview.simple.io.CreateWriter(filename, proxy=None, **extraArgs)[source]

Creates a writer that can write the data produced by the source proxy in the given file format (identified by the extension). This function doesn’t actually write the data, it simply creates the writer and returns it

Parameters:
  • filename (str) – The name of the output data file.

  • proxy (Source proxy.) – Source proxy whose output should be written. Optional, defaults to the creating a writer for the active source.

  • extraArgs (A variadic list of key=value pairs giving values of specific named properties in the writer.) – Additional arguments that should be passed to the writer proxy.

paraview.simple.io.ExtendFileSeries(proxy=None)[source]

For a reader proxy that supports reading files series, detect any new files added to the series and update the reader’s filename property.

Parameters:

proxy – Reader proxy that should check for a extended file series. Optional, defaults to extending file series in the active source.

Returns:

True if the operation succeeded, False otherwise

Return type:

bool

paraview.simple.io.FetchData(proxy=None, **kwargs)[source]

Fetches data from the specified data producer for processing locally. Use this function with caution since this can cause large amounts of data to be gathered and delivered to the client.

If no producer is specified, the active source is used.

Basic Usage

#to fetch data from port 0

dataMap = FetchData(producer)

# to fetch data from a specific port

dataMap = FetchData(OutputPort(producer, 1))

FetchData() does not explicitly update the pipeline. It is expected that the pipeline is already updated. This will simply deliver the current data.

Returns a map where the key is an integer representing a rank and value is the dataset fetched from that rank.

Keyword Parameters

The following keyword parameters can be used to customize the fetchs.

GatherOnAllRanks (bool/int, optional):

This is used only in symmetric batch (or ParaView-Catalyst) mode. If True, then FetchData() will gather the data on all ranks. Default is to only gather the data on the root node.

SourceRanks (list(int), optional):

List of ints to specity explicitly the ranks from which to fetch data. By default, data from all ranks is fetched.

paraview.simple.io.GetNumberOfCallbackThreads(n)[source]

Gets the number of threads used by the threaded callback queue that can be used for saving screenshots.

Parameters:

n (int) – Not used

paraview.simple.io.GetNumberOfSMPThreads(n)[source]
paraview.simple.io.LoadState(statefile, data_directory=None, restrict_to_data_directory=False, filenames=None, location=16, *args, **kwargs)[source]

Load PVSM state file.

This will load the state specified in the statefile.

ParaView can update absolute paths for data files used in the state which can be useful to portably load state file across different systems.

Alternatively, filenames can be used to specify a list of filenames explicitly. This must be list of the following form:

[
    {
        // either 'name' or 'id' are required. if both are provided, 'id'
        // is checked first.
        "name" : "[reader name shown in pipeline browser]",
        "id"   : "[reader id used in the pvsm state file]",

        // all modified filename-like properties on this reader
        "FileName" : "..."
        // ...
    }

    // ...
]

Calling this function with other positional or keyword arguments will invoke the legacy signature of this function _LoadStateLegacy.

Parameters:
  • statefile (str) – Path to the statefile to load

  • data_directory (str) – If not None, then ParaView searches for files matching those used in the state under the specified directory and if found, replaces the state to use the found files instead. Optional, defaults to None.

  • restrict_to_data_directory (bool) – If set to True, if a file is not found under the data_directory, it will raise an error, otherwise it is left unchanged. Optional, defaults to False.

  • filenames (str) – JSON-formatted string to specify a list of filenames.

  • location (vtkPVServer.ServerFlags enum value) – Where the statefile is located, e.g., pass vtkPVSession.CLIENT if the statefile is located on the client system (default value), pass in vtkPVSession.SERVERS if on the server. Optional, defaults to client.

paraview.simple.io.OpenDataFile(filename, **extraArgs)[source]

Creates a reader to read the give file, if possible. This uses extension matching to determine the best reader possible.

Returns:

Returns a suitable reader if found. If a reader cannot be identified, then this returns None.

Return type:

Reader proxy, or None

paraview.simple.io.ReloadFiles(proxy=None)[source]

Forces a reader proxy to reload the data files.

Parameters:

proxy (Reader proxy) – Reader proxy whose files should be reloaded. Optional, defaults to reloading files in the active source.

Returns:

Returns True if files reloaded successfully, False otherwise

Return type:

bool

paraview.simple.io.ReplaceReaderFileName(readerProxy, files, propName)[source]

Replaces the readerProxy by a new one given a list of files.

Parameters:
  • readerProxy (Reader proxy.) – Reader proxy whose filename should be updated.

  • files (list of str) – List of file names to be read by the reader.

  • propName (str) – should be “FileNames” or “FileName” depending on the property name in the reader.

paraview.simple.io.SaveAnimation(filename, viewOrLayout=None, scene=None, location=16, **params)[source]

Save animation as a movie file or series of images.

SaveAnimation is used to save an animation as a movie file (avi, mp4, or ogv) or a series of images.

Parameters:
  • filename (str) – Name of the output file. The extension is used to determine the type of the output. Supported extensions are png, jpg, tif, bmp, and ppm. Based on platform (and build) configuration, avi, mp4, and ogv may be supported as well.

  • viewOrLayout (View or layout proxy.) – The view or layout to save image from, defaults to None. If None, then the active view is used, if available. To save an image from a single view, this must be set to a view, to save an image from all views in a layout, pass the layout.

  • scene (Animation scene proxy) – Animation scene to save. If not provided, then the active scene returned by GetAnimationScene is used.

  • location (vtkPVSession.ServerFlags enum) – Location where the screenshot should be saved. This can be one of the following values: vtkPVSession.CLIENT, vtkPVSession.DATA_SERVER. The default is vtkPVSession.CLIENT.

Keyword Parameters (optional)

SaveAnimation supports all keyword parameters supported by SaveScreenshot. In addition, the following parameters are supported:

FrameRate (int):

Frame rate in frames per second for the output. This only affects the output when generated movies (avi or ogv), and not when saving the animation out as a series of images.

FrameWindow (tuple(int,int))

To save a part of the animation, provide the range in frames or timesteps index.

In addition, several format-specific keyword parameters can be specified. The format is chosen based on the file extension.

For Image-based file-formats that save series of images e.g. PNG, JPEG, following parameters are available.

SuffixFormat (string):

Format string used to convert the frame number to file name suffix.

FFMPEG avi file format supports following parameters.

Compression (int)

Set to 1 or True to enable compression.

Quality:

When compression is 1 (or True), this specifies the compression quality. 0 is worst quality (smallest file size) and 2 is best quality (largest file size).

VideoForWindows (VFW) avi file format supports following parameters.

Quality:

This specifies the compression quality. 0 is worst quality (smallest file size) and 2 is best quality (largest file size).

OGG/Theora file format supports following parameters.

Quality:

This specifies the compression quality. 0 is worst quality (smallest file size) and 2 is best quality (largest file size).

UseSubsampling:

When set to 1 (or True), the video will be encoded using 4:2:0 subsampling for the color channels.

paraview.simple.io.SaveData(filename, proxy=None, **extraArgs)[source]

Save data produced by the proxy parameter into a file.

Properties to configure the writer can be passed in as keyword arguments. Example usage:

SaveData("sample.pvtp", source0)
SaveData("sample.csv", FieldAssociation="Points")
Parameters:
  • filenam – Path where output file should be saved.

  • proxy (Source proxy.) – Proxy to save. Optional, defaults to saving the active source.

  • extraArgs – A variadic list of key=value pairs giving values of specific named properties in the writer.

paraview.simple.io.SaveScreenshot(filename, viewOrLayout=None, saveInBackground=False, location=16, **params)[source]

Save screenshot for a view or layout (collection of views) to an image.

SaveScreenshot is used to save the rendering results to an image.

Parameters:
  • filename (str) – Name of the image file to save to. The filename extension is used to determine the type of image file generated. Supported extensions are png, jpg, tif, bmp, and ppm.

  • viewOrLayout (View or layout proxy. Optional.) – The view or layout to save image from, defaults to None. If None, then the active view is used, if available. To save image from a single view, this must be set to a view, to save an image from all views in a layout, pass the layout.

  • saveInBackground (bool) – If set to True, the screenshot will be saved by a different thread and run in the background. In such circumstances, one can wait until the file is written by calling WaitForScreenshot(filename)().

  • location (vtkPVSession.ServerFlags enum) – Location where the screenshot should be saved. This can be one of the following values: vtkPVSession.CLIENT, vtkPVSession.DATA_SERVER. Optional, defaults to vtkPVSession.CLIENT.

Keyword Parameters (optional)

ImageResolution (tuple(int, int))

A 2-tuple to specify the output image resolution in pixels as (width, height). If not specified, the view (or layout) size is used.

FontScaling (str)

Specify whether to scale fonts proportionally (“Scale fonts proportionally”) or not (“Do not scale fonts”). Defaults to “Scale fonts proportionally”.

SeparatorWidth (int)

When saving multiple views in a layout, specify the width (in approximate pixels) for a separator between views in the generated image.

SeparatorColor (tuple(float, float, float))

Specify the color for separator between views, if applicable.

OverrideColorPalette (:obj:str, optional)

Name of the color palette to use, if any. If none specified, current color palette remains unchanged.

StereoMode (str)

Stereo mode to use, if any. Available values are “No stereo”, “Red-Blue”, “Interlaced”, “Left Eye Only”, “Right Eye Only”, “Dresden”, “Anaglyph”, “Checkerboard”, “Side-by-Side Horizontal”, and the default “No change”.

TransparentBackground (int)

Set to 1 (or True) to save an image with background set to alpha=0, if supported by the output image format.

In addition, several format-specific keyword parameters can be specified. The format is chosen based on the file extension.

For JPEG (*.jpg), the following parameters are available (optional)

Quality (int) [0, 100]

Specify the JPEG compression quality. O is low quality (maximum compression) and 100 is high quality (least compression).

Progressive (int):

Set to 1 (or True) to save progressive JPEG.

For PNG (*.png), the following parameters are available (optional)

CompressionLevel (int) [0, 9]

Specify the zlib compression level. 0 is no compression, while 9 is maximum compression.

Legacy Parameters

Prior to ParaView version 5.4, the following parameters were available and are still supported. However, they cannot be used together with other keyword parameters documented earlier.

view (proxy)

Single view to save image from.

layout (proxy)

Layout to save image from.

magnification (int)

Magnification factor to use to save the output image. The current view (or layout) size is scaled by the magnification factor provided.

quality (int)

Output image quality, a number in the range [0, 100].

paraview.simple.io.SaveState(filename, location=16)[source]

Save a ParaView statefile (.pvsm) to disk on a system provided by the location parameter.

Parameters:
  • filename (str) – Path where the state file should be saved.

  • location (vtkPVServer.ServerFlags enum value) – Where the statefile should be save, e.g., pass vtkPVSession.CLIENT if the statefile is located on the client system (default value), pass in vtkPVSession.SERVERS if on the server.

paraview.simple.io.SetNumberOfCallbackThreads(n)[source]

Sets the number of threads used by the threaded callback queue that can be used for saving screenshots.

Parameters:

n (int) – Number of callback threads.

paraview.simple.io.SetNumberOfSMPThreads(n)[source]

Sets the number of threads used by vtkSMPTools. It is used in various filters.

paraview.simple.io.WaitForScreenshot(filename=None)[source]

Pause this thread until saving a screenshot has terminated.

Parameters:

filename (str) – Path where screenshot should be saved. If no filename is provided, then this thread pauses until all screenshots have been saved.

paraview.simple.io.WriteAnimationGeometry(filename, view=None)[source]

Save the animation geometry from a specific view to a file specified. The animation geometry is written out as a PVD file.

Parameters:
  • filename (str) – The file path of the PVD file to write.

  • view (View proxy) – The view holding the geometry that should be saved. Optional, defaults to the active view if possible.