coprocessing Module

This module is designed for use in co-processing Python scripts. It provides a class, Pipeline, which is designed to be used as the base-class for Python pipeline. Additionally, this module has several other utility functions that are appropriate for co-processing.

class paraview.coprocessing.CoProcessor[source]

Bases: object

Base class for co-processing Pipelines.

paraview.cpstate Module can be used to dump out ParaView states as co-processing pipelines. Those are typically subclasses of this. The subclasses must provide an implementation for the CreatePipeline() method.

Cinema Tracks

CoProcessor maintains user-defined information for the Cinema generation in __CinemaTracks. This information includes track parameter values, data array names, etc. __CinemaTracks holds this information in the following structure:

{
  proxy_reference : {
  'ControlName' : [value_1, value_2, ..., value_n],
  'arraySelection' : ['ArrayName_1', ..., 'ArrayName_n']
  }
}

__CinemaTracks is populated when defining the co-processing pipline through paraview.cpstate. paraview.cpstate uses accessor instances to set values and array names through the RegisterCinemaTrack and AddArrayssToCinemaTrack methods of this class.

AddArraysToCinemaTrack(proxy, propertyName, arrayNames)[source]

Register user-defined target arrays by name.

CreatePipeline(datadescription)[source]

This methods must be overridden by subclasses to create the visualization pipeline.

CreateProducer(datadescription, inputname)[source]

Creates a producer proxy for the grid. This method is generally used in CreatePipeline() call to create producers.

CreateTemporalProducer(datadescription, inputname)[source]

Python access to a temporal cache object associated with a specific one simulation product. Much like CreateProducer, only this ends up with a temporal cache filter instead of a PVTrivialProducer.

DoLiveVisualization(datadescription, hostname, port)[source]

This method execute the code-stub needed to communicate with ParaView for live-visualization. Call this method only if you want to support live-visualization with your co-processing module.

EnableCinemaDTable()[source]

Enable the normally disabled cinema D table export feature

EnableLiveVisualization(enable, frequency=1)[source]

Call this method to enable live-visualization. When enabled, DoLiveVisualization() will communicate with ParaView server if possible for live visualization. Frequency specifies how often the communication happens (default is every second).

Finalize()[source]
IsInModulo(datadescription, frequencies)[source]

Return True if the given timestep in datadescription is in one of the provided frequencies or output is forced. This can be interpreted as follow:

isFM = IsInModulo(timestep-timeStepToStartOutputAt, [2,3,7])

is similar to:

isFM = (timestep-timeStepToStartOutputAt % 2 == 0) or (timestep-timeStepToStartOutputAt % 3 == 0) or (timestep-timeStepToStartOutputAt % 7 == 0)

The timeStepToStartOutputAt is the first timestep that will potentially be output.

LoadRequestedData(datadescription)[source]

Call this method in RequestDataDescription co-processing pass to mark the datadescription with information about what fields and grids are required for this pipeline for the given timestep, if any.

Default implementation uses the update-frequencies set using SetUpdateFrequencies() to determine if the current timestep needs to be processed and then requests all fields. Subclasses can override this method to provide additional customizations. If there is a Live connection that can also override the initial frequencies.

NeedToOutput(datadescription, frequency)[source]

Return True if we need to output based on the input timestep, frequency and forceOutput. Checks based __FirstTimeStepIndex, __FirstTimeStepIndex, __ForceOutputAtFirstCall and __TimeStepToStartOutputAt member variables.

ProcessExodusIIWriter(writer)[source]

Extra work for the ExodusII writer to avoid undesired warnings and print out a message on how to read the files into Ensight.

RegisterCinemaTrack(name, proxy, smproperty, valrange)[source]

Register a point of control (filter’s property) that will be varied over in a cinema export.

RegisterView(view, filename, freq, fittoscreen, magnification, width, height, cinema=None, compression=None)[source]

Register a view for image capture with extra meta-data such as magnification, size and frequency.

RegisterWriter(writer, filename, freq, paddingamount=0, **params)[source]

Registers a writer proxy. This method is generally used in CreatePipeline() to register writers. All writes created as such will write the output files appropriately in WriteData() is called. params should be empty as of ParaView 5.9 but is passed in for backwards compatibility.

RescaleDataRange(view, time)[source]

DataRange can change across time, sometime we want to rescale the color map to match to the closer actual data range.

SetDataRootDirectory(root_directory)[source]

Specify root directory for data extracts

SetImageRootDirectory(root_directory)[source]

Specify root directory for image extracts

SetInitialOutputOptions(timeStepToStartOutputAt, forceOutputAtFirstCall)[source]

Set the frequencies at which the pipeline needs to be updated. Typically, this is called by the subclass once it has determined what timesteps co-processing will be needed to be done. frequencies is a map, with key->string name of for the simulation input, and value is a list of frequencies.

SetPrintEnsightFormatString(enable)[source]

If outputting ExodusII files with the purpose of reading them into Ensight, print a message on process 0 on what to use for the ‘Set string’ input to properly read the generated files into Ensight.

SetRequestedArrays(channelname, requestedarrays)[source]

Set which arrays this script will request from the adaptor for the given channel name.

SetRootDirectory(root_directory)[source]

Makes Catalyst put all output under this directory.

SetUpdateFrequencies(frequencies)[source]

Set the frequencies at which the pipeline needs to be updated. Typically, this is called by the subclass once it has determined what timesteps co-processing will be needed to be done. frequencies is a map, with key->string name of for the simulation input, and value is a list of frequencies.

UpdateCinema(view, datadescription, specLevel)[source]

called from catalyst at each timestep to add to the cinema database

UpdateProducers(datadescription)[source]

This method will update the producers in the pipeline. If the pipeline is not created, it will be created using self.CreatePipeline().

WriteData(datadescription)[source]

This method will update all writes present in the pipeline, as needed, to generate the output data files, respecting the write-frequencies set on the writers.

WriteImages(datadescription, rescale_lookuptable=False, image_quality=None, padding_amount=0)[source]

This method will update all views, if present and write output images, as needed.

Parameters

datadescription

Catalyst data-description object

rescale_lookuptable (bool, optional)

If True, when all lookup tables are rescaled using current data ranges before saving the images. Defaults to False.

image_quality (int, optional)

If specified, should be a value in the range (0, 100) that specifies the image quality. For JPEG, 0 is low quality i.e. max compression, 100 is best quality i.e. least compression. For legacy reasons, this is inverted for PNG (which uses lossless compression). For PNG, 0 is no compression i.e maximum image size, while 100 is most compressed and hence least image size.

If not specified, for saving PNGs 0 is assumed to minimize performance impact.

padding_amount (int, optional)

Amount to pad the time index by.

WriterParametersProxy(writer, filename, freq, paddingamount)[source]

Creates a client only proxy that will be synchronized with ParaView Live, allowing a user to set the filename and frequency.