servermanager is a module for using paraview server manager in Python. One can always use the server manager API directly. However, this module provides an interface easier to use from Python by wrapping several VTK classes around Python classes.
Note that, upon load, this module will create several sub-modules: sources, filters and rendering. These modules can be used to instantiate specific proxy types. For a list, try “dir(servermanager.sources)”
Usually users should use the paraview.simple module instead as it provide a more user friendly API.
A simple example:
from paraview.servermanager import *
# Creates a new built-in session and makes it the active session.
Connect()
# Creates a new render view on the active session.
renModule = CreateRenderView()
# Create a new sphere proxy on the active session and register it
# in the sources group.
sphere = sources.SphereSource(registrationGroup="sources", ThetaResolution=16, PhiResolution=32)
# Create a representation for the sphere proxy and adds it to the render
# module.
display = CreateRepresentation(sphere, renModule)
renModule.StillRender()
paraview.servermanager.
ActiveConnection
= Connection (builtin:) [1]¶Keeps track of all connection objects. Unless the process was run with –multi-servers flag set to True, this will generally be just 1 item long at the most.
paraview.servermanager.
AnimateReader
(reader, view)[source]¶This is a utility function that, given a reader and a view animates over all time steps of the reader.
paraview.servermanager.
ArrayInformation
(proxy, field, name)[source]¶Bases: object
Meta-information associated with an array. Use the Name attribute to get the array name.
Please note that some of the methods accessible through the ArrayInformation class are not listed by help() because the ArrayInformation objects forward unresolved attributes to the underlying object. See the doxygen based documentation of the vtkPVArrayInformation C++ class for a full list.
paraview.servermanager.
ArrayListProperty
(proxy, smproperty)[source]¶Bases: paraview.servermanager.VectorProperty
This property provides a simpler interface for selecting arrays. Simply assign a list of arrays that should be loaded by the reader. Use the Available property to get a list of available arrays.
Available
¶This read-only property contains the list of items that can be read by a reader.
paraview.servermanager.
ArraySelectionProperty
(proxy, smproperty)[source]¶Bases: paraview.servermanager.VectorProperty
Property to select an array to be processed by a filter.
paraview.servermanager.
Connect
(ds_host=None, ds_port=11111, rs_host=None, rs_port=22221, timeout=60)[source]¶Use this function call to create a new session. On success, it returns a vtkSMSession object that abstracts the connection. Otherwise, it returns None.
There are several ways in which this function can be called:
paraview.servermanager.
Connection
(connectionId, session)[source]¶Bases: object
This is a python representation for a session/connection.
GetNumberOfDataPartitions
()[source]¶Returns the number of partitions on the data server for this connection
paraview.servermanager.
CreateProxy
(xml_group, xml_name, session=None)[source]¶Creates a proxy. If session is set, the proxy’s session is set accordingly. If session is None, the current Session is used, if present. You should not have to use method normally. Instantiate the appropriate class from the appropriate module, for example: sph = servermanager.sources.SphereSource()
paraview.servermanager.
CreateRenderView
(session=None, **extraArgs)[source]¶Creates a render window on the particular session. If session is not specified, then the active session is used, if available.
This method can also be used to initialize properties by passing keyword arguments where the key is the name of the property. In addition registrationGroup and registrationName (optional) can be specified (as keyword arguments) to automatically register the proxy with the proxy manager.
paraview.servermanager.
CreateRepresentation
(aProxy, view, **extraArgs)[source]¶Creates a representation for the proxy and adds it to the render module.
This method can also be used to initialize properties by passing keyword arguments where the key is the name of the property.In addition registrationGroup and registrationName (optional) can be specified (as keyword arguments) to automatically register the proxy with the proxy manager.
This method tries to create the best possible representation for the given proxy in the given view. Additionally, the user can specify proxyName (optional) to create a representation of a particular type.
paraview.servermanager.
DataInformation
(dataInformation, proxy, idx)[source]¶Bases: object
DataInformation is a contained for meta-data associated with an output data.
DataInformation is a python wrapper around a vtkPVDataInformation. In addition to proving all methods of a vtkPVDataInformation, it provides a few convenience methods.
Please note that some of the methods accessible through the DataInformation class are not listed by help() because the DataInformation objects forward unresolved attributes to the underlying object. To get the full list, see also dir(proxy.DataInformation). See also the doxygen based documentation of the vtkPVDataInformation C++ class.
GetDataSetTypeAsString
()[source]¶Returns the dataset type as a user-friendly string. This is not the same as the enumaration used by VTK
Update
()[source]¶**Deprecated** There is no reason anymore to use this method explicitly, it is called automatically when one gets any value from the data information object. Update the data information if necessary. Note that this does not cause execution of the underlying object. In certain cases, you may have to call UpdatePipeline() on the proxy.
paraview.servermanager.
Disconnect
(connection=None)[source]¶Disconnects the connection. Make sure to clear the proxy manager first.
paraview.servermanager.
DoubleMapProperty
(proxy, smproperty)[source]¶Bases: paraview.servermanager.Property
A DoubleMapProperty provides access to a map of double vector values.
paraview.servermanager.
EnumerationProperty
(proxy, smproperty)[source]¶Bases: paraview.servermanager.VectorProperty
Subclass of VectorProperty that is applicable for enumeration type properties.
Available
¶This read-only property contains the list of values that can be applied to this property.
paraview.servermanager.
ExodusIIReaderProxy
(**args)[source]¶Bases: paraview.servermanager.SourceProxy
Special class to define convenience functions for array selection.
paraview.servermanager.
Fetch
(input, arg1=None, arg2=None, idx=0)[source]¶A convenience method that moves data from the server to the client, optionally performing some operation on the data as it moves. The input argument is the name of the (proxy for a) source or filter whose output is needed on the client.
You can use Fetch to do three things:
If arg1 is None (the default) then all of the data is brought to the client. In parallel runs an appropriate append Filter merges the data on each processor into one data object. The filter chosen will be vtkAppendPolyData for vtkPolyData, vtkAppendRectilinearGrid for vtkRectilinearGrid, vtkMultiBlockDataGroupFilter for vtkCompositeData, and vtkAppendFilter for anything else.
If arg1 is an integer then one particular processor’s output is brought to the client. In serial runs the arg is ignored. If you have a filter that computes results in parallel and brings them to the root node, then set arg to be 0.
If arg1 and arg2 are a algorithms, for example vtkMinMax, the algorithm will be applied to the data to obtain some result. Here arg1 will be applied pre-gather and arg2 will be applied post-gather. In parallel runs the algorithm will be run on each processor to make intermediate results and then again on the root processor over all of the intermediate results to create a global result.
Optional argument idx is used to specify the output port number to fetch the data from. Default is port 0.
paraview.servermanager.
FieldDataInformation
(proxy, idx, field)[source]¶Bases: object
Meta-data for a field of an output object (point data, cell data etc…). Provides easy access to the arrays using the slice interface: > narrays = len(field_info) > for i in range(narrays): > array_info = field_info[i]
Full slice interface is supported: > arrays = field_info[0:5:3] where arrays is a list.
Array access by name is also possible: > array_info = field_info[‘Temperature’]
The number of arrays can also be accessed using the NumberOfArrays property.
GetArray
(idx)[source]¶Given an index or a string, returns an array information. Raises IndexError if the index is out of bounds.
NumberOfArrays
¶Returns the number of arrays.
paraview.servermanager.
FieldDataInformationIterator
(info, items=False)[source]¶Bases: object
Iterator for FieldDataInformation
paraview.servermanager.
FileNameProperty
(proxy, smproperty)[source]¶Bases: paraview.servermanager.VectorProperty
Property to set/get one or more file names. This property updates the pipeline information everytime its value changes. This is used to keep the array lists up to date.
paraview.servermanager.
Finalize
()[source]¶Although not required, this can be called at exit to cleanup.
paraview.servermanager.
GenericIterator
(obj)[source]¶Bases: object
Iterator for container type objects
paraview.servermanager.
GetAssociationAsString
(val)[source]¶Returns array association string from its integer value
paraview.servermanager.
GetAssociationFromString
(val)[source]¶Returns array association integer value from its string representation
paraview.servermanager.
GetConnectionFromId
(id)[source]¶Returns the Connection object corresponding a connection identified by the id.
paraview.servermanager.
GetConnectionFromSession
(session)[source]¶Returns the Connection object corresponding to a vtkSMSession instance.
paraview.servermanager.
GetContextViews
(connection=None)[source]¶Returns the set of all context views.
paraview.servermanager.
GetRenderView
(connection=None)[source]¶Return the render view in use. If more than one render view is in use, return the first one.
paraview.servermanager.
GetRenderViews
(connection=None)[source]¶Returns the set of all render views.
paraview.servermanager.
InputProperty
(proxy, smproperty)[source]¶Bases: paraview.servermanager.ProxyProperty
An InputProperty allows making pipeline connections. You can set either a source proxy or an OutputProperty to an input property:
> property[0] = proxy or > property[0] = OuputPort(proxy, 1)
> property.append(proxy) or > property.append(OutputPort(proxy, 0))
GetData
()[source]¶Returns all elements as either a list of OutputPort objects or a single OutputPort object.
paraview.servermanager.
LoadPlugin
(filename, remote=True, connection=None)[source]¶Given a filename and a session (optional, otherwise uses ActiveConnection), loads a plugin. It then updates the sources, filters and rendering modules.
paraview.servermanager.
LoadState
(filename, connection=None)[source]¶Given a state filename and an optional connection, loads the server manager state.
paraview.servermanager.
LoadXML
(xmlstring)[source]¶DEPRECATED. Given a server manager XML as a string, parse and process it.
paraview.servermanager.
MissingProxy
[source]¶Bases: Exception
Exception fired when the requested proxy is missing.
paraview.servermanager.
MissingRegistrationInformation
[source]¶Bases: Exception
Exception for missing registration information. Raised when a name or group is not specified or when a group cannot be deduced.
paraview.servermanager.
ParaViewLoader
[source]¶Bases: importlib.abc.InspectLoader
paraview.servermanager.
ParaViewPipelineController
[source]¶Bases: object
ParaViewPipelineController wraps vtkSMParaViewPipelineController class to manage conversion of arguments passed around from Python Proxy objects to vtkSMProxy instances are vice-versa.
paraview.servermanager.
Property
(proxy, smproperty)[source]¶Bases: object
Generic property object that provides access to one of the properties of a server object. This class does not allow setting/getting any values but provides an interface to update a property using __call__. This can be used for command properties that correspond to function calls without arguments. For example, > proxy.Foo() would push a Foo property which may cause the proxy to call a Foo method on the actual VTK object.
For advanced users: Python wrapper around a vtkSMProperty with a simple interface. In addition to all method provided by vtkSMProperty (obtained by forwarding unknown attributes requests to the underlying SMProxy), Property and sub-class provide a list API.
Please note that some of the methods accessible through the Property class are not listed by help() because the Property objects forward unresolved attributes to the underlying object. To get the full list, see also dir(proxy.SMProperty). See also the doxygen based documentation of the vtkSMProperty C++ class.
Name
¶Returns the name for the property
paraview.servermanager.
PropertyIterator
(aProxy)[source]¶Bases: object
Wrapper for a vtkSMPropertyIterator class to satisfy the python iterator protocol. Note that the list of properties can also be obtained from the class object’s dictionary. See the doxygen documentation for vtkSMPropertyIterator C++ class for details.
paraview.servermanager.
Proxy
(**args)[source]¶Bases: object
one or more server manager objects. It also provides an interface to set and get the properties of the server side objects. These properties are presented as Python properties. For example, you can set a property Foo using the following:
proxy.Foo = (1,2)
or:
proxy.Foo.SetData((1,2))
or:
proxy.Foo[0:2] = (1,2)
For more information, see the documentation of the property which you can obtain with:
help(proxy.Foo).
This class also provides an iterator which can be used to iterate over all properties, e.g.:
proxy = Proxy(proxy=smproxy)
for property in proxy:
print (property)
For advanced users: This is a python class that wraps a vtkSMProxy. Makes it easier to set/get properties. Instead of:
proxy.GetProperty("Foo").SetElement(0, 1)
proxy.GetProperty("Foo").SetElement(0, 2)
you can do:
proxy.Foo = (1,2)
or:
proxy.Foo.SetData((1,2))
or:
proxy.Foo[0:2] = (1,2)
Instead of:
proxy.GetProperty("Foo").GetElement(0)
you can do:
proxy.Foo.GetData()[0]
or:
proxy.Foo[0]
For proxy properties, you can use append:
proxy.GetProperty("Bar").AddProxy(foo)
you can do:
proxy.Bar.append(foo)
Properties support most of the list API. See VectorProperty
and
ProxyProperty
documentation for details.
Please note that some of the methods accessible through the Proxy
class are not listed by help()
because the Proxy
objects forward
unresolved attributes to the underlying object. To get the full list,
see also dir(proxy.SMProxy)
. See also the doxygen based documentation
of the vtkSMProxy
C++ class.
GetPropertyValue
(name)[source]¶Returns a scalar for properties with 1 elements, the property itself for vectors.
paraview.servermanager.
ProxyDefinitionIterator
(iter)[source]¶Bases: object
Wrapper for a vtkPVProxyDefinitionIterator class to satisfy the python iterator protocol. See the doxygen documentation of the vtkPVProxyDefinitionIterator C++ class for more information.
GetGroup
()[source]¶Returns the group for the proxy definition last returned by the call to ‘next()’
paraview.servermanager.
ProxyIterator
[source]¶Bases: object
Wrapper for a vtkSMProxyIterator class to satisfy the python iterator protocol. See the doxygen documentation of vtkSMProxyIterator C++ class for more information.
paraview.servermanager.
ProxyManager
(session=None)[source]¶Bases: object
When running scripts from the python shell in the ParaView application, registering proxies with the proxy manager is the only mechanism to notify the graphical user interface (GUI) that a proxy exists. Therefore, unless a proxy is registered, it will not show up in the user interface. Also, the proxy manager is the only way to get access to proxies created using the GUI. Proxies created using the GUI are automatically registered under an appropriate group (sources, filters, representations and views). To get access to these objects, you can use proxyManager.GetProxy(group, name). The name is the same as the name shown in the pipeline browser.
This class is a python wrapper for vtkSMProxyManager. Note that the underlying vtkSMProxyManager is a singleton. All instances of this class will refer to the same object. In addition to all methods provided by vtkSMProxyManager (all unknown attribute requests are forwarded to the vtkSMProxyManager), this class provides several convenience methods.
Please note that some of the methods accessible through the ProxyManager class are not listed by help() because the ProxyManager objects forwards unresolved attributes to the underlying object. To get the full list, see also dir(proxy.SMProxyManager). See also the doxygen based documentation of the vtkSMProxyManager C++ class.
GetPrototypeProxy
(group, name)[source]¶Returns a prototype proxy given a group and name. This is an SMProxy. This is a low-level method. You should not normally have to call it.
GetProxies
(groupname, proxyname)[source]¶Returns all proxies registered under the given group with the given name. Note that it is possible to register more than one proxy with the same name in the same group. Because the proxies are different, there is no conflict. Use this method instead of GetProxy() if you know that there are more than one proxy registered with this name.
NewDefinitionIterator
(groupname=None)[source]¶Returns an iterator that can be used to iterate over all groups and types of proxies that the proxy manager can create.
NewGroupIterator
(group_name)[source]¶Returns a ProxyIterator for a group. The resulting object can be used to traverse the proxies that are in the given group.
NewProxy
(group, name)[source]¶Creates a new proxy of given group and name and returns an SMProxy. Note that this is a server manager object. You should normally create proxies using the class objects. For example: obj = servermanager.sources.SphereSource()
paraview.servermanager.
ProxyProperty
(proxy, smproperty)[source]¶Bases: paraview.servermanager.Property
A ProxyProperty provides access to one or more proxies. You can use a slice to get one or more property values: > proxy = property[2] or > proxies = property[0:5:2] You can use a slice to set one or more property values: > property[2] = proxy or > property[1:3] = (proxy1, proxy2) You can also append and delete: > property.append(proxy) and > del property[1:2]
You can also remove all elements with Clear().
Note that some properties expect only 1 proxy and will complain if you set the number of values to be something else.
Available
¶This read only property is a list of strings you can use to select from the list domain. If there is no such list domain, the array is empty.
GetAvailable
()[source]¶If this proxy has a list domain, then this function returns the strings you can use to select from the domain. If there is no such list domain, the returned list is empty.
paraview.servermanager.
Register
(proxy, **extraArgs)[source]¶Registers a proxy with the proxy manager. If no ‘registrationGroup’ is specified, then the group is inferred from the type of the proxy. ‘registrationName’ may be specified to register with a particular name otherwise a default name will be created.
paraview.servermanager.
ResetSession
()[source]¶Reset the session in the active connection to its initial state.
paraview.servermanager.
ReverseConnect
(port=11111)[source]¶Use this function call to create a new session. On success, it returns a Session object that abstracts the connection. Otherwise, it returns None. In reverse connection mode, the client waits for a connection from the server (client has to be started first). The server then connects to the client (run pvserver with -rc and -ch option). The optional port specified the port to listen to.
paraview.servermanager.
SaveState
(filename)[source]¶Given a state filename, saves the state of objects registered with the proxy manager.
paraview.servermanager.
SetActiveConnection
(connection=None)[source]¶Set the active connection. If the process was run without multi-server enabled and this method is called with a non-None argument while an ActiveConnection is present, it will raise a RuntimeError.
paraview.servermanager.
SetProgressPrintingEnabled
(value)[source]¶Turn on/off printing of progress (by default, it is on). You can always turn progress off and add your own observer to the process module to handle progress in a custom way. See _printProgress for an example event observer.
paraview.servermanager.
SourceProxy
(**args)[source]¶Bases: paraview.servermanager.Proxy
Proxy for a source object. This class adds a few methods to Proxy that are specific to sources. It also provides access to the output ports. Output ports can be accessed by name or index: > op = source[0] or > op = source[‘some name’].
CellData
¶Returns cell data information
FieldData
¶Returns field data information
GetDataInformation
(idx=None)[source]¶This method returns a DataInformation wrapper around a vtkPVDataInformation
PointData
¶Returns point data information
paraview.servermanager.
StringListProperty
(proxy, smproperty)[source]¶Bases: paraview.servermanager.VectorProperty
Property to set/get the a string with a string list domain. This property provides an interface to get available strings.
Available
¶This read-only property contains the list of values that can be applied to this property.
paraview.servermanager.
SubsetInclusionLatticeProperty
(proxy, smproperty)[source]¶Bases: paraview.servermanager.ArrayListProperty
This property provides a simpler interface for selecting blocks on a property with a vtkSMSubsetInclusionLatticeDomain.
paraview.servermanager.
ToggleProgressPrinting
()[source]¶Turn on/off printing of progress. See SetProgressPrintingEnabled.
paraview.servermanager.
UnRegister
(proxy, **extraArgs)[source]¶UnRegisters proxies registered using Register().
paraview.servermanager.
VectorProperty
(proxy, smproperty)[source]¶Bases: paraview.servermanager.Property
A VectorProperty provides access to one or more values. You can use a slice to get one or more property values: > val = property[2] or > vals = property[0:5:2] You can use a slice to set one or more property values: > property[2] = val or > property[1:3] = (1,2)
paraview.servermanager.
ViewLayoutProxy
(**args)[source]¶Bases: paraview.servermanager.Proxy
Special class to define convenience methods for View Layout
AssignView
(location, view)[source]¶Assign a view at a particular location. Note that the view’s position may be changed by subsequent Split() calls. Returns true on success.
SplitViewHorizontal
(view, fraction=0.5)[source]¶Split the cell containing the specified view horizontally. If no fraction is specified, the frame is split into equal parts. On success returns a positive number that identifying the new cell location that can be used to assign view to, or split further. Return -1 on failure.
SplitViewVertical
(view=None, fraction=0.5)[source]¶Split the cell containing the specified view horizontally. If no view is specified, active view is used. If no fraction is specified, the frame is split into equal parts. On success returns a positive number that identifying the new cell location that can be used to assign view to, or split further. Return -1 on failure.
paraview.servermanager.
createModule
(groupName, mdl=None)[source]¶Populates a module with proxy classes defined in the given group. If mdl is not specified, it also creates the module
paraview.servermanager.
demo1
()[source]¶This simple demonstration creates a sphere, renders it and delivers it to the client using Fetch. It returns a tuple of (data, render view)
paraview.servermanager.
demo2
(fname='/Users/berk/Work/ParaViewData/Data/disk_out_ref.ex2')[source]¶This method demonstrates the user of a reader, representation and view. It also demonstrates how meta-data can be obtained using proxies. Make sure to pass the full path to an exodus file. Also note that certain parameters are hard-coded for disk_out_ref.ex2 which can be found in ParaViewData. This method returns the render view.
paraview.servermanager.
demo3
()[source]¶This method demonstrates the use of servermanager with numpy as well as pylab for plotting. It creates an artificial data sources, probes it with a line, delivers the result to the client using Fetch and plots it using pylab. This demo requires numpy and pylab installed. It returns a tuple of (data, render view).