PVUtils Package

This packages consists of utilities for Paraview.

geos_posp.visu.PVUtils.DisplayOrganizationParaview module

class geos_posp.visu.PVUtils.DisplayOrganizationParaview.DisplayOrganizationParaview[source]

Bases: object

Object to manage Paraview layouts.

Keeps track of Paraview layouts and views when created or removed.

RemoveViewFromLayout(view_name, layout_name, position)[source]

Remove a view from a layout.

Parameters:
  • view_name (str) – name of view.

  • layout_name (str) – name of the layout.

  • position (int) – position of the view.

SwapCellsInLayout(layout_name, position1, position2)[source]

Swap views in a layout.

Parameters:
  • layout_name (str) – name of the layout.

  • position1 (int) – first position of the view.

  • position2 (int) – second position of the view.

addLayout(new_layout_name)[source]

Add a layout.

Parameters:

new_layout_name (str) – name of the new layout.

addOneToCpt()[source]

Increment number of views.

addViewToLayout(viewType, layout_name, position)[source]

Add a view to a layout.

Parameters:
  • viewType (str) – type of view.

  • layout_name (str) – name of the layout.

  • position (int) – position of the view.

getLayoutViews()[source]

Get layout views.

Returns:

Any]: dictionnary of layout views.

Return type:

