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

Sebastien Jourdain sebastien.jourdain at kitware.com
Tue Oct 30 17:31:07 EDT 2012


Hi Joshua,

the logic is embedded inside
"src/Wrapping/Python/paraview/vtk/dataset_adapter.py"
In fact input.GetFieldData() will return the class
DataSetAttributes(VTKObjectWrapper).
If you end-up with a descent working solution, I'd be happy to integrate
your patch inside ParaView proper.

Hope this will help,

Seb

On Tue, Oct 30, 2012 at 5:16 PM, Joshua Murphy <
Joshua.Murphy at lasp.colorado.edu> wrote:

> Hi Seb,
>
> I have been working with this a little more.  I re-wrote my reader to not
> use spaces int he field data, but I am still having difficulty with getting
> string array elements to print with this filter.
>
> This code here is still the issue.
>
>     # Add Fields names inside current namespace
>
>     numberOfFields = input.GetFieldData().GetNumberOfArrays()
>
>     for index in xrange(numberOfFields):
>
>        fieldName = input.GetFieldData().GetAbstractArray(index).GetName()
>
>        exec("%s = input.FieldData['%s']" % (fieldName, fieldName))
>
>
>
> Changing the fieldName = input.GetAbstractArray(index).GetName() works to
> parse through the values, but the PythonAnnotation filter method
> input.FieldData[%s] does not get the output.  I don't know where
> input.FieldData[] is defined, but I suspect that there is a similar
> problem, as the GetArray() method does not work with strings.
>
> Can you point me to where I may be able to find the definition?  I tried
> using input.GetFieldData().GetAbstractArray(index).GetValue(0) in place of
> input.FieldData['%s'], but it was not a recognized routine….
>
> Anyway, I would like to try to get this working this week, so any pointers
> you might be able to give me would be great!
>
> 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 5:46 PM
>
> 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
>
> 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/20121030/1cdd5f90/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/20121030/1cdd5f90/attachment-0003.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/20121030/1cdd5f90/attachment-0004.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/20121030/1cdd5f90/attachment-0005.png>


More information about the Paraview-developers mailing list