0

dyntools 33.12 error

I've created a piece of code that extracts results from all .out files in a directory. I have been using it with no issues in 33.7 but with the new version of 33.12 I am trying to get the code updated but I am seeing the following issue:

ine 398, in <module> shorttitle, chanid, chandata = MyChannel.getdata(channels=[], outfile = FaultName) File ".\dyntools.py", line 1483, in getdata KeyError: u'Faultp4_delay.out'

I have updated for the new dyntools but I am still getting the issue. My code is below

MyChannel = dyntools.CHNF(FaultName,outvrsn='0')

shorttitle, chanid, chandata = MyChannel.getdata(channels=[], outfile = FaultName)

Is there anything obvious I am doing incorrectly?

anonymous user
asked 2020-03-26 12:12:45 -0500
edit flag offensive 0 remove flag close merge delete

Comments

Try.. MyChannel = dyntools.CHNF(FaultName) shorttitle, chanid, chandata = MyChannel.get_data()

Carlos G's avatar Carlos G (2020-04-03 11:56:54 -0500) edit
add a comment see more comments

1 Answer

0

var outvrsn takes an INT. Enter 0 for old out format, 1 for new outx format.

The code below runs on PSSe33, it will extract data to excel, plot using matplotlib and then save to a pdf:

import matplotlib.pyplot as plt
import psse33
import dyntools

#user data
outfile = r"""outs\Bus152_6cycles.out"""
chan = 3
#data extraction from OUT file
chnfobj = dyntools.CHNF(outfile,outvrsn=0)
short_title, chanid, chandata = chnfobj.get_data()
#export
XLSfile = 'channels.xls'
chnfobj.xlsout(channels=[chan,],outfile=outfile,
               xlsfile=XLSfile,show=False)
#plotting
label0= chanid[chan].split()[0]
label = chanid[chan]
x = chandata['time']
y = chandata[chan]
plt.plot(x,y,label=label)
plt.grid()
plt.xlabel("Time")
plt.ylabel(label0)
plt.legend()
plt.show()
#save to pdf
plt.savefig(r"""%s_chan%s.pdf"""%(label0,chan))
jconto's avatar
2.9k
jconto
answered 2020-03-26 14:19:00 -0500, updated 2020-03-27 09:20:49 -0500
edit flag offensive 0 remove flag delete link

Comments

This is the only dyntools functions in use for the code. The rest is just math functions but for some reason it thinks there is a key error when it pulls the first file name in on the second line.

alex_me's avatar alex_me (2020-03-27 05:52:28 -0500) edit

See example above.

jconto's avatar jconto (2020-03-27 09:21:10 -0500) edit

I face problem while importing matplotlib.pyplot. I am using python2.7. Tried installing using pip but error pops up. Help please. Can I also create the above file for multiple channel plot?

brownkid's avatar brownkid (2022-05-10 20:57:34 -0500) edit
add a comment see more comments

Your Answer

Login/Signup to Answer