dict[Any

getLayoutsKeys()[source]

Get layout keys.

Returns:

list of layout keys.

Return type:

list[Any]

getLayoutsNames()[source]

Get layout names.

Returns:

list of layout names.

Return type:

list[str]

getNumberLayouts()[source]

Get the number of layouts.

Returns:

number of layouts.

Return type:

int

getViewsCpt()[source]

Get the number of views.

Returns:

number of views.

Return type:

int

getViewsName()[source]

Get view names.

Returns:

list of view names.

Return type:

list[str]

initLayoutViews()[source]

Initialize layout views.

initLayouts()[source]

Initialize layouts.

removeLayout(layout_name)[source]

Remove a layout.

Parameters:

layout_name (str) – name of the layout to remove.

updateOrganization()[source]

Update layouts.

geos_posp.visu.PVUtils.DisplayOrganizationParaview.buildNewLayoutWithPythonView()[source]

Create a new PythonView layout.

geos_posp.visu.PVUtils.checkboxFunction module

geos_posp.visu.PVUtils.checkboxFunction.createModifiedCallback(anobject)[source]

Helper for the creation and use of vtkDataArraySelection in ParaView.

Parameters:

anobject – any object.

geos_posp.visu.PVUtils.paraviewTreatments module

geos_posp.visu.PVUtils.paraviewTreatments.addDataframeColumnsToVtkPolyData(polyData, df)[source]

Add columns from a dataframe to a vtkPolyData.

Parameters:
  • polyData (vtkPolyData) – vtkPolyData before modifcation.

  • df (pd.DataFrame) – Pandas dataframe.

Returns:

vtkPolyData with new arrays.

Return type:

vtkPolyData

geos_posp.visu.PVUtils.paraviewTreatments.dataframeForEachTimestep(sourceName)[source]

Get the data from source at each time step.

In ParaView, a source object can contain data for multiple timesteps. If so, knowing the source name, we can access its data for each timestep and store it in a dict where the keys are the timesteps and the values the data at each one of them.

Parameters:

sourceName (str) – Name of the source in ParaView pipeline.

Returns:

dictionary where time is the key and dataframe is the value.

Return type:

dict[str, pd.DataFrame]

geos_posp.visu.PVUtils.paraviewTreatments.findSubArrayNames(vtkArray, arrayName)[source]

Get sub array names from multi array attributes.

Because arrays in ParaView can be of multiple dimensions, it can be difficult to convert these arrays to numpy arrays. Therefore, we can split the original array into multiple sub one dimensional arrays. In that case, new sub names need to be derived from the original array to be used.

Parameters:
  • vtkArray (vtkDataArray) – Array from vtk library.

  • arrayName (str) – Name of the array.

Returns:

Sub array names from original array name.

Return type:

list[str]

geos_posp.visu.PVUtils.paraviewTreatments.getArrayChoices(array)[source]

Extracts the column names of input array when they are enabled.

Parameters:

array (vtkDataArraySelection) – input data

Returns:

[columnName1, …, columnNameN]

Return type:

set[str]

geos_posp.visu.PVUtils.paraviewTreatments.getDataframesFromMultipleVTKSources(sourceNames, commonColumn)[source]

Creates the dataframe from each source if they have the commonColumn.

Parameters:
  • sourceNames (set[str]) – list of sources.

  • commonColumn (str) – common column name.

Returns:

output dataframe.

Return type:

list[pd.DataFrame]

geos_posp.visu.PVUtils.paraviewTreatments.getDatasFromSources(sourceNames)[source]

Get the data from input sources.

Parameters:

sourceNames (set[str]) – [sourceName1, …, sourceNameN]

Returns:

dictionary where source names are keys and dataframe are values. { sourceName1: servermanager.Fetch(FindSource(sourceName1)), … sourceNameN: servermanager.Fetch(FindSource(sourceNameN)) }

Return type:

dict[[str, pd.DataFrame]]

geos_posp.visu.PVUtils.paraviewTreatments.getFilterInput(sourceName)[source]

Access the vtk dataset that is used as input for a filter.

Parameters:

sourceName (str) – name of a source object in the pipeline.

Returns:

The vtk dataset that serves as input for the filter.

Return type:

Any

geos_posp.visu.PVUtils.paraviewTreatments.getPossibleSourceNames()[source]

Get the list of valid source names for PythonViewConfigurator.

In PythonViewConfigurator, multiple sources can be considered as valid inputs. We want the user to know the names of every of these sources that can be used to plot data. This function therefore identifies which source names are valid to be used later as sources.

Returns:

Source names in the paraview pipeline.

Return type:

set[str]

geos_posp.visu.PVUtils.paraviewTreatments.getTimeStepIndex(time, timeSteps)[source]

Get the time step index of input time from the list of time steps.

Parameters:
  • time (float) – time

  • timeSteps (npt.NDArray[np.float64]) – Array of time steps

Returns:

time step index

Return type:

int

geos_posp.visu.PVUtils.paraviewTreatments.getVtkOriginalCellIds(mesh)[source]

Get vtkOriginalCellIds from a vtkUnstructuredGrid object.

Parameters:

mesh (vtkMultiBlockDataSet|vtkCompositeDataSet|vtkDataObject) – input mesh.

Returns:

ids of the cells.

Return type:

list[str]

geos_posp.visu.PVUtils.paraviewTreatments.integrateSourceNames(sourceNames, arrayChoices)[source]

Aggregate source and arrayChoices names.

When creating the user choices in PythonViewConfigurator, you need to take into account both the source names and the choices of curves to have user choices corresponding to the column names of the dataframe with the data to be plot.

Parameters:
  • sourceNames (set[str]) – Name of sources found in ParaView pipeline.

  • arrayChoices (set[str]) – Column names of the vtkdataarrayselection.

Returns:

[sourceName1__choice1, sourceName1__choice2,

…, sourceNameN__choiceN]

Return type:

set[str]

geos_posp.visu.PVUtils.paraviewTreatments.isFilter(sourceName)[source]

Identify if a source name can link to a filter in the ParaView pipeline.

Parameters:

sourceName (str) – name of a source object in the pipeline

Returns:

True if filter, False instead.

Return type:

bool

geos_posp.visu.PVUtils.paraviewTreatments.mergeDataframes(dataframes, commonColumn)[source]

Merge all dataframes into a single one by using the common column.

Parameters:
  • dataframes (list[pd.DataFrame]) – List of dataframes from getDataframesFromMultipleVTKSources.

  • commonColumn (str) – Name of the only common column between all of the dataframes.

Returns:

Merged dataframes into a single one by ‘outer’ on the commonColumn.

Return type:

pd.DataFrame

geos_posp.visu.PVUtils.paraviewTreatments.mergeFilterPV(input, keepPartialAttributes=False)[source]

Apply Paraview merge block filter.

Parameters:
  • input (vtkMultiBlockDataSet | vtkCompositeDataSet | vtkDataObject) – composite object to merge blocks

  • keepPartialAttributes (bool) –

    if True, keep partial attributes after merge.

    Defaults to False.

Returns:

merged block object

Return type:

vtkUnstructuredGrid

geos_posp.visu.PVUtils.paraviewTreatments.strEnumToEnumerationDomainXml(enumObj)[source]

Creates an enumeration domain from an Enum objec.

Creates an enumeration domain from an Enum objec for the dropdown widgets of paraview plugin.

Parameters:

enumObj (Enum) – Enumeration values to put in the dropdown widget.

Returns:

the XML string.

Return type:

str

geos_posp.visu.PVUtils.paraviewTreatments.strListToEnumerationDomainXml(properties)[source]

Creates an enumeration domain from a list of strings.

Creates an enumeration domain from a list of strings for the dropdown widgets of paraview plugin.

Parameters:

properties (set[str] | list[str]) – Properties to put in the dropdown widget.

Returns:

the XML string.

Return type:

str

geos_posp.visu.PVUtils.paraviewTreatments.usefulSourceNamesPipeline()[source]

Get the list of valid pipelines for PythonViewConfigurator.

When using the PythonViewConfigurator, we want to check if the sources in the ParaView pipeline are compatible with what the filter can take as input. So this function scans every sources of the pipeline and if it corresponds to one of the hardcoded valid types, we keep the name. They are right now : [“GeosLogReader”, “RenameArrays”]

Returns:

[sourceName1, …, sourceNameN]

Return type:

set[str]

geos_posp.visu.PVUtils.paraviewTreatments.usefulVisibleDatasPipeline()[source]

Get the list of visible pipelines.

When using the PythonViewConfigurator, we want to collect the data of each source that is visible in the paraview pipeline and that is compatible as input data for the filter. Therefore, only certain types of sources will be considered as valid. They are right now : [“GeosLogReader”, “RenameArrays”]

Finally, if the sources are visible and valid, we access their data and return the names of the source and their respective data.

Returns:

dictionary of source names and data from pipeline. { sourceName1: servermanager.Fetch(FindSource(sourceName1)), … sourceNameN: servermanager.Fetch(FindSource(sourceNameN)) }

Return type:

dict[str, ‘vtkInformation’]

geos_posp.visu.PVUtils.paraviewTreatments.vtkPolyDataToPointsDataframe(polydata)[source]

Creates a pandas dataframe containing points data from vtkPolyData.

Parameters:

polydata (vtkPolyData) – vtkPolyData object.

Returns:

Pandas dataframe containing the points data.

Return type:

pd.DataFrame

geos_posp.visu.PVUtils.paraviewTreatments.vtkTableToDataframe(table)[source]

From a vtkTable, creates and returns a pandas dataframe.

Parameters:

table (vtkTable) – vtkTable object.

Returns:

Pandas dataframe.

Return type:

pd.DataFrame

geos_posp.visu.PVUtils.paraviewTreatments.vtkToDataframe(dataset)[source]

Creates a dataframe containing points data from vtkTable or vtkPolyData.

Parameters:

dataset (Any) – dataset to convert if possible.

Returns:

if the dataset is in the right format.

Return type:

pd.DataFrame

geos_posp.visu.PVUtils.paraviewTreatments.vtkUnstructuredGridCellsToDataframe(grid)[source]

Creates a pandas dataframe containing points data from vtkUnstructuredGrid.

Parameters:

grid (vtkUnstructuredGrid) – vtkUnstructuredGrid object.

Returns:

Pandas dataframe.

Return type:

pd.DataFrame

geos_posp.visu.PVUtils.matplotlibOptions module

class geos_posp.visu.PVUtils.matplotlibOptions.FontStyleEnum(value)[source]

Bases: OptionSelectionEnum

An enumeration.

Define the enumeration to options for Paraview selectors.

Parameters:
  • displayName (str) – name displayed in the selector

  • optionValue (str) –

    value used by matplotlib.

    Defaults to None (same optionName as displayName)

ITALIC = ('italic', 'italic')
NORMAL = ('normal', 'normal')
OBLIQUE = ('oblique', 'oblique')
class geos_posp.visu.PVUtils.matplotlibOptions.FontWeightEnum(value)[source]

Bases: OptionSelectionEnum

An enumeration.

Define the enumeration to options for Paraview selectors.

Parameters:
  • displayName (str) – name displayed in the selector

  • optionValue (str) –

    value used by matplotlib.

    Defaults to None (same optionName as displayName)

BOLD = ('bold', 'bold')
HEAVY = ('heavy', 'heavy')
LIGHT = ('light', 'light')
NORMAL = ('normal', 'normal')
class geos_posp.visu.PVUtils.matplotlibOptions.LegendLocationEnum(value)[source]

Bases: OptionSelectionEnum

An enumeration.

Define the enumeration to options for Paraview selectors.

Parameters:
  • displayName (str) – name displayed in the selector

  • optionValue (str) –

    value used by matplotlib.

    Defaults to None (same optionName as displayName)

BEST = ('best', 'best')
CENTER = ('center', 'center')
CENTER_LEFT = ('center left', 'center left')
CENTER_RIGHT = ('center right', 'center right')
LOWER_CENTER = ('lower center', 'lower center')
LOWER_LEFT = ('lower left', 'lower left')
LOWER_RIGHT = ('lower right', 'lower right')
UPPER_CENTER = ('upper center', 'upper center')
UPPER_LEFT = ('upper left', 'upper left')
UPPER_RIGHT = ('upper right', 'upper right')
class geos_posp.visu.PVUtils.matplotlibOptions.LineStyleEnum(value)[source]

Bases: OptionSelectionEnum

An enumeration.

Define the enumeration to options for Paraview selectors.

Parameters:
  • displayName (str) – name displayed in the selector

  • optionValue (str) –

    value used by matplotlib.

    Defaults to None (same optionName as displayName)

DASHDOT = ('dashdot', '-.')
DASHED = ('dashed', '--')
DOTTED = ('dotted', ':')
NONE = ('None', 'None')
SOLID = ('solid', '-')
class geos_posp.visu.PVUtils.matplotlibOptions.MarkerStyleEnum(value)[source]

Bases: OptionSelectionEnum

An enumeration.

Define the enumeration to options for Paraview selectors.

Parameters:
  • displayName (str) – name displayed in the selector

  • optionValue (str) –

    value used by matplotlib.

    Defaults to None (same optionName as displayName)

CIRCLE = ('circle', 'o')
DIAMOND = ('diamond', 'D')
NONE = ('None', '')
PLUS = ('plus', '+')
POINT = ('point', '.')
SQUARE = ('square', 's')
STAR = ('star', '*')
TRIANGLE = ('triangle', '^')
X = ('x', 'x')
class geos_posp.visu.PVUtils.matplotlibOptions.OptionSelectionEnum(value)[source]

Bases: Enum

An enumeration.

Define the enumeration to options for Paraview selectors.

Parameters:
  • displayName (str) – name displayed in the selector

  • optionValue (str) –

    value used by matplotlib.

    Defaults to None (same optionName as displayName)

geos_posp.visu.PVUtils.matplotlibOptions.optionEnumToXml(enumObj)[source]

Creates an enumeration domain from an OptionSelectionEnum object.

Dedicated to the dropdown widgets of paraview plugin.

Parameters:

enumObj (OptionSelectionEnum) – Enumeration values to put in the dropdown widget.

Returns:

the XML string.

Return type:

str