# ValueError with Numpy Programmable Filter and Exodus File

**URL:** https://discourse.paraview.org/t/valueerror-with-numpy-programmable-filter-and-exodus-file/14535
**Category:** ParaView Support
**Tags:** exodus, python
**Created:** [May 1, 2024, 5:49pm UTC](https://discourse.paraview.org/t/valueerror-with-numpy-programmable-filter-and-exodus-file/14535 "2024-05-01T17:49:34Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![kellis](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/k/5daacb/32.png) [@kellis](https://discourse.paraview.org/u/kellis)
#### Post date: [May 1, 2024, 5:49pm UTC](https://discourse.paraview.org/t/valueerror-with-numpy-programmable-filter-and-exodus-file/14535/1 "2024-05-01T17:49:34Z")

</div>

Hello all,

I am trying to extract the lambda-2 criterion from an Exodus solution file following the method in [this post](https://discourse.paraview.org/t/programmable-filter-eigenvalues-lambda2/12188/9). My solution has 3 individual vector components, so I apply a Merge Vector Components filter to create the velocity field, and then attempt to apply a programmable filter on top of that to calculate the lambda-2s, as described in that post. When I hit apply, I get the following error:

`ValueError: matmul: Input operand 0 does not have enough dimensions (has 0, gufunc core with signature (n?,k),(k,m?)->(n?,m?) requires 1)`

I have tried troubleshooting the script a few ways but cannot get around this issue. The script works as expected when I generate a mesh with a source in ParaView and create a synthetic velocity field with the Calculator filter, but it refuses to work with the Exodus solution file.

Any help would be appreciated. I have attached both a sample .exo solution file and a ParaView state file to this post for anyone who is interested in debugging.

Thanks,  
Kellis

[lambda-2-script.pvsm](https://discourse.paraview.org/uploads/short-url/r352dIZWf5LK9CO9xt5JADSlbAw.pvsm) (418.6 KB)  
[incompressible\_3d\_wale\_cavity\_small\_solution.exo](https://discourse.paraview.org/uploads/short-url/d1RMCZnIAipRO4hmMkXILrreLTo.exo) (792.6 KB)

---

<div class="post-metadata">

### Author: ![Kenichiro-Yoshimi](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/k/ecc23a/32.png) [@Kenichiro-Yoshimi](https://discourse.paraview.org/u/Kenichiro-Yoshimi)
#### Post date: [May 11, 2024, 12:12pm UTC](https://discourse.paraview.org/t/valueerror-with-numpy-programmable-filter-and-exodus-file/14535/2 "2024-05-11T12:12:09Z")

</div>

In version 5.12.0, I incorporated a `Merge Blocks` filter prior to the `Programmable` filter, and the following `Script` did not trigger any errors.

```python
import numpy as np

# Compute the lambda_2 Vortex criterion, see pp.76-77 in
# J. Jeong and F. Hussain, “On the identification of a vortex,” 
# Journal of Fluid Mechanics, vol. 285, pp. 69–94, 1995, doi: 10.1017/S0022112095000462.

vvector = inputs[0].PointData['velocity']

vstrain = strain(vvector)
vskew = gradient(vvector) - vstrain

aaa = matmul(vstrain, vstrain) + matmul(vskew, vskew)

# since aaa is symmetric, it only has real eigenvalues
lambdas = np.linalg.eigvals(aaa)
lambdas = np.real(lambdas )
lambda2 = sort(lambdas)[:,1]

output.DeepCopy(inputs[0].VTKObject)
output.PointData.append(lambda2, 'lambda2')

```

[lambda-2-script\_01.pvsm](https://discourse.paraview.org/uploads/short-url/27UBAccg8JxOKIT81l4kjA7cHFP.pvsm) (738.3 KB)

```auto

```

---

<div class="post-metadata">

### Author: ![kellis](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/k/5daacb/32.png) [@kellis](https://discourse.paraview.org/u/kellis)
#### Post date: [May 13, 2024, 1:47am UTC](https://discourse.paraview.org/t/valueerror-with-numpy-programmable-filter-and-exodus-file/14535/3 "2024-05-13T01:47:40Z")

</div>

Thank you very much! Applying your script gave the expected results in Paraview 5.11.0 as well.

Cheers,  
Kellis

---

<div class="post-metadata">

### Author: ![woodscn](https://discourse.paraview.org/user_avatar/discourse.paraview.org/woodscn/32/3226_2.png) [@woodscn](https://discourse.paraview.org/u/woodscn)
#### Post date: [May 16, 2024, 7:19pm UTC](https://discourse.paraview.org/t/valueerror-with-numpy-programmable-filter-and-exodus-file/14535/4 "2024-05-16T19:19:00Z")

</div>

To give some context here:

MergeBlocks converts MultiBlock Data (like Exodus) into Unstructured Grid data. You can work with the MultiBlock data directly, but you have to loop over the blocks. There aren’t a lot of Programmable Filter examples out there with MultiBlock Data to learn from, so most of us use MergeBlocks.
