CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > ParaView

WriteImage of XYplot when script running = problem.

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   February 20, 2014, 14:12
Default WriteImage of XYplot when script running = problem.
  #1
Senior Member
 
M. Montero
Join Date: Mar 2009
Location: Madrid
Posts: 112
Rep Power: 8
be_inspired is on a distinguished road
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
Attached Images
File Type: jpg test_nok.jpg (11.0 KB, 6 views)
File Type: jpg test_ok.jpg (30.3 KB, 6 views)
Attached Files
File Type: txt XY_forum.txt (3.4 KB, 12 views)
be_inspired is offline   Reply With Quote

Old   February 22, 2014, 14:44
Default
  #2
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 8,301
Blog Entries: 34
Rep Power: 84
wyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nice
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
wyldckat is offline   Reply With Quote

Old   March 3, 2014, 06:52
Default
  #3
Senior Member
 
M. Montero
Join Date: Mar 2009
Location: Madrid
Posts: 112
Rep Power: 8
be_inspired is on a distinguished road
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.
be_inspired is offline   Reply With Quote

Old   March 3, 2014, 08:04
Default
  #4
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 8,301
Blog Entries: 34
Rep Power: 84
wyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nice
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
wyldckat is offline   Reply With Quote

Old   March 3, 2014, 09:59
Default
  #5
Senior Member
 
M. Montero
Join Date: Mar 2009
Location: Madrid
Posts: 112
Rep Power: 8
be_inspired is on a distinguished road
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.
Attached Files
File Type: txt csvtoPNG.csv.txt (4.7 KB, 3 views)
be_inspired is offline   Reply With Quote

Old   March 4, 2014, 12:12
Default
  #6
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 8,301
Blog Entries: 34
Rep Power: 84
wyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nice
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.
wyldckat is offline   Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Running salome-meca from a java script Iche_Bins Structural Mechanics 0 October 9, 2013 06:44
RSH problem for parallel running in CFX Nicola CFX 5 June 18, 2012 18:31
Problem running a parallel fluent job on local machine via mpd highhopes FLUENT 0 March 3, 2011 06:07
Running Matlab script from Scheme code dhimans Fluent UDF and Scheme Programming 0 July 28, 2009 15:13
Statically Compiling OpenFOAM Issues herzfeldd OpenFOAM Installation 21 January 6, 2009 10:38


All times are GMT -4. The time now is 10:24.