# Plotting .out of PSSEv32 with python 2.5 code

Hi everybody,

I'm doing so quite lot of tests and simulations withs PSSE v32 and I'm using python 2.5 for that.

As I'm doing lot of testing and simulations with a python code and PSSE v32, everytime I finish a simulation I have to go to PSSPLT program and open de .out file to see and evaluate the results.

I would like be able to plot some channels automatically from python code, instead to use PSSPLT and I found that I have to use dyntools. But I don't know how to used properly, somebody can help me with that?.

Also I would like to know if matploit can be use with python 2.5 I think is another way to plot do it but as I read works only for recent versions of python and not with 2.5.

edit retag close merge delete

Sort by » oldest newest most voted

First let me start by saying that PSSPLT is the worst tool of plotting anything in recorded human history.

I have a simple python code to plot a single channel from an out/outx file. It can be modified to plot any number of channels. However, it is working with PSSE33 and python27. I tried to use matplotlib with python25 but couldn't. I would recommend you install PSSE33 or 34 and run this python file. Don't worry you wont need to repeat your simulations as you can plot any out file from any PSSE version. Also with PSSE 33 and 34 you can always use PSSE's plotting GUI which is very stable and actually quite descent.

import os
import sys

PSSEdir = str('C:\Program Files (x86)\PTI\PSSE33') # Determine PSSE Path By Default : C:\Program Files\PTI\PSSE33
PSSEbinDir = os.path.join(PSSEdir,'PSSBIN')
os.environ['PATH'] = PSSEbinDir + ';' + os.environ['PATH']
sys.path.insert(0,PSSEbinDir) # Add [ C:\Program Files (x86)\PTI\PSSE33\PSSBIN ] to Python Lib Path

import redirect
redirect.psse2py()
import psspy
import dyntools
psspy.throwPsseExceptions = True

import matplotlib.pyplot as plt

outfile = r"""outfile location"""
chnfobj = dyntools.CHNF(outfile)
short_title, chanid, chandata = chnfobj.get_data()

print short_title
print chanid
print chandata

t = chandata['time']
f = chandata[1]
v = chandata[2]

fig = plt.figure()
fig.patch.set_facecolor('0.8')
ax1 = plt.subplot2grid((1,1),(0,0))
ax1.plot(t,v,'g-', linewidth=1,label="Voltage")
axes = plt.gca()
plt.grid(linestyle='--', color='grey',linewidth=0.5,which='both')
plt.xlabel("Time")
plt.ylabel("Volt")
plt.title("\nVoltage\n")
plt.legend()
axes.set_facecolor('w')
axes.set_ylim([0.6,1.2],)
axes.set_xlim([0,10])
plt.savefig(r"""C:\Users\XXX\Desktop\Voltage.pdf""",dpi=fig.dpi,facecolor='0.8')

more