First time here? We are a friendly community of Power Systems Engineers. Check out the FAQ!

Ask Your Question
0

Automatic export from OUT to PDF

asked May 14 '15

Cao Huy gravatar image

Hi, folks,

I am trying to export PDF from OUT file, automatically. Everything works well, ecxept the pssplot.dragdropplotdata command. It seems the command didn't drop any thing in the plot window, which it's supposed to do.

Below here is my piece of code:

#Import from xls
import xlrd 
import os,sys
import pssplot
dir = '''D:\Huy\Test3\\'''
xls_file = dir+'Multiple_CCT.xls'       # xlsx is not acceptable
wb = xlrd.open_workbook(xls_file) 
sh = wb.sheet_by_index(0)
nr = sh.nrows 
pssplot.newplotbook()
for num in range(1,nr):
    #Read from Xls
    OUT= dir+str(int(sh.row_values(num)[0]))+"-"+ str(int(sh.row_values(num)[1]))+"-CCT0.0800s.out"
    NAME=str(int(sh.row_values(num)[0]))+"-"+ str(int(sh.row_values(num)[1]))+"-CCT0.0800s"
    pssplot.openchandatafile(OUT)
    pssplot.dragdropplotdata(NAME,r"""1 - ANGL 35201[G1 220.00]1""")
    pssplot.dragdropplotdata(NAME,r"""2 - ANGL 49502[G2 500.00]1""")
    pssplot.dragdropplotdata(NAME,r"""3 - ANGL 60501[G3 500.00]1""")
    pssplot.exportplot(dir+NAME+"_ANGLE.pdf",4)

3 answers

Sort by » oldest newest most voted
0

answered May 25 '0

jfconroy gravatar image

I think a better approach is the following. 1) Get the data into Python from the *.out or *.outx file using the

dyntools.CHNF(outfilename)

command. 2) Use matplotlib to do the plots, which is much more flexible and has much more options than pssplot. 3) Save your graph as a pdf using matplotlib.

link
0

answered May 17 '15

jconto gravatar image

updated May 20 '0

I run within the PSSe GUI, v33, a similar code for a single plot and it did created the pdf as well as it showed the plot on the plot window.
My out file was 'GOP1.out' and my NAME variable was 'GOP1'. Also I made sure that the channel name exists in the OUT file.

The file plot1.zip stored at my Google drive public site contains the plot1.py script. Before run it in the PSSe GUI, update filenames and other variables for your case.

A better way to plot to pdf is with "channels", also stored at the same site.

link

Comments

I have applied the code recorded from PSSE but it the dragdrop command just doesn't work and I don't know why. Also, I have reinstall PSSE, but the problem remain still. :(

Cao Huy gravatar imageCao Huy (May 18 '15)

Test the code I used. Check my updated answer.

jconto gravatar imagejconto (May 19 '15)

Just throwing this out there, but sometimes the things act strange if you have too many out files open at once, or out files of the same name. Also there is really limited error output if your out file/channel strings are wrong. Does recording with a new PSSE window and only one out file work OK?

cajief gravatar imagecajief (May 19 '15)

Sorry for my late reply. I have another project needed to be finished recently. Thank for your reply.

Cao Huy gravatar imageCao Huy (May 27 '15)

@calief:: I afaird that's not the problem, cause I've tried recording and executing with only one file.

Cao Huy gravatar imageCao Huy (May 27 '15)
0

answered May 19 '0

Hazim gravatar image

Hi sir, i cant access your link fakepath\plot.py.gif. please help me sir

link

Comments

I updated the link!

jconto gravatar imagejconto (May 20 '0)

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.
Want to format code in your answer? Here is a one minute demo on Youtube

Add Answer

[hide preview]

Question Tools

Stats

Asked: May 14 '15

Seen: 2,153 times

Last updated: May 25 '20