Sorry for not providing the right information, I am new to this.
It’s an acquired skill, but generally useful.
The error is:
Traceback (most recent call last):
File “C:\Users\sgcgrif3\Documents\MFIX Files\Rice Pile\130421 working
mfix files\New folder\convert.py”, line 27, in
vel = vtk_to_numpy(point_data.GetAbstractArray(‘Velocity’))
File
“C:\Users\sgcgrif3\Anaconda3\envs\mfix-21.1.0\lib\site-packages\vtkmodules\util\numpy_support.py”,
line 216, in vtk_to_numpy
typ = vtk_array.GetDataType()
AttributeError: ‘NoneType’ object has no attribute ‘GetDataType’
Based on this, we can infer that “vtk_array” is None, instead of the
array type that numpy_support.py expected. So why?
Backing up, the previous line (from your own code) is:
vel = vtk_to_numpy(point_data.GetAbstractArray('Velocity'))
so we may guess that vtk_to_numpy() has perhaps been passed None instead
of the desired array object. That would imply that:
point_data.GetAbstractArray('Velocity')
returned None. A bit of poking around with a search engine finds this:
https://vtk.org/doc/nightly/html/classvtkFieldData.html#ac21ae27f8d0bdcfba55523ed7a2d01da
which is to documentation for the GetAbstractArray method from the C++
VTK library (your Python code will be accessing this via a little
adaptor). It says:
vtkAbstractArray* vtkFieldData::GetAbstractArray(int i)
Returns the ith array in the field.
Unlike GetArray(), this method returns a vtkAbstractArray and can be
used to access any array type. A nullptr is returned only if the index i
is out of range.
That suggests that the matching Python method probably returns None if
‘Velocity’ is unknown (I’d guess that keys like ‘Velocity’ are mapped to
an index for the underlying library).
This asks the question: is ‘Velocity’ the correct key? For example, is
there a ‘Velocity’ field in your data? Alternatively, do you need to
convert ‘Velocity’ into some integer index (this seems less likely)?
I would start by printing out what
point_data.GetAbstractArray(‘Velocity’) returns:
ary = point_data.GetAbstractArray('Velocity')
print("ary =", type(ary), ary)
vel = vtk_to_numpy(ary)
That will tell you if you’re getting None or a more useful thing. Then
adjust your code so that you get the more useful thing.
Cheers,
Cameron Simpson cs@cskk.id.au