Take a look at the BRNDT2 function in the API. For example:
ierr, line_rx = psspy.brndt2(113987,113973,'1','RX')
would give you a complex value for the line impedance. linerx.real and linerx.imag will then separate the resistance and reactance values of the impedance.
You were also interested in accessing the data from caspy. It is quite a bit different beast, and is a little more difficult to get the data you are requesting.
Here is the gist of how to get the same data:
rx = None
sav = 'c:/path/to/your/case.sav'
from_bus = '113987'
to_bus = '113973'
ckt_id = ' 1'
case = caspy.Savecase(sav)
# Look for from bus in FRMBUS list
for i in range(len(case.pssbrn.frmbus)):
if ((case.pssbrn.frmbus[i] == float(from_bus)) and (case.pssbrn.tobus[i]==float(to_bus)) and case.pssbrn.ckt[i].strip() == ckt_id.strip()):
rx = case.pssbrn.rx[i]
# Look for from bus in TOBUS list
for i in range(len(case.pssbrn.tobus)):
if ((case.pssbrn.frmbus[i] == float(to_bus)) and (case.pssbrn.tobus[i]==float(from_bus)) and case.pssbrn.ckt[i].strip() == ckt_id.strip()):
rx = case.pssbrn.rx[i]
if rx:
print('%05f + %05fi' % (rx.real,rx.imag))
else:
print('Branch not found in case')
Check out the "DIFF" command in the API documentation. It's the API version of a powerflow case comparison.
@ nyga0082, thank you I checked "DIFF" seems it's not what I want. API should have a command to output the specific branch data or bus data, right?
@Shengen Specifically what sort of data are you looking to get (flows? voltages? line impedances? ratings?) If you want to get bus and branch data from only one case at a time (as opposed to both cases with DIFF), check out Chapter 7 of the API doc. Especially commands like BUSDAT, BRNDAT, & BRNMSC
@nyga0082 just care about line impedances, thank you, it really helps. Not familiar with PSSE and API.
Might be an overkill but see my command line case compare python utility PSSecompare https://github.com/sbhowmik7/PSSEcompare/tree/pyV27. Why reinvent the wheel.