Math Operations

Array Math

class PVGeo.filters.math.ArrayMath(**kwargs)[source]

Bases: PVGeo.base.FilterPreserveTypeBase

This filter allows the user to select two input data arrays on which to perfrom math operations. The input arrays are used in their order of selection for the operations.

Available Math Operations:

  • add: This adds the two data arrays together
  • subtract: This subtracts input array 2 from input array 1
  • multiply: Multiplies the two data arrays together
  • divide: Divide input array 1 by input array 2 (arr1/arr2)
  • correlate: Use np.correlate(arr1, arr2, mode=’same’)
Apply(inputDataObject, arrayName0, arrayName1)[source]

Update the algorithm and get the output data object

GetMultiplier()[source]

Return the set multiplier/scalar

GetNewArrayName()[source]
static GetOperation(idx)[source]

Gets a math operation based on an index in the keys

Returns:the math operation method
Return type:callable
static GetOperationNames()[source]

Gets a list of the math operation keys

Returns:the keys for getting the math operations
Return type:list(str)
static GetOperations()[source]

Returns the math operation methods as callable objects in a dictionary

RequestData(request, inInfo, outInfo)[source]

Used by pipeline to perfrom operation and generate output

SetInputArrayToProcess(idx, port, connection, field, name)[source]

Used to set the input array(s)

Parameters:
  • idx (int) – the index of the array to process
  • port (int) – input port (use 0 if unsure)
  • connection (int) – the connection on the port (use 0 if unsure)
  • field (int) – the array field (0 for points, 1 for cells, 2 for field, and 6 for row)
  • name (int) – the name of the array
SetMultiplier(val)[source]

This is a static shifter/scale factor across the array after normalization.

SetNewArrayName(name)[source]

Give the new array a meaningful name.

SetOperation(op)[source]

Set the math operation to perform

Parameters:
  • op (str, int, or callable) – The operation as a string key, int
  • or callable method (index,) –

Note

This can accept a callable method to set a custom operation as long as its signature is: <callable>(arr1, arr2)

_MathUp(pdi, pdo)[source]

Make sure to pass array names and integer associated fields. Use helpers to get these properties.

_SetInputArray1(field, name)[source]
_SetInputArray2(field, name)[source]
static _add(arr1, arr2)[source]
static _correlate(arr1, arr2)[source]

Use np.correlate() on mode='same' on two selected arrays from one input.

static _divide(arr1, arr2)[source]
static _multiply(arr1, arr2)[source]
static _subtract(arr1, arr2)[source]

Arrays To RGBA

class PVGeo.filters.math.ArraysToRGBA(**kwargs)[source]

Bases: PVGeo.base.FilterPreserveTypeBase

Use arrays from input data object to set an RGBA array. Sets colors and transparencies.

Apply(inputDataObject, rArray, gAray, bArray, aArray=None)[source]

Update the algorithm and get the output data object

RequestData(request, inInfo, outInfo)[source]

Execute on pipeline

SetInputArrayToProcess(idx, port, connection, field, name)[source]

Used to set the input array(s)

Parameters:
  • idx (int) – the index of the array to process
  • port (int) – input port (use 0 if unsure)
  • connection (int) – the connection on the port (use 0 if unsure)
  • field (int) – the array field (0 for points, 1 for cells, 2 for field, and 6 for row)
  • name (int) – the name of the array
SetMaskValue(val)[source]
SetUseTransparency(flag)[source]
_GetArrays(wpdi)[source]
_MaskArrays(rArr, gArr, bArr, aArr)[source]
_SetInputArrayBlue(field, name)[source]
_SetInputArrayGreen(field, name)[source]
_SetInputArrayRed(field, name)[source]
_SetInputArrayTrans(field, name)[source]

Normalize Array

class PVGeo.filters.math.NormalizeArray(**kwargs)[source]

Bases: PVGeo.base.FilterPreserveTypeBase

This filter allows the user to select an array from the input data set to be normalized. The filter will append another array to that data set for the output. The user can specify how they want to rename the array, can choose a multiplier, and can choose from several types of common normalizations (more functionality added as requested).

Normalization Types:

  • feature_scale: Feature Scale
  • standard_score: tandard Score
  • log10: Natural Log
  • natural_log: Log Base 10
  • just_multiply: Only Multiply by Multiplier
Apply(inputDataObject, arrayName)[source]

Update the algorithm and get the output data object

static GetArrayRange(pdi, field, name)[source]

Returns a tuple of the range for a vtkDataArray on a vtkDataObject.

GetMultiplier()[source]

Return the set multiplier/scalar

GetNewArrayName()[source]
static GetNormalization(idx)[source]

Gets a normalization based on an index in the keys

Returns:the normalization method
Return type:callable
static GetNormalizationNames()[source]

Gets a list of the normalization keys

Returns:the keys for getting the normalizations
Return type:list(str)
static GetNormalizations()[source]

All Available normalizations

Returns:dictionary of callable methods for normalizing an array
Return type:dict
RequestData(request, inInfo, outInfo)[source]

Used by pipeline to generate output

SetInputArrayToProcess(idx, port, connection, field, name)[source]

Used to set the input array(s)

Parameters:
  • idx (int) – the index of the array to process
  • port (int) – input port (use 0 if unsure)
  • connection (int) – the connection on the port (use 0 if unsure)
  • field (int) – the array field (0 for points, 1 for cells, 2 for field, and 6 for row)
  • name (int) – the name of the array
SetMultiplier(val)[source]

This is a static shifter/scale factor across the array after normalization.

SetNewArrayName(name)[source]

Give the new array a meaningful name.

SetNormalization(norm)[source]

Set the normalization operation to perform

Parameters:norm (str, int, or callable) – The operation as a string key, int index, or callable method

Note

This can accept a callable method to set a custom operation as long as its signature is: <callable>(arr)

SetShift(sft)[source]

Set a static shifter to the input data array

SetTakeAbsoluteValue(flag)[source]

This will take the absolute value of the array before normalization.

_Normalize(pdi, pdo)[source]

Perform normalize on a data array for any given VTK data object.

static _featureScale(arr, rng=None)[source]
static _log10(arr)[source]
static _logNat(arr)[source]
static _passArray(arr)[source]
static _standardScore(arr)[source]

Percent Threshold

class PVGeo.filters.math.PercentThreshold(percent=50, invert=False, **kwargs)[source]

Bases: PVGeo.base.FilterBase

Allows user to select a percent of the data range to threshold. This will find the data range of the selected input array and remove the bottom percent. This can be reversed using the invert property.

Apply(inputDataObject, arrayName)[source]

Update the algorithm and get the output data object

RequestData(request, inInfo, outInfo)[source]

Used by pipeline for execution

SetInputArrayToProcess(idx, port, connection, field, name)[source]

Used to set the input array(s)

Parameters:
  • idx (int) – the index of the array to process
  • port (int) – input port (use 0 if unsure)
  • connection (int) – the connection on the port (use 0 if unsure)
  • field (int) – the array field (0 for points, 1 for cells, 2 for field, and 6 for row)
  • name (int) – the name of the array
SetInvert(flag)[source]

Use to invert the threshold filter

SetPercent(percent)[source]

Set the percent for the threshold in range (0, 100). Any values falling beneath the set percent of the total data range will be removed.

SetUseContinuousCellRange(flag)[source]

If this is on (default is off), we will use the continuous interval [minimum cell scalar, maxmimum cell scalar] to intersect the threshold bound , rather than the set of discrete scalar values from the vertices