[Paraview-developers] AnnotateGlobalData filter does not work with string arrays

Joshua Murphy Joshua.Murphy at lasp.colorado.edu
Fri Oct 19 17:32:06 EDT 2012


Hello all,

So I have been working with annotation.py, and there seems to be a pretty bad logic error, and I am not quite sure how to deal with it.

This section of code is assigning the name of the variable it value, but this doesn't take into account field names that have spaces in them.


   for index in xrange(numberOfFields):

       fieldName = input.GetFieldData().GetAbstractArray(index).GetName()

       exec("%s = input.FieldData['%s']" % (fieldName, fieldName))

For example, in my custom Enlil model reader,  there are several fieldData items which names include spaces.  One is "Physical Time", which produces the following error:


Traceback (most recent call last):

File "<string>", line 5, in <module>

File "/Volumes/Data/Development/paraview_git/build/lib/site-packages/paraview/annotation.py", line 45, in ComputeAnnotation

exec("%s = input.FieldData['%s']" % (fieldName, fieldName))

File "<string>", line 1

Physical Time = input.FieldData['Physical Time']

^

SyntaxError: invalid syntax

As it is obviously not possible to assign Physical Time a value.

As was noted in last email, it was necessary to change "GetArray" to "GetAbstractArray" in order for this to work with strings.

Now, the question is, are there recommended best practices for naming field data items?  Are spaces not recommended?  Or does the filter need to be able to deal with this case?

Thanks,
Josh

[cid:C7A30C8E-90D5-4596-991B-DF23E382F518]
Joshua J. Murphy
Computer Scientist
Laboratory for Atmospheric and Space Physics
University of Colorado, Boulder


From: Sebastien Jourdain <sebastien.jourdain at kitware.com<mailto:sebastien.jourdain at kitware.com>>
Date: Friday, October 19, 2012 11:55 AM
To: Joshua Murphy <Joshua.Murphy at lasp.colorado.edu<mailto:Joshua.Murphy at lasp.colorado.edu>>
Cc: "paraview-developers at paraview.org<mailto:paraview-developers at paraview.org>" <paraview-developers at paraview.org<mailto:paraview-developers at paraview.org>>
Subject: Re: [Paraview-developers] AnnotateGlobalData filter does not work with string arrays

ParaView/src/Wrapping/Python/paraview/annotation.py

Let me know if that works in all the case and I could push the fix on the main repo...

On Fri, Oct 19, 2012 at 1:39 PM, Joshua Murphy <Joshua.Murphy at lasp.colorado.edu<mailto:Joshua.Murphy at lasp.colorado.edu>> wrote:
Hello,

I am trying to use the AnnotateGlobalData filter with string data in my reader's field data, but the filter is calling the wrong functions to retrieve the string data.

The error being generated is:


Traceback (most recent call last):

File "<string>", line 5, in <module>

File "/Users/jomu9721/Data/Development/paraview_git/build/lib/site-packages/paraview/annotation.py", line 44, in ComputeAnnotation

fieldName = input.GetFieldData().GetArray(index).GetName()

AttributeError: 'NoneType' object has no attribute 'GetName'


Trough a query to the general paraview mailing list, I was able to ascertain that proper call would be:


fieldName = input.GetFieldData().GetAbstractArray(index).GetName()


Is there an easy way I can fix this? Can someone point me to where in the source tree this filter is defined?


Thanks,

Josh


[cid:D6616F45-18FE-4B95-9378-CE5F535EDC54]
Joshua J. Murphy
Computer Scientist
Laboratory for Atmospheric and Space Physics
University of Colorado, Boulder


_______________________________________________
Paraview-developers mailing list
Paraview-developers at paraview.org<mailto:Paraview-developers at paraview.org>
http://public.kitware.com/mailman/listinfo/paraview-developers


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/paraview-developers/attachments/20121019/b6f8df44/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: A93D829A-3C2C-4769-925A-35900ECAAE2C[2].png
Type: image/png
Size: 16467 bytes
Desc: A93D829A-3C2C-4769-925A-35900ECAAE2C[2].png
URL: <http://public.kitware.com/pipermail/paraview-developers/attachments/20121019/b6f8df44/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: A93D829A-3C2C-4769-925A-35900ECAAE2C[1].png
Type: image/png
Size: 16467 bytes
Desc: A93D829A-3C2C-4769-925A-35900ECAAE2C[1].png
URL: <http://public.kitware.com/pipermail/paraview-developers/attachments/20121019/b6f8df44/attachment-0003.png>


More information about the Paraview-developers mailing list