Revision history [back]
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)
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 only 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)
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 only 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')
branchescompleted_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:
completed_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]))
completed_branches.append((fromBus[0][i],toBus[0][i],brnID[0][i]))
print csv
with open('c:\\output.csv','w') as f:
f.write(csv)
