First time here? We are a friendly community of Power Systems Engineers. Check out the FAQ!

Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

answered Jun 28 '16

JervisW gravatar image

At this point here, you have all the information you want, but spread in three different lists (or columns). buses, iarea and volts

ierr, buses = psspy.abusint(-1,2,string='NUMBER')
ierr, iarea = psspy.abusint(-1,2, string='AREA')
ierr, volts = psspy.abusreal(-1,2,string='PU')

What you want is a way to filter for the rows where the area == 5

You need to transpose your columns into rows first.

rows = zip(buses, iarea, volts)

then you'll need to set the cells that you'd like. I don't think excelpy is efficiently using set_range. It is just calling set_cell individually. So we can do this without any performance penalty

for rowid, record in enumerate(rows):
    bus, area, voltage = record
    if area == 5:
        x1.set_range(2 + rowid, 'a', area)
        x1.set_range(2 + rowid, 'b', bus)
        x1.set_range(2 + rowid, 'c', voltage)

where enumerate obviously gives us a 0-based index, and you wanted to start from row 2, that's why I add 2 to every rowid.

click to hide/show revision 2
No.2 Revision

At this point here, you have all the information you want, but spread in three different lists (or columns). buses, iarea and volts

ierr, buses = psspy.abusint(-1,2,string='NUMBER')
ierr, iarea = psspy.abusint(-1,2, string='AREA')
ierr, volts = psspy.abusreal(-1,2,string='PU')

What you want is a way to filter for the rows where the area == 5

You need to transpose your columns into rows first.

rows = zip(buses, iarea, volts)

then you'll need to set the cells that you'd like. I don't think excelpy is efficiently using set_range. It is just calling set_cell individually. So we can do this without any performance penalty

for rowid, record in enumerate(rows):
    bus, area, voltage = record
    if area == 5:
        x1.set_range(2 x1.set_cell(2 + rowid, 'a', area)
        x1.set_range(2 x1.set_cell(2 + rowid, 'b', bus)
        x1.set_range(2 x1.set_cell(2 + rowid, 'c', voltage)

where enumerate obviously gives us a 0-based index, and you wanted to start from row 2, that's why I add 2 to every rowid.