Ask Your Question
0

Dyntools import

asked 2024-07-21 11:23:24 -0500

lonely_coder gravatar image

Hi all,

I am just starting out with PSSE and Python. I did dynamic simulation and created a number of OUT files that I want to export to Excel. I am aware of Dyntools and have found numerous examples on this website. However, if I try to import dyntools or try to run any of the python files from the EXAMPLE directory, I get an error:

ImportError: bad magic number in 'dyntools': b'\x03\xf3\r\n'

I use PSSE 34.3.0 and have Python 2.7 and Python 3.11 installed. I though it is related to the wrong environment hence I have installed "virtualenv" in Python and used "virtualenv -p c:\Python27\python.exe venv" to change to 2.7 environment, but I am still getting the same error.

Any ides what is wrong?

Thanks

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2024-07-21 20:22:36 -0500

YKC gravatar image

Hi, I would like to check first: You want to import dyntools in python, right? If so, you could add the following code in yours.

#import psse system
PSSE_LOCATION = r"C:\\Program Files (x86)\\PTI\\PSSE34\\PSSPY27"
sys.path.append(PSSE_LOCATION)
os.environ['PATH'] = os.environ['PATH'] + ';' +  PSSE_LOCATION 
import psse34
import psspihist, psspy, dyntools, redirect
_i = psspy.getdefaultint()
_f = psspy.getdefaultreal()
_s = psspy.getdefaultchar()
redirect.psse2py()
psspy.psseinit(100000000)

Also in case you need code to export out file to excel file, you could follow the code below and adjust to yours version. filename have to name as the same as your out file, and channels depend on which data you want to export, and also remind you that my code is export to csv file.

#convert out file to csv file, and choose all channels to export
output_obj = dyntools.CHNF(filename + '.out')
output_obj.csvout(channels=[1,2,3])
edit flag offensive delete link more

Comments

Thank you. I managed to resolve the issue listed above. It was actually related to using the Python 3.4 and then finding modules that are compatible with it (numpy, matplotlib, etc.). However, once I now run your script, I get and error: AttributeError: 'CHNF' object has no attribute 'csvout'

lonely_coder gravatar imagelonely_coder ( 2024-07-22 06:14:01 -0500 )edit

I run the code in PSS/E v34.4.0 with py 2.7

YKC gravatar imageYKC ( 2024-07-22 07:25:01 -0500 )edit

I resolve it and managed to export to TXT. Have used "chnfobj.txtout" instead of "chnfobj.csvout". Thank you.

lonely_coder gravatar imagelonely_coder ( 2024-07-22 08:06:12 -0500 )edit

Glad to hear you solve the problem!!

YKC gravatar imageYKC ( 2024-07-23 01:58:46 -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: 2024-07-21 11:23:24 -0500

Seen: 233 times

Last updated: Jul 21