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

Sebastien Jourdain sebastien.jourdain at kitware.com
Fri Oct 19 19:46:29 EDT 2012


I guess the solution here is to remove the spaces for the field name and
capitalize the letter next to it if needed.
This logic is to ease the syntax, otherwise, you will have to refer to your
field like that

> input.FieldData['Your field name with space']

I guess it was a bad assumption on my end to suppose the field name won't
have space in it. ;-)

Seb


On Fri, Oct 19, 2012 at 5:32 PM, Joshua Murphy <
Joshua.Murphy at lasp.colorado.edu> wrote:

> 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
>
> Joshua J. Murphy
> Computer Scientist
> Laboratory for Atmospheric and Space Physics
> University of Colorado, Boulder
>
>
> From: Sebastien Jourdain <sebastien.jourdain at kitware.com>
> Date: Friday, October 19, 2012 11:55 AM
> To: Joshua Murphy <Joshua.Murphy at lasp.colorado.edu>
> Cc: "paraview-developers at paraview.org" <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> 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
>>
>>
>> Joshua J. Murphy
>> Computer Scientist
>> Laboratory for Atmospheric and Space Physics
>> University of Colorado, Boulder
>>
>>
>> _______________________________________________
>> Paraview-developers mailing list
>> 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/39b77212/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/png
Size: 16467 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/paraview-developers/attachments/20121019/39b77212/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/png
Size: 16467 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/paraview-developers/attachments/20121019/39b77212/attachment-0003.png>


More information about the Paraview-developers mailing list