Ask Your Question

Saving .out file in Excel format

asked 2017-08-10 01:59:18 -0500

Amir90 gravatar image


I am running a dynamic simulation in python script, I want to save output channel in excel file,I used dyntools module for this application but the "outfile.csv" didn't created, actually " ch_data" doesn't have any data.I need complete answer. please help me. My code is as follow:

import os,sys
PYTHONPATH = r'C:\Program Files (x86)\PTI\PSSE32\PSSBIN'

os.environ['PATH'] += ';' + PYTHONPATH

import psspy
from psspy import _i
from psspy import _f
import redirect

# Redirect output from PSSE to Python:

# Last case:
CASE = r"C:\Users\N.JAHAN\Desktop\2015_RVS_Test_System.sav"

# Convert loads (3 step process):

# Convert generators:

# Solve for dynamics

# Save converted case
case_root = os.path.splitext(CASE)[0] + "_C.sav")

# Add dynamics data
psspy.dyre_new(dyrefile=r"C:\Users\N.JAHAN\Desktop\2015_RVS_Test_System - Copy.dyr")

# Add channels by subsystem

psspy.chsb(sid=0,all=1, status=[-1,-1,-1,1,13,0])

# Add channels individually
#   load active and reactive power

# Save snapshot
psspy.snap(sfile="C:\Program Files (x86)\PTI\PSSE32\EXAMPLE\python_test.snp")
#psspy.dynamics_solution_param_2([_i,_i,_i,_i,_i,_i,_i,_i],[_f,_f, 0.002,_f,_f,_f,_f,_f])
# Initialize
psspy.strt(outfile="C:\Program Files (x86)\PTI\PSSE32\EXAMPLE\python_test.out")

# 3-phase fault on bus 201 (default bus fault is a 3phase and there is no bus 200)

# Run to 5 cycles
time = 1+(5.0/60.0)

# Clear fault (assuming only part of bus faults)
psspy.dist_branch_trip(ibus=103, jbus=109, id='1')

# Run to 10 seconds
time = 5

import dyntools

# Run dyntools to extract the data
chnfobj = dyntools.CHNF(os.path.join('C:\Program Files (x86)\PTI\PSSE32\EXAMPLE\python_test.out', 
sh_ttl, ch_id, ch_data = chnfobj.get_data()

# Extract time as a variable
time = ch_data['time']

# Number of channels, (-1 as 'time' is represented in channel data)
count = len(ch_id) - 1

# Extract channel data
data = [ch_data[x + 1] for x in xrange(count)]
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2017-08-10 11:30:36 -0500

jconto gravatar image

To get a 'manual' about the dyntools, open a CMD (DOS window), run python and then type:

import dyntools

help (dyntools)

The CHNF function expects OUT filenames, not to declare output data filenames, change it to:

chnfobj = dyntools.CHNF('C:\Program Files (x86)\PTI\PSSE32\EXAMPLE\python_test.out')

Also, by the end of your code, define an excel filename to received data using the function dyntools.xlsout

From the 'manual':

 |      xlsfile  = chnfobj.xlsout(outfile,channels,show,xlsfile)
 |      outfile  = PSS(R)E Dynamic Simulation Channel Output File Name (.out), when not
 |                 provided, used 1st file from the files provided during object creation.
 |      channels = Channel numbers to extract, specified as a channel number or
 |                 list of channel numbers to extract.
 |                 If not specified, all channels are extracted, default.
 |      show     = True (default) - Show Excel Spreadsheet when being populated,
 |               = False - Hide
 |      xlsfile  = Data saved to this Excel File, with or without extension.
edit flag offensive delete link more

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


Asked: 2017-08-10 01:59:18 -0500

Seen: 443 times

Last updated: Aug 10 '17