MantisBT - ParaView
View Issue Details
0015770ParaView(No Category)public2015-10-12 08:392016-08-12 09:59
Eelco van Vliet 
Kitware Robot 
normalminorhave not tried
closedmoved 
4.4 
 
ParaViewVR
feature
0015770: Not all numpy funtions can be acccessed in PythonCalculator
I would like to clip my data field using the PythonCalculator in order to be able to clip the largest vectors from a data array

Normally I did this with

minimum(0.1, mag(U))*U/(mag(U)+1e-6)

But I noticed that minimum does not work anymore.

Also other useful numpy routines like clip do not work in 4.4. I would like to do

clip(mag(U), 0, 0.1)

But this gives 'name' clip ' not defined error.

Other numpy function like sin, square, and sqrt are available.

Is it possible to include the whole list as given here: http://docs.scipy.org/doc/numpy/reference/routines.math.html [^]
I found that the following PythonProgramableFilter does more or less what I want. But I used to do this in a one liner in the PythonCalculator. Anyway how to do this easier?


from vtk.numpy_interface import dataset_adapter as dsa
from vtk.numpy_interface import algorithms as algs
import numpy as np
import numpy.linalg

# input parameter

Umax = 1

data = inputs[0]

U = data.PointData['U']
alpha1 = data.PointData['alpha1']

def mag(x):
    return algs.sqrt(x[:,0]*x[:,0]+x[:,1]*x[:,1]+x[:,2]*x[:,2])

Umag = mag(U)
Un = U/algs.max(Umag)

msk = 1*(Umag<Umax)

Uclip = (U*msk+Umax*(1-msk))*alpha1

#print algs.min(Uclip), algs.max(Uclip)
#print algs.min(Umag), algs.max(Umag)
#print algs.min(msk), algs.max(msk)

output.PointData.append(Uclip, "Uclip")
No tags attached.
Issue History
2015-10-12 08:39Eelco van VlietNew Issue
2015-10-12 10:21Eelco van VlietAdditional Information Updatedbug_revision_view_page.php?rev_id=1330#r1330
2016-08-12 09:59Kitware RobotNote Added: 0038906
2016-08-12 09:59Kitware RobotStatusbacklog => closed
2016-08-12 09:59Kitware RobotResolutionopen => moved
2016-08-12 09:59Kitware RobotAssigned To => Kitware Robot

Notes
(0038906)
Kitware Robot   
2016-08-12 09:59   
Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current ParaView Issues page linked in the banner at the top of this page.