Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The easiest is to use API treedat, which returns a lot of information in a dictionary. The following will return a list with a sublist with bus numbers in every found island.

treeobj = psspy.treedat(20)
islandbuses = treeobj['island_busnum']

For eaxemple, with three islands the list may look like this:

[[101], [102], [201, 202, 203, 204, 205, 206, 211]]

This can be merged into one single list with:

islandbuslist = [j for i in islandbuses for j in i]

Now the list is:

[101, 102, 201, 202, 203, 204, 205, 206, 211]

Everything in a single line:

islandbuslist = [j for i in psspy.treedat(999)['island_busnum'] for j in i]

The easiest is to use API treedat, which returns a lot of information in a dictionary. The following will return a list with a sublist with bus numbers in every found island.

treeobj = psspy.treedat(20)
psspy.treedat(999)
islandbuses = treeobj['island_busnum']

For eaxemple, with three islands the list may look like this:

[[101], [102], [201, 202, 203, 204, 205, 206, 211]]

This can be merged into one single list with:

islandbuslist = [j for i in islandbuses for j in i]

Now the list is:

[101, 102, 201, 202, 203, 204, 205, 206, 211]

Everything in a single line:

islandbuslist = [j for i in psspy.treedat(999)['island_busnum'] for j in i]