<div dir="ltr"><div>Hello, <br> <br></div>  I figured out that the input data set is of type vtkImage while the Slice is type Polygonal. Hence my script seems to work on the Polygonal data set. This is how you get add a vector array to a Cell based vtkImage dataset.<br>
<br>import numpy as np
<p style="margin:0px;text-indent:0px">from  paraview.vtk.dataset_adapter import numpyTovtkDataArray</p>
<p style="margin:0px;text-indent:0px"><br></p>
<p style="margin:0px;text-indent:0px">output = self.GetImageDataOutput()</p>
<p style="margin:0px;text-indent:0px">u =  inputs[0].CellData["U"]</p>
<p style="margin:0px;text-indent:0px">d =  inputs[0].GetDimensions()</p>
<p style="margin:0px;text-indent:0px">dz = 2048/256.0</p>
<p style="margin:0px;text-indent:0px">uPrime = np.empty([d[2],d[1],d[0],3])</p>
<p style="margin:0px;text-indent:0px">print d</p>
<p style="margin:0px;text-indent:0px">for i in range(d[0]):</p>
<p style="margin:0px;text-indent:0px">        for j in range(d[1]):</p>
<p style="margin:0px;text-indent:0px">                 for k in range(d[2]):</p>
<p style="margin:0px;text-indent:0px">                             uPrime[k,j,i] = np.array([0,0,k*dz + 4.0])</p>
<p style="margin:0px;text-indent:0px"><br></p>
<p style="margin:0px;text-indent:0px">uPrime = uPrime.reshape((d[0]*d[1]*d[2],3))</p>
<p style="margin:0px;text-indent:0px">uPrimeVTK = numpyTovtkDataArray(uPrime)</p>
<p style="margin:0px;text-indent:0px">uPrimeVTK.SetName('uPrime')</p>
<p style="margin:0px;text-indent:0px">output.GetCellData().AddArray(uPrimeVTK)</p>
<p style="margin:0px;text-indent:0px"><br></p><br>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Aug 28, 2014 at 11:53 AM, Ganesh Vijayakumar <span dir="ltr"><<a href="mailto:ganesh.iitm@gmail.com" target="_blank">ganesh.iitm@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5"><div dir="ltr"><div><div><div>Hello,<br><br><br></div>  My original dataset is an xdmf 
file that points to some hdf5 files. I have this piece of code in a 
programmable filter. It seems to work on a Slice of the original 
dataset, but won't work on the dataset as a whole. The original dataset 
is cell centered and I then pass it through a "CellDataToPointData" 
filter. Could anyone tell me why? I'm running Paraview 4.1 - 64 bit on a
 server-client mode with the server using 16 cores. I thought it might 
be related to the dataset being multiblock or something (I don't 
understand this very well). So I tried the piece of code here<br>
<br><a href="http://www.paraview.org/Wiki/Python_Programmable_Filter#Dealing_with_Composite_Datasets" target="_blank">http://www.paraview.org/Wiki/Python_Programmable_Filter#Dealing_with_Composite_Datasets</a><br><br></div>

This also works on the slice.. but not on the whole dataset.<br>
<br><br></div>#Programmable filter code below <br><br>import numpy as np<br>from paraview import vtk<br>from  paraview.vtk.dataset_adapter import numpyTovtkDataArray<br>from scipy.interpolate import interp1d<br>
<br>initrLoc = array([0, 2.8667, 5.6, 8.3333, 11.75, 15.85, 19.95, 
24.05, 28.15, 32.25, 36.35, 40.45, 44.55, 48.65, 52.75, 56.1667, 58.9, \<br>61.633, 62.9, 300.0])<br>initaeroTwist
 = array([13.308, 13.308, 13.308, 13.308, 13.308, 11.48, 10.162, 9.011, 
7.795, 6.544, 5.361, 4.188, 3.125, 2.319, 1.526, \<br>
0.863, 0.37, 0.106, 0, 0.0])<br>pitch = 8.7<br>aeroTwistInterp = interp1d(initrLoc, initaeroTwist+pitch)<br><br><br>uxym = np.loadtxt('uxym')<br>umeanInterp = interp1d(uxym[:,2], uxym[:,0]*cos(21.6*np.pi/180.<div>

0) + uxym[:,1]*sin(21.6*np.pi/180.0))<br>
vmeanInterp = interp1d(uxym[:,2], -uxym[:,0]*sin(21.6*np.pi/180.0) + uxym[:,1]*cos(21.6*np.pi/180.0))<br><br>input = self.GetInput()<br>output = self.GetOutput()<br>output.ShallowCopy(input)<br>points = inputs[0].Points[:,:]<br>


nPoints = np.size(points,0)<br>vel = inputs[0].PointData['U']<br>uPrime = np.empty(np.shape(vel))<br>AoACyl = np.empty(np.size(vel,0))<br>omega = (12.0 * 2 * np.pi / 60.0) * array([1,0,0])<br>for i in range(nPoints):<br>


    uPrime[i] = array([umeanInterp(points[i,2]),vmeanInterp(points[i,2]), 0.0])<br>    r = array([0, 15, 0])<br>    localTwist = aeroTwistInterp(15)<br>    newVel = vel[i] - np.cross(omega, r)<br>    AoACyl[i] = arctan2(newVel[0,1],-newVel[0,2])*180/np.pi - localTwist<br>


<br>uPrimeVTK = numpyTovtkDataArray(uPrime)<br>uPrimeVTK.SetName('uPrime')<br>output.GetPointData().AddArray(uPrimeVTK)<br><br>AoACylVTK = numpyTovtkDataArray(AoACyl)<br>AoACylVTK.SetName('AoACyl')<br>output.GetPointData().AddArray(AoACylVTK)</div>

<br clear="all"><br>-- <br>ganesh<br>
</div>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>ganesh<br>
</div>