Ask Your Question
1

Mutual Data

asked 2013-06-02 01:58:41 -0500

PPS Newbie gravatar image

Hi experts, I wonder if there is there an API for python to retrieve the Mutual data (the data in the mutual tab) in a case ??? Thanks.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2013-06-04 00:43:27 -0500

JervisW gravatar image

There doesn't seem to be one to read the mutual data into pure Python.

There are APIs to change the mutual data:

psspy.seq_mutual_data

but nothing in the single element data retrieval or subsystem data retrieval chapters.

The closest we can get is using the sqli command which has the following signature:

psspy.sqli(sid, all, opt)

where:

sid, a subsystem id number (can be -1 to indicate all buses)

all, =1 process all buses, otherwise 
     =0 only buses in subsystem sid

opt, =1, full listing 
     =2, bus load data
     =3, generator data
     =4, branch data
     =5, two winding transformer data
     =6, mutual data
     =7, switched shunt data
     =8, three winding transformer data
     =9, line shunt data
     =10, fixed shunt data

We'll take the 6 option for mutual data.

>>> psspy.sqli(
     sid=-1,
     opt=6) # mutual data
PSS(R)E PROGRAM APPLICATION GUIDE EXAMPLE                MUTUAL DATA
BASE CASE INCLUDING SEQUENCE DATA
X----- FROM BUS -----X X-------- TO BUS ------X
BUS# X-- NAME --X BASKV  BUS# X-- NAME --X BASKV CKT  MUTUAL IMPEDANCE  B1   B2
151  NUCPANT      500.0  152  MID500       500.0 1    0.0020 0.0200    0.000 1.000
151  NUCPANT      500.0  152  MID500       500.0 2                     0.000 1.000

... and so on...

You'll need to redirect this output to a string, so we can parse it and turn it into Python data.

import StringIO

import psspy
psspy.throwPsseExceptions = True

import redirect
redirect.psse2py()

#... then after initialising psse and loading the case ...

report = StringIO.StringIO()
sys.stdout = report
psspy.sqli(sid=-1, opt=6)
sys.stdout = sys.__stdout__

mutual_report = report.getvalue().split('\n')

# strip all rows except those starting with a number.
def starts_with_number(row):
    try:
        firstcolumn = row.strip().split()[0]
    except IndexError:
        return False
    return firstcolumn.isdigit()

rows = filter(starts_with_number, mutual_report)

print rows

Now all the rows in the sqli table are in the rows variable, you'll have to write code to get the information you want from each string. It wouldn't be a pretty or easy to do task, so I've not done that here. You'll need to write that bit yourself.

some explanation about the program

I've used StringIOto capture the report that PSSE would normally print to the screen. It's part of the Python standard library. http://docs.python.org/2/library/stri...

Afterwards, I reassign back to sys.stdout so that future program output once again shows up on the screen.

Secondly, I've used the filter function, which operates line by line to see if the first word in the sentence is a digit. The try..except block is there to handle if the line is blank and there are no words.

edit flag offensive delete link more

Comments

Fantastic, thanks.

PPS Newbie gravatar imagePPS Newbie ( 2013-06-04 01:41:54 -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

Stats

Asked: 2013-06-02 01:58:41 -0500

Seen: 383 times

Last updated: Jun 04 '13