Ask Your Question
3

Is there any way to export to excel LOSSES of all the branches of a system?

asked 2013-09-02 06:15:23 -0500

anonymous user

Anonymous

updated 2013-09-09 04:51:48 -0500

Hi,

I am new with PSSE and python. I am trying to export to excel a list with the losses in a system. If It is possible I would like to get losses in each bus connection. I have tried with caspy but I don´t know how to get losses from branches. Anyone of you could give me an idea?

Thank you very much!

* I have problems to post a comment* Thank you very much! very useful and helpful answer.

edit retag flag offensive close merge delete

3 answers

Sort by » oldest newest most voted
4

answered 2013-09-03 08:19:49 -0500

jsexauer gravatar image

updated 2014-04-09 14:01:49 -0500

This will do what you're looking for. Refer to chapter 8 Subsystem Data Retrieval, specifically the bit on Branch Flow data, for more info. Keep in mind the "-1" subsystem is the entire case.

ierr, loss = psspy.aflowreal(-1, 2, 1, 1, 'PLOSS')
ierr, toBus = psspy.aflowint(-1, 2, 1, 1, 'TONUMBER')
ierr, fromBus = psspy.aflowint(-1, 2, 1, 1, 'FROMNUMBER')
ierr, brnID = psspy.aflowchar(-1, 2, 1, 1, 'ID')

csv = 'ToBus, FromBus, ID, PLOSS\n'
for fields in zip(toBus[0], fromBus[0], brnID[0],loss[0]):
    csv += ','.join(map(str,fields)) + '\n'
print csv
with open('output.csv','w') as f:
    f.write(csv)
edit flag offensive delete link more
1

answered 2014-04-07 11:56:11 -0500

EBahr gravatar image

updated 2014-04-10 08:08:58 -0500

Unfortunately I don't think you can extract that type of calculated data from caspy.

Also, see below for a slight variation to @jsexauer's answer. This version will make sure the branch is only documented once. Otherwise if you tried to calculate total system losses, it would be double what it should be.

ierr, loss = psspy.aflowreal(-1, 2, 1, 1, 'PLOSS')
ierr, toBus = psspy.aflowint(-1, 2, 1, 1, 'TONUMBER')
ierr, fromBus = psspy.aflowint(-1, 2, 1, 1, 'FROMNUMBER')
ierr, brnID = psspy.aflowchar(-1, 2, 1, 1, 'ID')
branches = []

csv = 'ToBus, FromBus, ID, PLOSS\n'
for i in range(len(loss[0])):
    if not (toBus[0][i],fromBus[0][i],brnID[0][i]) in branches:
        csv += '%i,%i,%s,%f\n' % (toBus[0][i], fromBus[0][i], brnID[0][i],loss[0][i])
        branches.append((fromBus[0][i],toBus[0][i],brnID[0][i]))
print csv
with open('c:\\output.csv','w') as f:
    f.write(csv)
edit flag offensive delete link more

Comments

good catch, thanks

jsexauer gravatar imagejsexauer ( 2014-04-09 14:04:00 -0500 )edit
0

answered 2014-04-02 11:19:14 -0500

Towana gravatar image

Thanks it was interesting..... But i did not get results in excel file, it is possible? If yes, how we can do it? Thanks in advance

edit flag offensive delete link more

Comments

double click on the csv file.

jconto gravatar imagejconto ( 2014-04-02 21:51:06 -0500 )edit

Edited answer to save results to a file, output.csv

jsexauer gravatar imagejsexauer ( 2014-04-07 09:05:14 -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-09-02 06:15:23 -0500

Seen: 2,121 times

Last updated: Apr 10 '14