[Paraview] Plot over line CSV export python script not working
Andy Bauer
andy.bauer at kitware.com
Mon Oct 3 10:17:30 EDT 2011
I'm glad it's working for you.
I'm not sure who is responsible for building the paraview binaries for the
ubuntu repos. I know some maintainers have contacted us in the past about
properly doing this for certain installations and we are more than happy to
help. If you have the energy to contact the people for ubuntu we can help
get it properly done.
Andy
On Sun, Oct 2, 2011 at 11:46 PM, Luca Giannelli <bilogo at gmail.com> wrote:
> Thank you very much Andy,
> with your precious help I have been able to find out a working solution for
> what I need.
>
> I foud out the the original script is completly functional without any
> modification....
> the only BIG ISSUE was the the Paraview binaries provided by the Ubuntu
> Repositories
> do not provide all the needed python scripts for the execution of a perfect
> python environment
> in Paraview. I would like to notify this to the mantainers of the repos.
> So, the workaround was this easy! I just installed Paraview from the latest
> source and got
> the thing running.
>
> However I found another problem relatet of course to the execution of the
> pipeline due to
> the missing active source, just as you suggested in you mail. That was
> easier to solve.
> So I ended up with a working script I want to share with all those people
> that may need it.
> I'll send an heavily commented version with a dedicated email. Here is a
> snippet just to let you
> see how i did.
> Thank you very much for your time!
>
> Luca
>
> ------------------ CODE-------------------
>
> try: paraview.simple
> except: from paraview.simple import *
> paraview.simple._DisableFirstRenderCameraReset()
>
> fotobioreattore_foam = FindSource("fotobioreattore.foam")
> SetActiveSource(fotobioreattore_foam)
>
> PlotOverLine2 = PlotOverLine( Source="High Resolution Line Source" )
> DataRepresentation7 = Show()
>
> PlotOverLine2.Source.Point1 = [0.0, 0.0, 0.0]
> PlotOverLine2.Source.Point2 = [0.0, 0.0, 0.43]
>
> Render()
>
> source = PlotOverLine2
> writer = CreateWriter("YOUR_FILE_NAME_GOES_HERE.csv", source)
> writer.FieldAssociation = "Points" # or "Cells"
> writer.UpdatePipeline()
> del writer
>
> -------------------------------------------
>
> 2011/9/30 Andy Bauer <andy.bauer at kitware.com>
>
>> I think the first problem is that there isn't an active source. The
>> GetActiveSource() is returning None and when you create subsequent filters
>> that automatically connect to the active source it causes problems when you
>> try to execute the pipeline. Something along the lines of below should get
>> you closer:
>> =========
>>
>> try: paraview.simple
>> except: from paraview.simple import *
>> paraview.simple._DisableFirstRenderCameraReset()
>>
>> Wavelet()
>> p = PlotOverLine()
>> p.Source.Point1 = [-.5, -5., -5.]
>> p.Source.Point2 = [.5, 5., 5.]
>> w = CSVWriter()
>> w.FileName = "/home/piota/csv.csv"
>> w.UpdatePipeline()
>> =========
>>
>> The problem here is that the output of PlotOverLine is a polydata and the
>> writer is expecting a vtkTable. I'm not sure how to convert between the
>> two. Maybe someone else can help you with that.
>>
>> The 2 things I'd try at this point are either creating my own writer using
>> the python programmable filter or writing out a polydata file and parsing
>> that for the information that you need. The first one is probably the
>> better choice of the two.
>>
>> Andy
>>
>>
>>
>> On Fri, Sep 30, 2011 at 12:47 AM, Luca Giannelli <bilogo at gmail.com>wrote:
>>
>>> Ok,
>>>
>>> I moved on a little..... Reading the output of the error reported in the
>>> previous mail, it says that it cannot find "XArrayName". Looking the
>>> original script you can see that it is needed for the definition of the plot
>>> area properties in the GUI.... I don't need it as I only want a csv file, so
>>> I commented out everything in that section. Running the script again it now
>>> complains about being unable to find "CreateWriter". I need this to
>>> write the csv file so this error becomes fatal.
>>> As this function should be included in the paraview.simple that I load at
>>> the beginning of the script (like explained in the manual), what I did was
>>> to go through all the functions in the simple.py file to locate it. Without
>>> any succes..... Then I went on with the brute-force approach and lauched:
>>>
>>> grep -H -r "CreateWriter" /usr
>>>
>>> Binary file /usr/lib/paraview/libvtkPVFilters.so matches
>>>
>>> Binary file /usr/lib/paraview/libvtkPVServerManager.so matches
>>>
>>> Binary file /usr/lib/paraview/libvtkIO.so.pv3.8 matches
>>>
>>> Binary file /usr/lib/paraview/libvtkPVServerManagerPythonD.so matches
>>>
>>> Binary file /usr/lib/paraview/libpqApplicationComponents.so matches
>>>
>>> Binary file /usr/lib/paraview/libvtkIO.so matches
>>>
>>>
>>> Unfortunately they are all bin files and not py...
>>>
>>> I'm starting to believe that I'm really missing something here.....
>>>
>>> Any idea?
>>>
>>>
>>> Thx!!!
>>>
>>>
>>> Luca
>>>
>>>
>>> 2011/9/30 Luca Giannelli <bilogo at gmail.com>
>>>
>>>> Andy,
>>>>
>>>> thank you for your quick reply.
>>>>
>>>> I am using Paraview 3.8.0 which is the latest binary in the Ubuntu
>>>> repos. I chose to install that without compiling from source as I was
>>>> rushing (I know, it sounds weird... but). Do you believe that the problem is
>>>> build-related?
>>>>
>>>> However, reading the errors that you get I don't see anything that I can
>>>> visualize in my output which is as follows (Python shell)
>>>>
>>>> Traceback (most recent call last):
>>>>
>>>> File "/usr/lib/paraview/site-packages/paraview/servermanager.py", line
>>>> 2922, in _proxyDefinitionsUpdated
>>>>
>>>> if vtkSMObject.GetProxyManager().GetProxyDefinitionsUpdated():
>>>>
>>>> AttributeError: GetProxyDefinitionsUpdated
>>>>
>>>> Traceback (most recent call last):
>>>>
>>>> File "/usr/lib/paraview/site-packages/paraview/servermanager.py", line
>>>> 2922, in _proxyDefinitionsUpdated
>>>>
>>>> if vtkSMObject.GetProxyManager().GetProxyDefinitionsUpdated():
>>>>
>>>> AttributeError: GetProxyDefinitionsUpdated
>>>>
>>>> Traceback (most recent call last):
>>>>
>>>> File "/usr/lib/paraview/site-packages/paraview/servermanager.py", line
>>>> 2922, in _proxyDefinitionsUpdated
>>>>
>>>> if vtkSMObject.GetProxyManager().GetProxyDefinitionsUpdated():
>>>>
>>>> AttributeError: GetProxyDefinitionsUpdated
>>>>
>>>> Traceback (most recent call last):
>>>>
>>>> File "/usr/lib/paraview/site-packages/paraview/servermanager.py", line
>>>> 2922, in _proxyDefinitionsUpdated
>>>>
>>>> if vtkSMObject.GetProxyManager().GetProxyDefinitionsUpdated():
>>>>
>>>> AttributeError: GetProxyDefinitionsUpdated
>>>>
>>>> Traceback (most recent call last):
>>>>
>>>> File "<string>", line 17, in <module>
>>>>
>>>> File "/usr/lib/paraview/site-packages/paraview/servermanager.py", line
>>>> 201, in __setattr__
>>>>
>>>> "to add this attribute.")
>>>>
>>>> AttributeError: Attribute XArrayName does not exist. This class does not
>>>> allow addition of new attributes to avoid mistakes due to typos. Use
>>>> add_attribute() if you really want to add this attribute.
>>>>
>>>>
>>>> It looks like a complain about the server, not about my script
>>>> though.... in fact, if comment out the writer part, leaving only the "trace"
>>>> recorded set of operations, it spits out the very same error. Moreover, the
>>>> Paraview output doesn't show any output at all (except for the usual a
>>>> complain about the qt4 that is not related).
>>>>
>>>> Do you see any evident problem in the script syntax in the writer
>>>> section? For example references to the wrong source, etc?
>>>>
>>>> Or do you believe that it is a problem related to the Paraview/Python
>>>> installation (or whatever..).
>>>>
>>>>
>>>> Another point.... does the "PlotOverLine2" influence the results? I
>>>> recorded the trace making a second POL that automatically got labeled as
>>>> #2... if I run it at startup it executes perfectly fine so I don't think
>>>> that the problem is here too.
>>>>
>>>>
>>>> I'm sorry for my pretty low level in Python as I am an absolute beginner
>>>>
>>>>
>>>> Thanks again
>>>>
>>>>
>>>> Luca
>>>>
>>>> 2011/9/29 Andy Bauer <andy.bauer at kitware.com>
>>>>
>>>>> If you're running the python script in the paraview gui sometimes the
>>>>> messages are printed out to the python shell. What version of paraview are
>>>>> you using?
>>>>>
>>>>> I'm running paraview from the head of the repo. The output I get from
>>>>> the OutputMessages window is:
>>>>> ================
>>>>>
>>>>> ERROR: In
>>>>> /home/acbauer/CODE/ParaView/ParaView/VTK/Filtering/vtkDemandDrivenPipeline.cxx,
>>>>> line 727
>>>>>
>>>>> vtkPVCompositeDataPipeline (0x493bbd0): Input port 1 of algorithm
>>>>> vtkPProbeFilter(0x493dab0) has 0 connections but is not optional.
>>>>>
>>>>> ERROR: In
>>>>> /home/acbauer/CODE/ParaView/ParaView/VTK/Filtering/vtkDemandDrivenPipeline.cxx,
>>>>> line 727
>>>>>
>>>>> vtkPVCompositeDataPipeline (0x493bbd0): Input port 1 of algorithm
>>>>> vtkPProbeFilter(0x493dab0) has 0 connections but is not optional.
>>>>>
>>>>> ERROR: In
>>>>> /home/acbauer/CODE/ParaView/ParaView/VTK/Filtering/vtkDemandDrivenPipeline.cxx,
>>>>> line 727
>>>>>
>>>>> vtkPVCompositeDataPipeline (0x493bbd0): Input port 1 of algorithm
>>>>> vtkPProbeFilter(0x493dab0) has 0 connections but is not optional.
>>>>>
>>>>> ERROR: In
>>>>> /home/acbauer/CODE/ParaView/ParaView/VTK/Filtering/vtkDemandDrivenPipeline.cxx,
>>>>> line 727
>>>>>
>>>>> vtkPVCompositeDataPipeline (0x493bbd0): Input port 1 of algorithm
>>>>> vtkPProbeFilter(0x493dab0) has 0 connections but is not optional.
>>>>>
>>>>> ERROR: In
>>>>> /home/acbauer/CODE/ParaView/ParaView/VTK/Filtering/vtkDemandDrivenPipeline.cxx,
>>>>> line 727
>>>>>
>>>>> vtkPVCompositeDataPipeline (0x493bbd0): Input port 1 of algorithm
>>>>> vtkPProbeFilter(0x493dab0) has 0 connections but is not optional.
>>>>>
>>>>> ERROR: In
>>>>> /home/acbauer/CODE/ParaView/ParaView/VTK/Filtering/vtkDemandDrivenPipeline.cxx,
>>>>> line 727
>>>>>
>>>>> vtkPVCompositeDataPipeline (0x493bbd0): Input port 1 of algorithm
>>>>> vtkPProbeFilter(0x493dab0) has 0 connections but is not optional.
>>>>>
>>>>> ERROR: In
>>>>> /home/acbauer/CODE/ParaView/ParaView/VTK/Filtering/vtkDemandDrivenPipeline.cxx,
>>>>> line 727
>>>>>
>>>>> vtkPVCompositeDataPipeline (0x493bbd0): Input port 1 of algorithm
>>>>> vtkPProbeFilter(0x493dab0) has 0 connections but is not optional.
>>>>>
>>>>> ERROR: In
>>>>> /home/acbauer/CODE/ParaView/ParaView/VTK/Filtering/vtkDemandDrivenPipeline.cxx,
>>>>> line 727
>>>>>
>>>>> vtkPVCompositeDataPipeline (0x493bbd0): Input port 1 of algorithm
>>>>> vtkPProbeFilter(0x493dab0) has 0 connections but is not optional.
>>>>>
>>>>> ERROR: In
>>>>> /home/acbauer/CODE/ParaView/ParaView/VTK/Filtering/vtkDemandDrivenPipeline.cxx,
>>>>> line 727
>>>>>
>>>>> vtkPVCompositeDataPipeline (0x493bbd0): Input port 1 of algorithm
>>>>> vtkPProbeFilter(0x493dab0) has 0 connections but is not optional.
>>>>>
>>>>> ERROR: In
>>>>> /home/acbauer/CODE/ParaView/ParaView/VTK/Filtering/vtkDemandDrivenPipeline.cxx,
>>>>> line 727
>>>>>
>>>>> vtkPVCompositeDataPipeline (0x493bbd0): Input port 1 of algorithm
>>>>> vtkPProbeFilter(0x493dab0) has 0 connections but is not optional.
>>>>>
>>>>> ERROR: In
>>>>> /home/acbauer/CODE/ParaView/ParaView/VTK/Filtering/vtkDemandDrivenPipeline.cxx,
>>>>> line 727
>>>>>
>>>>> vtkPVCompositeDataPipeline (0x493bbd0): Input port 1 of algorithm
>>>>> vtkPProbeFilter(0x493dab0) has 0 connections but is not optional.
>>>>>
>>>>> ERROR: In
>>>>> /home/acbauer/CODE/ParaView/ParaView/VTK/Filtering/vtkDemandDrivenPipeline.cxx,
>>>>> line 727
>>>>>
>>>>> vtkPVCompositeDataPipeline (0x493bbd0): Input port 1 of algorithm
>>>>> vtkPProbeFilter(0x493dab0) has 0 connections but is not optional.
>>>>>
>>>>> ERROR: In
>>>>> /home/acbauer/CODE/ParaView/ParaView/VTK/Filtering/vtkDemandDrivenPipeline.cxx,
>>>>> line 727
>>>>>
>>>>> vtkPVCompositeDataPipeline (0x493bbd0): Input port 1 of algorithm
>>>>> vtkPProbeFilter(0x493dab0) has 0 connections but is not optional.
>>>>>
>>>>> ERROR: In
>>>>> /home/acbauer/CODE/ParaView/ParaView/VTK/Filtering/vtkDemandDrivenPipeline.cxx,
>>>>> line 727
>>>>>
>>>>> vtkPVCompositeDataPipeline (0x493bbd0): Input port 1 of algorithm
>>>>> vtkPProbeFilter(0x493dab0) has 0 connections but is not optional.
>>>>>
>>>>> ERROR: In
>>>>> /home/acbauer/CODE/ParaView/ParaView/VTK/Filtering/vtkDemandDrivenPipeline.cxx,
>>>>> line 727
>>>>>
>>>>> vtkPVCompositeDataPipeline (0x493bbd0): Input port 1 of algorithm
>>>>> vtkPProbeFilter(0x493dab0) has 0 connections but is not optional.
>>>>>
>>>>> ERROR: In
>>>>> /home/acbauer/CODE/ParaView/ParaView/VTK/Filtering/vtkDemandDrivenPipeline.cxx,
>>>>> line 727
>>>>>
>>>>> vtkPVCompositeDataPipeline (0x493bbd0): Input port 1 of algorithm
>>>>> vtkPProbeFilter(0x493dab0) has 0 connections but is not optional.
>>>>>
>>>>> ERROR: In
>>>>> /home/acbauer/CODE/ParaView/ParaView/VTK/Filtering/vtkDemandDrivenPipeline.cxx,
>>>>> line 727
>>>>>
>>>>> vtkPVCompositeDataPipeline (0x493bbd0): Input port 1 of algorithm
>>>>> vtkPProbeFilter(0x493dab0) has 0 connections but is not optional.
>>>>>
>>>>> ERROR: In
>>>>> /home/acbauer/CODE/ParaView/ParaView/VTK/Filtering/vtkDemandDrivenPipeline.cxx,
>>>>> line 727
>>>>>
>>>>> vtkPVCompositeDataPipeline (0x493bbd0): Input port 1 of algorithm
>>>>> vtkPProbeFilter(0x493dab0) has 0 connections but is not optional.
>>>>>
>>>>> ERROR: In
>>>>> /home/acbauer/CODE/ParaView/ParaView/VTK/Filtering/vtkDemandDrivenPipeline.cxx,
>>>>> line 727
>>>>>
>>>>> vtkPVCompositeDataPipeline (0x493bbd0): Input port 1 of algorithm
>>>>> vtkPProbeFilter(0x493dab0) has 0 connections but is not optional.
>>>>>
>>>>> ERROR: In
>>>>> /home/acbauer/CODE/ParaView/ParaView/VTK/Filtering/vtkDemandDrivenPipeline.cxx,
>>>>> line 727
>>>>>
>>>>> vtkPVCompositeDataPipeline (0x493bbd0): Input port 1 of algorithm
>>>>> vtkPProbeFilter(0x493dab0) has 0 connections but is not optional.
>>>>>
>>>>> ERROR: In
>>>>> /home/acbauer/CODE/ParaView/ParaView/VTK/Filtering/vtkDemandDrivenPipeline.cxx,
>>>>> line 727
>>>>>
>>>>> vtkPVCompositeDataPipeline (0x493bbd0): Input port 1 of algorithm
>>>>> vtkPProbeFilter(0x493dab0) has 0 connections but is not optional.
>>>>>
>>>>> Warning: In
>>>>> /home/acbauer/CODE/ParaView/ParaView/VTK/Filtering/vtkDataObject.cxx, line
>>>>> 920
>>>>>
>>>>> vtkMultiBlockDataSet (0x4da0e00): Attempted to ShallowCopy from null.
>>>>>
>>>>> Warning: In
>>>>> /home/acbauer/CODE/ParaView/ParaView/VTK/Filtering/vtkDataObject.cxx, line
>>>>> 920
>>>>>
>>>>> vtkMultiBlockDataSet (0x4da3af0): Attempted to ShallowCopy from null.
>>>>>
>>>>> ================
>>>>>
>>>>> The output I get from the python shell is:
>>>>> ===============
>>>>>
>>>>> Traceback (most recent call last):
>>>>>
>>>>> File "<string>", line 17, in <module>
>>>>>
>>>>> File
>>>>> "/media/ssddrive/BUILDS/ParaView/release-parallel/Utilities/VTKPythonWrapping/site-packages/paraview/servermanager.py",
>>>>> line 209, in __setattr__
>>>>>
>>>>> "to add this attribute.")
>>>>>
>>>>> AttributeError: Attribute XArrayName does not exist. This class does
>>>>> not allow addition of new attributes to avoid mistakes due to typos. Use
>>>>> add_attribute() if you really want to add this attribute.
>>>>>
>>>>> ======================
>>>>>
>>>>> On Thu, Sep 29, 2011 at 5:57 AM, Luca Giannelli <bilogo at gmail.com>wrote:
>>>>>
>>>>>> Hello everybody,
>>>>>>
>>>>>> I've been using Paraview for quite a long time but I didn't need the
>>>>>> python scripting up to now.
>>>>>> I want to execute a series of plot over line in numerous points and
>>>>>> different time steps so it is nothing
>>>>>> I can afford to do manually.
>>>>>> Looking on the net I was able to find out how to record a macro and
>>>>>> how to create a writer so I
>>>>>> ended up with this script:
>>>>>>
>>>>>> --------------------------------------------------------------------
>>>>>> try: paraview.simple
>>>>>> except: from paraview.simple import *
>>>>>> paraview.simple._DisableFirstRenderCameraReset()
>>>>>>
>>>>>> fotobioreattore_foam = GetActiveSource()
>>>>>> PlotOverLine2 = PlotOverLine( Source="High Resolution Line Source" )
>>>>>>
>>>>>> PlotOverLine2.Source.Point1 = [-0.035100001841783524,
>>>>>> -0.03509980067610741, 0.0]
>>>>>> PlotOverLine2.Source.Point2 = [0.035100001841783524,
>>>>>> 0.035100001841783524, 0.4300000071525574]
>>>>>>
>>>>>> DataRepresentation7 = Show()
>>>>>>
>>>>>> PlotOverLine2.Source.Point1 = [-0.0, 0.0, 0.0]
>>>>>> PlotOverLine2.Source.Point2 = [0.0, 0.0, 0.4300000071525574]
>>>>>>
>>>>>> XYChartView4 = GetRenderView()
>>>>>> DataRepresentation7.XArrayName = 'arc_length'
>>>>>> DataRepresentation7.SeriesVisibility = ['U (0)', '0', 'U (1)', '0', 'U
>>>>>> (2)', '0', 'vtkValidPointMask', '0', 'arc_length', '0', 'Points (0)', '0',
>>>>>> 'Points (1)', '0', 'Points (2)', '0', 'Points (Magnitude)', '0']
>>>>>> DataRepresentation7.UseIndexForXAxis = 0
>>>>>>
>>>>>> Render()
>>>>>>
>>>>>> #= create writer
>>>>>> source = PlotOverLine2 #PlotOverLine2.Source
>>>>>> writer = CreateWriter("/home/piota/csv.csv", source)
>>>>>> #writer = CreateWriter("/home/piota/csv.csv")
>>>>>> writer.FieldAssociation = "Points" # or "Cells"
>>>>>> writer.UpdatePipeline()
>>>>>> del writer
>>>>>>
>>>>>> --------------------------------------------------------------------------
>>>>>>
>>>>>> If I'm not mistaken, this should write a csv.csv file in my home
>>>>>> folder but it doesn't write anything. No error is reported when I run the
>>>>>> script but still I get no output.
>>>>>> I'm still a bit confused on which source I should specify, so I'm
>>>>>> pretty sure that the writer part is incorrect.
>>>>>>
>>>>>> Can somebody help me filling it out properly?
>>>>>>
>>>>>> Thx in advance.
>>>>>>
>>>>>> Luca
>>>>>>
>>>>>> _______________________________________________
>>>>>> Powered by www.kitware.com
>>>>>>
>>>>>> Visit other Kitware open-source projects at
>>>>>> http://www.kitware.com/opensource/opensource.html
>>>>>>
>>>>>> Please keep messages on-topic and check the ParaView Wiki at:
>>>>>> http://paraview.org/Wiki/ParaView
>>>>>>
>>>>>> Follow this link to subscribe/unsubscribe:
>>>>>> http://www.paraview.org/mailman/listinfo/paraview
>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.paraview.org/pipermail/paraview/attachments/20111003/5cc9ef32/attachment-0001.htm>
More information about the ParaView
mailing list