3

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

  • retag add tags

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.

anonymous user
asked 2013-09-02 06:15:23 -0500, updated 2013-09-09 04:51:48 -0500
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

3 Answers

4

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)
jsexauer's avatar
586
jsexauer
answered 2013-09-03 08:19:49 -0500, updated 2014-04-09 14:01:49 -0500
edit flag offensive 0 remove flag delete link

Comments

add a comment see more comments
1

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)
EBahr's avatar
420
EBahr
answered 2014-04-07 11:56:11 -0500, updated 2014-04-10 08:08:58 -0500
edit flag offensive 0 remove flag delete link

Comments

good catch, thanks

jsexauer's avatar jsexauer (2014-04-09 14:04:00 -0500) edit
add a comment see more comments
0

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

Towana's avatar
3
Towana
answered 2014-04-02 11:19:14 -0500
edit flag offensive 0 remove flag delete link

Comments

double click on the csv file.

jconto's avatar jconto (2014-04-02 21:51:06 -0500) edit

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

jsexauer's avatar jsexauer (2014-04-07 09:05:14 -0500) edit
add a comment see more comments

Your Answer

Login/Signup to Answer