Hi Joshua,<div><br></div><div>the logic is embedded inside "src/Wrapping/Python/paraview/vtk/dataset_adapter.py"</div><div>In fact <span style="font-family:Menlo;font-size:11px">input.GetFieldData()</span> will return the class<span style="color:rgb(192,192,192)"> </span>DataSetAttributes(VTKObjectWrapper).</div>
<div>If you end-up with a descent working solution, I'd be happy to integrate your patch inside ParaView proper.</div><div><br></div><div>Hope this will help,</div><div><br></div><div>Seb<br><br><div class="gmail_quote">
On Tue, Oct 30, 2012 at 5:16 PM, Joshua Murphy <span dir="ltr"><<a href="mailto:Joshua.Murphy@lasp.colorado.edu" target="_blank">Joshua.Murphy@lasp.colorado.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="font-size:14px;font-family:Calibri,sans-serif;word-wrap:break-word"><div>Hi Seb,</div><div><br></div><div>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.</div>
<div><br></div><div>This code here is still the issue.</div><div><br></div><div><p style="margin:0.0px 0.0px 0.0px 0.0px;font:11.0px Menlo;color:#008210"><span style="color:#000000"> </span># Add Fields names inside current namespace</p>
<p style="margin:0.0px 0.0px 0.0px 0.0px;font:11.0px Menlo"> numberOfFields = input.GetFieldData().GetNumberOfArrays()</p><div class="im">
<p style="margin:0.0px 0.0px 0.0px 0.0px;font:11.0px Menlo"> <span style="color:#b933a1">for</span> index <span style="color:#b933a1">in</span> xrange(numberOfFields):</p>
<p style="margin:0.0px 0.0px 0.0px 0.0px;font:11.0px Menlo"> fieldName = input.GetFieldData().GetAbstractArray(index).GetName()</p>
<p style="margin:0.0px 0.0px 0.0px 0.0px;font:11.0px Menlo"> <span style="color:#b933a1">exec</span>(<span style="color:#d02d21">"%s = input.FieldData['%s']"</span> % (fieldName, fieldName))</p><p style="margin:0.0px 0.0px 0.0px 0.0px;font:11.0px Menlo">
<br></p><p style="margin:0.0px 0.0px 0.0px 0.0px;font:11.0px Menlo"><br></p></div></div><div>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.</div>
<div><br></div><div>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….</div>
<div><br></div><div>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!</div><div class="im"><div><br></div><div>Thanks,</div><div>Josh</div><div><br></div>
<div><div><div><div><img src="cid:EB0C5404-ED0E-490D-8316-47EB9D05F855" type="image/png"></div></div><div>Joshua J. Murphy</div><div>Computer Scientist</div><div>Laboratory for Atmospheric and Space Physics</div><div>University of Colorado, Boulder</div>
<div><br></div></div></div><div><br></div><div><br></div></div><span><div style="border-right:medium none;padding-right:0in;padding-left:0in;padding-top:3pt;text-align:left;font-size:11pt;border-bottom:medium none;font-family:Calibri;border-top:#b5c4df 1pt solid;padding-bottom:0in;border-left:medium none">
<span style="font-weight:bold">From: </span> Sebastien Jourdain <<a href="mailto:sebastien.jourdain@kitware.com" target="_blank">sebastien.jourdain@kitware.com</a>><br><span style="font-weight:bold">Date: </span> Friday, October 19, 2012 5:46 PM<div>
<div class="h5"><br><span style="font-weight:bold">To: </span> Joshua Murphy <<a href="mailto:Joshua.Murphy@lasp.colorado.edu" target="_blank">Joshua.Murphy@lasp.colorado.edu</a>><br><span style="font-weight:bold">Cc: </span> "<a href="mailto:paraview-developers@paraview.org" target="_blank">paraview-developers@paraview.org</a>" <<a href="mailto:paraview-developers@paraview.org" target="_blank">paraview-developers@paraview.org</a>><br>
<span style="font-weight:bold">Subject: </span> Re: [Paraview-developers] AnnotateGlobalData filter does not work with string arrays<br></div></div></div><div><div class="h5"><div><br></div><div><div>
I guess the solution here is to remove the spaces for the field name and capitalize the letter next to it if needed.
<div>This logic is to ease the syntax, otherwise, you will have to refer to your field like that</div><div><br></div><div>> <span style="color:rgb(208,45,33);font-family:Menlo;font-size:11px">input.FieldData['Your field name with space']</span></div>
<div><br></div><div><div>I guess it was a bad assumption on my end to suppose the field name won't have space in it. ;-)</div><div><br></div><div>Seb</div><div><br></div><div><br><div class="gmail_quote">On Fri, Oct 19, 2012 at 5:32 PM, Joshua Murphy <span dir="ltr">
<<a href="mailto:Joshua.Murphy@lasp.colorado.edu" target="_blank">Joshua.Murphy@lasp.colorado.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="font-family:Calibri,sans-serif;word-wrap:break-word"><div style="font-size:14px">Hello all,</div><div style="font-size:14px"><br></div><div style="font-size:14px">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.</div>
<div style="font-size:14px"><br></div><div style="font-size:14px">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.</div><div style="font-size:14px">
<br></div><div style="font-size:14px"><p style="margin:0.0px 0.0px 0.0px 0.0px;font:11.0px Menlo"> <span style="color:#b933a1">for</span> index
<span style="color:#b933a1">in</span> xrange(numberOfFields):</p><p style="margin:0.0px 0.0px 0.0px 0.0px;font:11.0px Menlo"> fieldName = input.GetFieldData().GetAbstractArray(index).GetName()</p><p style="margin:0.0px 0.0px 0.0px 0.0px;font:11.0px Menlo">
<span style="color:#b933a1">
exec</span>(<span style="color:#d02d21">"%s = input.FieldData['%s']"</span> % (fieldName, fieldName))</p></div><div style="font-size:14px"><br></div><div style="font-size:14px">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:</div>
<div style="font-size:14px"><br></div><div><div><p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><span style="font-family:Courier;color:rgb(128,0,0);font-size:12px">Traceback (most recent call last):</span></p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><span style="font-family:Courier;color:rgb(128,0,0);font-size:12px">File "<string>", line 5, in <module></span></p>
</div><p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><span style="font-family:Courier;color:rgb(128,0,0);font-size:12px">File "/Volumes/Data/Development/paraview_git/build/lib/site-packages/paraview/annotation.py", line 45, in ComputeAnnotation</span></p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><span style="font-family:Courier;color:rgb(128,0,0);font-size:12px">exec("%s = input.FieldData['%s']" % (fieldName, fieldName))</span></p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><span style="font-family:Courier;color:rgb(128,0,0);font-size:12px">File "<string>", line 1</span></p><p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">
<span style="font-family:Courier;color:rgb(128,0,0);font-size:12px">Physical Time = input.FieldData['Physical Time']</span></p><p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">
<span style="font-family:Courier;color:rgb(128,0,0);font-size:12px">^</span></p><p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><span style="font-family:Courier;color:rgb(128,0,0);font-size:12px">SyntaxError: invalid syntax</span></p>
</div><div style="font-size:14px"><br></div><div style="font-size:14px">As it is obviously not possible to assign Physical Time a value.</div><div style="font-size:14px"><br></div><div style="font-size:14px">As was noted in last email, it was necessary to change "GetArray" to "GetAbstractArray" in order for this to work with strings.</div>
<div style="font-size:14px"><br></div><div style="font-size:14px">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?</div>
<div><div style="font-size:14px"><br></div><div style="font-size:14px">Thanks,</div><div style="font-size:14px">Josh</div><div style="font-size:14px"><br></div><div style="font-size:14px"><div><div><div><img src="cid:C7A30C8E-90D5-4596-991B-DF23E382F518" type="image/png"></div>
</div><div>Joshua J. Murphy</div><div>Computer Scientist</div><div>Laboratory for Atmospheric and Space Physics</div><div>University of Colorado, Boulder</div><div><br></div></div></div><div style="font-size:14px"><br></div>
</div><span style="font-size:14px"><div style="border-right:medium none;padding-right:0in;padding-left:0in;padding-top:3pt;text-align:left;font-size:11pt;border-bottom:medium none;font-family:Calibri;border-top:#b5c4df 1pt solid;padding-bottom:0in;border-left:medium none">
<span style="font-weight:bold">From: </span>Sebastien Jourdain <<a href="mailto:sebastien.jourdain@kitware.com" target="_blank">sebastien.jourdain@kitware.com</a>><br><span style="font-weight:bold">Date: </span>Friday, October 19, 2012 11:55 AM<br>
<span style="font-weight:bold">To: </span>Joshua Murphy <<a href="mailto:Joshua.Murphy@lasp.colorado.edu" target="_blank">Joshua.Murphy@lasp.colorado.edu</a>><br><span style="font-weight:bold">Cc: </span>"<a href="mailto:paraview-developers@paraview.org" target="_blank">paraview-developers@paraview.org</a>" <<a href="mailto:paraview-developers@paraview.org" target="_blank">paraview-developers@paraview.org</a>><br>
<span style="font-weight:bold">Subject: </span>Re: [Paraview-developers] AnnotateGlobalData filter does not work with string arrays<br></div><div><div><div><br></div><div><div>ParaView/src/Wrapping/Python/paraview/annotation.py
<div><br></div><div>Let me know if that works in all the case and I could push the fix on the main repo...<br><br><div class="gmail_quote">On Fri, Oct 19, 2012 at 1:39 PM, Joshua Murphy <span dir="ltr">
<<a href="mailto:Joshua.Murphy@lasp.colorado.edu" target="_blank">Joshua.Murphy@lasp.colorado.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word"><div style="font-size:14px;font-family:Calibri,sans-serif">Hello,</div><div style="font-size:14px;font-family:Calibri,sans-serif"><br></div><div style="font-size:14px;font-family:Calibri,sans-serif">
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.</div><div style="font-size:14px;font-family:Calibri,sans-serif">
<br></div><div style="font-size:14px;font-family:Calibri,sans-serif">The error being generated is:</div><div style="font-size:14px;font-family:Calibri,sans-serif"><br></div><div><p style="margin-right:0px;text-indent:0px;font-size:14px;margin-left:0px;margin-bottom:0px;font-family:Calibri,sans-serif;margin-top:0px">
<span style="font-family:'Courier';font-size:13pt;color:#800000">Traceback (most recent call last):</span></p><p style="margin-right:0px;text-indent:0px;font-size:14px;margin-left:0px;margin-bottom:0px;font-family:Calibri,sans-serif;margin-top:0px">
<span style="font-family:'Courier';font-size:13pt;color:#800000">File "<string>", line 5, in <module></span></p><p style="margin-right:0px;text-indent:0px;font-size:14px;margin-left:0px;margin-bottom:0px;font-family:Calibri,sans-serif;margin-top:0px">
<span style="font-family:'Courier';font-size:13pt;color:#800000">File "/Users/jomu9721/Data/Development/paraview_git/build/lib/site-packages/paraview/annotation.py", line 44, in ComputeAnnotation</span></p>
<p style="margin-right:0px;text-indent:0px;font-size:14px;margin-left:0px;margin-bottom:0px;font-family:Calibri,sans-serif;margin-top:0px"><span style="font-family:'Courier';font-size:13pt;color:#800000">fieldName = input.GetFieldData().GetArray(index).GetName()</span></p>
<p style="margin-right:0px;text-indent:0px;font-size:14px;margin-left:0px;margin-bottom:0px;font-family:Calibri,sans-serif;margin-top:0px"><span style="font-family:'Courier';font-size:13pt;color:#800000">AttributeError: 'NoneType' object has no attribute 'GetName'</span></p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px;font-family:Courier;font-size:13pt;color:rgb(128,0,0)"><br></p><p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">
<font face="Calibri,sans-serif"><span style="white-space:normal">Trough a query to the general paraview mailing list, I was able to ascertain that proper call would be:</span></font></p><p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">
<font face="Calibri,sans-serif"><span style="white-space:normal"><br></span></font></p><p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><span style="color:rgb(128,0,0);font-family:Courier;font-size:17px">fieldName = input.GetFieldData().GetAbstractArray(index).GetName()</span></p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><span style="color:rgb(128,0,0);font-family:Courier;font-size:17px"><br></span></p><p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">
<font face="Calibri,sans-serif"><span style="white-space:normal">Is there an easy way I can fix this? Can someone point me to where in the source tree this filter is defined?</span></font></p><p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">
<font face="Calibri,sans-serif"><span style="white-space:normal"><br></span></font></p><p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><font face="Calibri,sans-serif"><span style="white-space:normal">Thanks,</span></font></p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><font face="Calibri,sans-serif"><span style="white-space:normal">Josh</span></font></p><p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">
<font face="Calibri,sans-serif"><span style="white-space:normal"><br></span></font></p><p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><font face="Calibri,sans-serif"><span style="white-space:normal"></span></font></p>
<div><div><div><font face="Calibri,sans-serif"><img src="cid:D6616F45-18FE-4B95-9378-CE5F535EDC54" type="image/png"></font></div></div><div><font face="Calibri,sans-serif">Joshua J. Murphy</font></div><div><font face="Calibri,sans-serif">Computer Scientist</font></div>
<div><font face="Calibri,sans-serif">Laboratory for Atmospheric and Space Physics</font></div><div><font face="Calibri,sans-serif">University of Colorado, Boulder</font></div><div><font face="Calibri,sans-serif"><br></font></div>
</div><p></p></div></div><br>_______________________________________________<br>
Paraview-developers mailing list<br><a href="mailto:Paraview-developers@paraview.org" target="_blank">Paraview-developers@paraview.org</a><br><a href="http://public.kitware.com/mailman/listinfo/paraview-developers" target="_blank">http://public.kitware.com/mailman/listinfo/paraview-developers</a><br>
<br></blockquote></div><br></div></div></div></div></div></span></div></blockquote></div><br></div></div></div></div></div></div></span></div>
</blockquote></div><br></div>