CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   ParaView (https://www.cfd-online.com/Forums/paraview/)
-   -   [General] WriteImage of XYplot when script running = problem. (https://www.cfd-online.com/Forums/paraview/130164-writeimage-xyplot-when-script-running-problem.html)

be_inspired February 20, 2014 13:12

WriteImage of XYplot when script running = problem.
 
3 Attachment(s)
Hi all,

I really hope someone can help me because I have spent more than 2 days trying to solve this issue by different ways.

I am using paraview 3.10.1 64 bits over the HPC platform. In a point of the postprocess, I perform a double slice by plane over the domain to obtain a line with the data that I want. Then I want to use Plot Data to represent the velocity distribution in relation to the height.
Inside the attached script, I export the data to csv OK but the image is not correctly saved with writeImage.
But when the script has finished and then I write in the python shell the same command, the image is correctly saved.

It seems like a problem when saving images while a python script is running, but only with XYploy because for other types of images ( 3D Views), it works correctly.

Thank you very much for your help.

Best Regards

wyldckat February 22, 2014 13:44

Greetings be_inspired,

Very nice script! Many thanks for sharing!

OK, I've taken a look into the script code and my guess is that you should change this:
Code:

    DataRepresentation20.SeriesLineStyle = ['Hub', '2']
    time.sleep(5)
    Render()

    WriteImage("XY/"+f[0]+"_UxVerticalDistribution.png", view = XYChartView1)

To this:
Code:

    DataRepresentation20.SeriesLineStyle = ['Hub', '2']
    Render()
    time.sleep(5)

    WriteImage("XY/"+f[0]+"_UxVerticalDistribution.png", view = XYChartView1)

Namely to call sleep only after the render call, since it takes a little to render the data.

But without test data and a simpler test example, I'm not able to test this myself... or at least not very quickly :(

Best regards,
Bruno

be_inspired March 3, 2014 05:52

Thank you Bruno,

I have tried it without success. I have also tried the script into another linux machine ( with a graphic card) and now the output png file is all in black. I thought that maybe it could be related to the mesa graphic libraries, it seems that it is not, but now I do not know what to try.

wyldckat March 3, 2014 07:04

Hi Montero,

Like I wrote in the other post, without a simple test case, I'm not able to test this myself.

The one suggestion that does come to mind is to try and export to JPG instead of PNG. I've had some issues in the past with exporting to PNG, possibly due to a "libpng.so" conflict.

Best regards,
Bruno

be_inspired March 3, 2014 08:59

1 Attachment(s)
Here I upload a simple csv file ( remove the final txt extension).
I have the same problem when I want to execute a python script that reads the csv file, plot the U:0 versus Height ( for example) and then, that plot is saved as a screenshot with "writeimage".
If after the script has ended I execute a single python script where I have only the line of writeimage, the screenshots is correctly obtained.

Thank you for your time

New news: I have tried with WriteAnimation instead of WriteImage and now the ouput is correct but I have 1 file per time step :( . The scrip loads the time 0 and the last time, so the required time to run the script is multiplied.

O am working with PV 3.12.0 and also with PV3.10.1. May it be some type of bug with writeImage when dealing with XYplot? WriteImage for 3D Views works ok.
Other possibility is that with "writeAnimation" the view is forces to be rendered and with WriteImage is not forced and I do not know how to do it.

wyldckat March 4, 2014 11:12

The following script worked for me in ParaView 3.12.0:
Code:

from paraview.simple import *

csvtoPNG_csv = CSVReader( FileName=['/home/user/Montero/csvtoPNG.csv'] )
csvtoPNG_csv.FieldDelimiterCharacters = ';'
UpdatePipeline()
SetActiveSource(csvtoPNG_csv)

XYChartView1 = CreateXYPlotView()
XYChartView1.ViewTime = 0.0

PlotData1 = PlotData()
SetActiveSource(PlotData1)
DataRepresentation2 = Show()
DataRepresentation2.XArrayName = 'U:0'
DataRepresentation2.SeriesColor = ['U:1', '0.894118', '0.101961', '0.109804', 'U:2', '0.215686', '0.494118', '0.721569', 'Height', '0.301961', '0.686275', '0.290196']
DataRepresentation2.AttributeType = 'Row Data'
DataRepresentation2.SeriesVisibility = ['vtkOriginalIndices', '0', 'U:1', '0', 'U:2', '0', 'Height', '0']
UpdatePipeline()

AnimationScene1 = GetAnimationScene()
AnimationScene1.ViewModules = [ XYChartView1 ]
Render()

WriteImage('/home/user/Montero/test2.jpg')

Using pvpython and pvbatch also worked for me:
Code:

pvpython ./simple_test.py
pvbatch ./simple_test.py

Keep in mind that I used in the local machine, with graphical interface, not remotely.

I didn't need to use a call to "sleep()", because I believe that the trick might be to use "UpdatePipeline()", but you'll have to test this yourself, to confirm if it works properly for you as well.


All times are GMT -4. The time now is 00:09.