Python Calculator: Difference between revisions
No edit summary |
|||
(6 intermediate revisions by the same user not shown) | |||
Line 4: | Line 4: | ||
Below is a list of mathematical functions currently supported by this python calculator. Notice that these functions are also available in the python programmable filter. | Below is a list of mathematical functions currently supported by this python calculator. Notice that these functions are also available in the python programmable filter. | ||
* Functions working on data arrays | |||
<table border="1"> | <table border="1"> | ||
<tr> | <tr> | ||
<th>Name</th> | <th>Name</th> | ||
<th>Supported Operand Types</th> | <th colspan="3">Supported Operand Types</th> | ||
<th> | <th># Operands</th> | ||
<th>Data Association</th> | <th colspan="2">Data Association</th> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td>abs</td> | <td>abs</td> | ||
<td>scalar vector tensor</td> | <td align="center">scalar</td> | ||
<td>1</td> | <td align="center">vector</td> | ||
<td>point | <td align="center">tensor</td> | ||
<td align="center">1</td> | |||
<td align="center">point</td> | |||
<td align="center">cell</td> | |||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td>cross</td> | <td>cross</td> | ||
<td> | <td align="center"></td> | ||
<td>2</td> | <td align="center">vector</td> | ||
<td>point | <td align="center"></td> | ||
<td align="center">2</td> | |||
<td align="center">point</td> | |||
<td align="center">cell</td> | |||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td>curl</td> | <td>curl</td> | ||
<td> | <td align="center"></td> | ||
<td>1</td> | <td align="center">vector</td> | ||
<td>point | <td align="center"></td> | ||
<td align="center">1</td> | |||
<td align="center">point</td> | |||
<td align="center">cell</td> | |||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td>det</td> | <td>det</td> | ||
<td> | <td align="center"></td> | ||
<td>1</td> | <td align="center"></td> | ||
<td>point | <td align="center">tensor</td> | ||
<td align="center">1</td> | |||
<td align="center">point</td> | |||
<td align="center">cell</td> | |||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td>determinant</td> | <td>determinant</td> | ||
<td> | <td align="center"></td> | ||
<td>1</td> | <td align="center"></td> | ||
<td>point | <td align="center">tensor</td> | ||
<td align="center">1</td> | |||
<td align="center">point</td> | |||
<td align="center">cell</td> | |||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td>dot</td> | <td>dot</td> | ||
<td>scalar vector | <td align="center">scalar</td> | ||
<td>2</td> | <td align="center">vector</td> | ||
<td>point | <td align="center"></td> | ||
<td align="center">2</td> | |||
<td align="center">point</td> | |||
<td align="center">cell</td> | |||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td>eigenvalue</td> | <td>eigenvalue</td> | ||
<td> | <td align="center"></td> | ||
<td>1</td> | <td align="center"></td> | ||
<td>point | <td align="center">tensor</td> | ||
<td align="center">1</td> | |||
<td align="center">point</td> | |||
<td align="center">cell</td> | |||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td>eigenvector</td> | <td>eigenvector</td> | ||
<td> | <td align="center"></td> | ||
<td>1</td> | <td align="center"></td> | ||
<td>point | <td align="center">tensor</td> | ||
<td align="center">1</td> | |||
<td align="center">point</td> | |||
<td align="center">cell</td> | |||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td>global_mean</td> | <td>global_mean</td> | ||
<td>scalar vector tensor</td> | <td align="center">scalar</td> | ||
<td>1</td> | <td align="center">vector</td> | ||
<td>point | <td align="center">tensor</td> | ||
<td align="center">1</td> | |||
<td align="center">point</td> | |||
<td align="center">cell</td> | |||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td>global_max</td> | <td>global_max</td> | ||
<td>scalar vector tensor</td> | <td align="center">scalar</td> | ||
<td>1</td> | <td align="center">vector</td> | ||
<td>point | <td align="center">tensor</td> | ||
<td align="center">1</td> | |||
<td align="center">point</td> | |||
<td align="center">cell</td> | |||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td>global_min</td> | <td>global_min</td> | ||
<td>scalar vector tensor</td> | <td align="center">scalar</td> | ||
<td>1</td> | <td align="center">vector</td> | ||
<td>point | <td align="center">tensor</td> | ||
<td align="center">1</td> | |||
<td align="center">point</td> | |||
<td align="center">cell</td> | |||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td>gradient</td> | <td>gradient</td> | ||
<td>scalar vector | <td align="center">scalar</td> | ||
<td>1</td> | <td align="center">vector</td> | ||
<td>point | <td align="center"></td> | ||
<td align="center">1</td> | |||
<td align="center">point</td> | |||
<td align="center">cell</td> | |||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td>inverse</td> | <td>inverse</td> | ||
<td> | <td align="center"></td> | ||
<td>1</td> | <td align="center"></td> | ||
<td>point | <td align="center">tensor</td> | ||
<td align="center">1</td> | |||
<td align="center">point</td> | |||
<td align="center">cell</td> | |||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td>laplacian</td> | <td>laplacian</td> | ||
<td>scalar | <td align="center">scalar</td> | ||
<td>1</td> | <td align="center"></td> | ||
<td>point | <td align="center"></td> | ||
<td align="center">1</td> | |||
<td align="center">point</td> | |||
<td align="center">cell</td> | |||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td>ln</td> | <td>ln</td> | ||
<td>scalar vector tensor</td> | <td align="center">scalar</td> | ||
<td>1</td> | <td align="center">vector</td> | ||
<td>point | <td align="center">tensor</td> | ||
<td align="center">1</td> | |||
<td align="center">point</td> | |||
<td align="center">cell</td> | |||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td>log(==ln)</td> | <td>log(==ln)</td> | ||
<td>scalar vector tensor</td> | <td align="center">scalar</td> | ||
<td>1</td> | <td align="center">vector</td> | ||
<td>point | <td align="center">tensor</td> | ||
<td align="center">1</td> | |||
<td align="center">point</td> | |||
<td align="center">cell</td> | |||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td>log10</td> | <td>log10</td> | ||
<td>scalar vector tensor</td> | <td align="center">scalar</td> | ||
<td>1</td> | <td align="center">vector</td> | ||
<td>point | <td align="center">tensor</td> | ||
<td align="center">1</td> | |||
<td align="center">point</td> | |||
<td align="center">cell</td> | |||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td>max</td> | <td>max</td> | ||
<td>scalar vector tensor</td> | <td align="center">scalar</td> | ||
<td>1</td> | <td align="center">vector</td> | ||
<td>point | <td align="center">tensor</td> | ||
<td align="center">1</td> | |||
<td align="center">point</td> | |||
<td align="center">cell</td> | |||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td>min</td> | <td>min</td> | ||
<td>scalar vector tensor</td> | <td align="center">scalar</td> | ||
<td>1</td> | <td align="center">vector</td> | ||
<td>point | <td align="center">tensor</td> | ||
<td align="center">1</td> | |||
<td align="center">point</td> | |||
<td align="center">cell</td> | |||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td>mean</td> | <td>mean</td> | ||
<td>scalar vector tensor</td> | <td align="center">scalar</td> | ||
<td>1</td> | <td align="center">vector</td> | ||
<td>point | <td align="center">tensor</td> | ||
<td align="center">1</td> | |||
<td align="center">point</td> | |||
<td align="center">cell</td> | |||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td>mag</td> | <td>mag</td> | ||
<td>scalar vector | <td align="center">scalar</td> | ||
<td>1</td> | <td align="center">vector</td> | ||
<td>point | <td align="center"></td> | ||
<td align="center">1</td> | |||
<td align="center">point</td> | |||
<td align="center">cell</td> | |||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td>norm</td> | <td>norm</td> | ||
<td>scalar vector | <td align="center">scalar</td> | ||
<td>1</td> | <td align="center">vector</td> | ||
<td>point | <td align="center"></td> | ||
<td align="center">1</td> | |||
<td align="center">point</td> | |||
<td align="center">cell</td> | |||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td>strain</td> | <td>strain</td> | ||
<td> | <td align="center"></td> | ||
<td>1</td> | <td align="center">vector</td> | ||
<td>point | <td align="center"></td> | ||
<td align="center">1</td> | |||
<td align="center">point</td> | |||
<td align="center">cell</td> | |||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td>trace</td> | <td>trace</td> | ||
<td> | <td align="center"></td> | ||
<td>1</td> | <td align="center"></td> | ||
<td>point | <td align="center">tensor</td> | ||
<td align="center">1</td> | |||
<td align="center">point</td> | |||
<td align="center">cell</td> | |||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td>vorticity</td> | <td>vorticity</td> | ||
<td> | <td align="center"></td> | ||
<td>1</td> | <td align="center">vector</td> | ||
<td>point | <td align="center"></td> | ||
<td align="center">1</td> | |||
<td align="center">point</td> | |||
<td align="center">cell</td> | |||
</tr> | </tr> | ||
Line 192: | Line 267: | ||
* Functions working on dataset | |||
<table border="1"> | <table border="1"> | ||
<tr> | <tr> | ||
<th>Name</th> | <th>Name</th> | ||
<th>Supported Cell Types</th> | <th colspan="4">Supported Cell Types</th> | ||
<th>Data Association</th> | <th colspan="2">Data Association</th> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td>area </td><td> trig quad | <td>area </td> | ||
<td align="center">trig</td> | |||
<td align="center">quad</td> | |||
<td align="center"></td> | |||
<td align="center"></td> | |||
<td align="center"></td> | |||
<td align="center">cell</td> | |||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td>aspect </td><td> trig quad tet | <td>aspect </td> | ||
<td align="center">trig</td> | |||
<td align="center">quad</td> | |||
<td align="center">tet</td> | |||
<td align="center"></td> | |||
<td align="center"></td> | |||
<td align="center">cell</td> | |||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td>aspect_gamma </td><td> | <td>aspect_gamma </td> | ||
<td align="center"></td> | |||
<td align="center"></td> | |||
<td align="center">tet</td> | |||
<td align="center"></td> | |||
<td align="center"></td> | |||
<td align="center">cell</td> | |||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td>diagonal </td><td> | <td>diagonal </td> | ||
<td align="center"></td> | |||
<td align="center"></td> | |||
<td align="center"></td> | |||
<td align="center">hex</td> | |||
<td align="center"></td> | |||
<td align="center">cell</td> | |||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td>jacobian </td><td> | <td>jacobian </td> | ||
<td align="center"></td> | |||
<td align="center">quad</td> | |||
<td align="center">tet</td> | |||
<td align="center">hex</td> | |||
<td align="center"></td> | |||
<td align="center">cell</td> | |||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td>max_angle </td><td> trig quad | <td>max_angle </td> | ||
<td align="center">trig</td> | |||
<td align="center">quad</td> | |||
<td align="center"></td> | |||
<td align="center"></td> | |||
<td align="center"></td> | |||
<td align="center">cell</td> | |||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td>min_angle </td><td> trig quad | <td>min_angle </td> | ||
<td align="center">trig</td> | |||
<td align="center">quad</td> | |||
<td align="center"></td> | |||
<td align="center"></td> | |||
<td align="center"></td> | |||
<td align="center">cell</td> | |||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td>shear </td><td> | <td>shear </td> | ||
<td align="center"></td> | |||
<td align="center">quad</td> | |||
<td align="center"></td> | |||
<td align="center"></td> | |||
<td align="center"></td> | |||
<td align="center">cell</td> | |||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td>skew </td><td> | <td>skew </td> | ||
<td align="center"></td> | |||
<td align="center">quad</td> | |||
<td align="center"></td> | |||
<td align="center">hex</td> | |||
<td align="center"></td> | |||
<td align="center">cell</td> | |||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td>surface_normal</td><td> trig | <td>surface_normal</td> | ||
<td align="center">trig</td> | |||
<td align="center"></td> | |||
<td align="center"></td> | |||
<td align="center"></td> | |||
<td align="center"></td> | |||
<td align="center">cell</td> | |||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td>volume </td><td> | <td>volume </td> | ||
<td align="center"></td> | |||
<td align="center"></td> | |||
<td align="center">tet</td> | |||
<td align="center">hex</td> | |||
<td align="center"></td> | |||
<td align="center">cell</td> | |||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td>vertex_normal </td><td> trig | <td>vertex_normal </td> | ||
<td align="center">trig</td> | |||
<td align="center"></td> | |||
<td align="center"></td> | |||
<td align="center"></td> | |||
<td align="center">point</td> | |||
<td align="center"></td> | |||
</tr> | </tr> | ||
</table> | </table> | ||
== Comments == | == Comments == | ||
The first list gives all the math functions that work with point data or cell data. The general calling signature is function_name(array) for functions taking one operand or function_name(array1, array2) for functions taking two operands. For example, abs(Normals) computes the absolute value for all normals associated with the dataset | The first list gives all the math functions that work with point data or cell data. The general calling signature is function_name(array) for functions taking one operand or function_name(array1, array2) for functions taking two operands. For example, abs(Normals) computes the component-wise absolute value for all normals associated with the dataset. The array association must be given throuth the GUI interface of the python calculator. | ||
The second list gives all the math functions that directly work with a dataset. Most of them work on the cells of a dataset, with only one exception vertex_normal which computes the normal for each point in a dataset. The calling signature of this category is function_name(inputs[0]) where inputs[0] is defined within the calling context by paraview to be your first input dataset. | The second list gives all the math functions that directly work with a dataset. Most of them work on the cells of a dataset, with only one exception vertex_normal which computes the normal for each point in a dataset. The calling signature of this category is function_name(inputs[0]) where inputs[0] is defined within the calling context by paraview to be your first input dataset. |
Latest revision as of 15:39, 16 August 2010
The python calculator is a programmable calculator that provides common mathematical operations and apply them on the point data, cell data or the input datasets directly. It is similar to the python programmable filter and utilizes its functionality to build python scripts for execution. For efficiency, the actual computation is delegated either to corresponding VTK filters or to the numpy library.
Supported Function List
Below is a list of mathematical functions currently supported by this python calculator. Notice that these functions are also available in the python programmable filter.
- Functions working on data arrays
Name | Supported Operand Types | # Operands | Data Association | |||
---|---|---|---|---|---|---|
abs | scalar | vector | tensor | 1 | point | cell |
cross | vector | 2 | point | cell | ||
curl | vector | 1 | point | cell | ||
det | tensor | 1 | point | cell | ||
determinant | tensor | 1 | point | cell | ||
dot | scalar | vector | 2 | point | cell | |
eigenvalue | tensor | 1 | point | cell | ||
eigenvector | tensor | 1 | point | cell | ||
global_mean | scalar | vector | tensor | 1 | point | cell |
global_max | scalar | vector | tensor | 1 | point | cell |
global_min | scalar | vector | tensor | 1 | point | cell |
gradient | scalar | vector | 1 | point | cell | |
inverse | tensor | 1 | point | cell | ||
laplacian | scalar | 1 | point | cell | ||
ln | scalar | vector | tensor | 1 | point | cell |
log(==ln) | scalar | vector | tensor | 1 | point | cell |
log10 | scalar | vector | tensor | 1 | point | cell |
max | scalar | vector | tensor | 1 | point | cell |
min | scalar | vector | tensor | 1 | point | cell |
mean | scalar | vector | tensor | 1 | point | cell |
mag | scalar | vector | 1 | point | cell | |
norm | scalar | vector | 1 | point | cell | |
strain | vector | 1 | point | cell | ||
trace | tensor | 1 | point | cell | ||
vorticity | vector | 1 | point | cell |
- Functions working on dataset
Name | Supported Cell Types | Data Association | ||||
---|---|---|---|---|---|---|
area | trig | quad | cell | |||
aspect | trig | quad | tet | cell | ||
aspect_gamma | tet | cell | ||||
diagonal | hex | cell | ||||
jacobian | quad | tet | hex | cell | ||
max_angle | trig | quad | cell | |||
min_angle | trig | quad | cell | |||
shear | quad | cell | ||||
skew | quad | hex | cell | |||
surface_normal | trig | cell | ||||
volume | tet | hex | cell | |||
vertex_normal | trig | point |
Comments
The first list gives all the math functions that work with point data or cell data. The general calling signature is function_name(array) for functions taking one operand or function_name(array1, array2) for functions taking two operands. For example, abs(Normals) computes the component-wise absolute value for all normals associated with the dataset. The array association must be given throuth the GUI interface of the python calculator.
The second list gives all the math functions that directly work with a dataset. Most of them work on the cells of a dataset, with only one exception vertex_normal which computes the normal for each point in a dataset. The calling signature of this category is function_name(inputs[0]) where inputs[0] is defined within the calling context by paraview to be your first input dataset.
In the lists, vector means 3D vectors and tensor stands for 3 by 3 matrix. trig is triangle, quad is quadrilateral, tet is tetrahedron and hex is hexahedron.
Examples
Compute area for each cell
area(inputs[0]) and array association set to Cell Data
Compute vector length for each point
sqrt(dot(BrownianVectors,BrownianVectors)) or equivalently mag(BrownianVectors)
where BrownianVectors is an array of 3D vectors that are associated with each point in the dataset. Array association set to Point Data.
A more complex example
max(abs(trace(inverse(gradient(Normals)))))
Normals is an array of 3D vectors that are associated to each point in the dataset. The expression first computes for each component of the normal vector its gradient, therefore effectively generates a tensor and then it takes the inverse of the generated matrix and then sum everything on the diagonal of the inverse matrix and then computes the absolute value of the sum and then looks for the maximum of all the absolute values.