servermanager Module¶
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. It creates an AnimationScene and add a new TimeAnimationCue in it.
When running from the GUI and python shell, prefer using the existing scene and cue to maintain time consistency in the application.
- class 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.
- class 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.
- property Available¶
This read-only property contains the list of items that can be read by a reader.
- class 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:
When called with no hosts, it creates a new session to the built-in server on the client itself.
When called with ds_host and ds_port arguments, it attempts to connect to a server(data and render server on the same server) on the indicated host:port.
When called with ds_host, ds_port, rs_host, rs_port, it creates a new connection to the data server on ds_host:ds_port and to the render server on rs_host: rs_port.
All these connection types support a timeout argument in second. Default is 60. 0 means no retry, -1 means infinite retries.
- paraview.servermanager.ConnectToCatalyst(ds_host='localhost', ds_port=22222)[source]¶
Use this function to create a new catalyst session.
- class 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
- class paraview.servermanager.ConnectionProxyNamespaces(session)[source]¶
Bases:
object
This class stores class types for all known proxies on a particular session. The classes are maintained in separate namespaces accessible as read-only properties on an instance of this class.
- property animation¶
animation proxies
- property extended_sources¶
extented sources
- property filters¶
filter proxies
- getClass(smproxy)[source]¶
Given a vtkSMProxy returns a Proxy class subclass type appropriate for the proxy. This will atttempt to reuse the class type is already seen, otherwise a new one will be created.
- property implicit_functions¶
implicit function proxies
- property misc¶
miscellaneous proxies
- property piecewise_functions¶
piece-wise functions
- property rendering¶
rendering proxies
- property sources¶
source proxies
- property writers¶
writers proxies
- 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.
- class 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.
- paraview.servermanager.Disconnect(connection=None)[source]¶
Disconnects the connection. Make sure to clear the proxy manager first.
- class paraview.servermanager.DoubleMapProperty(proxy, smproperty)[source]¶
Bases:
paraview.servermanager.Property
A DoubleMapProperty provides access to a map of double vector values.
- class paraview.servermanager.EnumerationProperty(proxy, smproperty)[source]¶
Bases:
paraview.servermanager.VectorProperty
Subclass of VectorProperty that is applicable for enumeration type properties.
- property Available¶
This read-only property contains the list of values that can be applied to this property.
- class 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.
- class 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.
- property NumberOfArrays¶
Returns the number of arrays.
- class paraview.servermanager.FieldDataInformationIterator(info, items=False)[source]¶
Bases:
object
Iterator for FieldDataInformation
- class 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.
- class 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.
- class 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.
remote=True has no effect when the connection is not remote.
- paraview.servermanager.LoadState(filename, connection=None, location=16)[source]¶
Given a state filename and an optional connection, loads the server manager state.
- class paraview.servermanager.ParaViewLoader[source]¶
Bases:
importlib.abc.InspectLoader
- class 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.
- class 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.
- property Name¶
Returns the name for the property
- class 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.
- class 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
andProxyProperty
documentation for details.Please note that some of the methods accessible through the Proxy class are not listed by
help()
because theProxy
objects forward unresolved attributes to the underlying object. To get the full list, see alsodir(proxy.SMProxy)
. See also the doxygen based documentation of thevtkSMProxy
C++ class.- GetPropertyValue(name)[source]¶
Returns a scalar for properties with 1 elements, the property itself for vectors.
- class 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__()’
- class 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.
- class 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()
- class paraview.servermanager.ProxyNamespace(xmlGroups, session)[source]¶
Bases:
object
This class is a container for class types representing known proxies types. Conceptually, one can think of this a Python equivalent for a proxy group, however, due to legacy reasons, it can represent proxies in more than one proxy-group.
Class types are created on demand. All known proxies types can be determined using dir() call on this instance. This avoids having to define classes for all proxy types during initialization, thus speeding up initialization.
- class 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.
- property 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.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, location=16)[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.
- class 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’].
- property CellData¶
Returns cell data information
- property FieldData¶
Returns field data information
- GetDataInformation(idx=None)[source]¶
This method returns a DataInformation wrapper around a vtkPVDataInformation
- property PointData¶
Returns point data information
- class 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.
- property Available¶
This read-only property contains the list of values that can be applied to this property.
- paraview.servermanager.ToggleProgressPrinting()[source]¶
Turn on/off printing of progress. See SetProgressPrintingEnabled.
- class 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)
- class 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.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).