Ask Your Question
0

dyntools 33.12 error

asked 2020-03-26 12:12:45 -0500

anonymous user

Anonymous

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?

edit retag flag offensive close merge delete

Comments

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

Carlos G gravatar imageCarlos G ( 2020-04-03 11:56:54 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2020-03-26 14:19:00 -0500

jconto gravatar image

updated 2020-03-27 09:20:49 -0500

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))
edit flag offensive delete link more

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 gravatar imagealex_me ( 2020-03-27 05:52:28 -0500 )edit

See example above.

jconto gravatar imagejconto ( 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 gravatar imagebrownkid ( 2022-05-10 20:57:34 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

[hide preview]

Question Tools

1 follower

Stats

Asked: 2020-03-26 12:12:45 -0500

Seen: 836 times

Last updated: Mar 27 '20