I am receiving an error when trying to find total load and generation in an area. I keep getting an attribute error. WHere can i find specific attributes for the psspy.ardat code. For the load attribute, .real is correct but for generation attribute, .complex is incorrect.
I keep getting this error:
AttributeError: 'complex' object has no attribute 'complex'
[ierr, sysload_N] = psspy.ardat(1, 'LOAD')
[ierr, sysload_D] = psspy.ardat(2, 'LOAD')
[ierr, sysload_M] = psspy.ardat(3, 'LOAD')
[ierr, sysgen_NI] = psspy.ardat(1, 'GEN')
[ierr, sysgen_DI] = psspy.ardat(2, 'GEN')
[ierr, sysgen_MI] = psspy.ardat(3, 'GEN')
sysload_TOT = sysload_N.real + sysload_D.real+sysload_M.real
output = 'Total Load iS #: {} MW\t'
formatted = output.format(sysload_TOT)
sysgen_TOT = sysgen_NI.complex + sysgen_DI.real+sysgen_MI.complex
output2 = 'Total Generation iS #: {} MW\t'
formatted2 = output2.format(sysgen_TOT)
sysLG_TOT=(sysload_TOT-sysgen_TOT)/(sysload_TOT)*100
output3 = 'Total Imports iS #: {}%\t'
formatted3 = output3.format(sysLG_TOT)
output.append(formatted)
output2.append(formatted2)
output3.append(formatted3)
print(output)
print(output2)
print(output3)
The function
psspy.ardat()returns[ierr, cmpval]whereierris anintegerobject andcmpvalis acomplexobject as described by the docstring below and repeated in the API documentation:A
complexobject is defined in the Python standard library and has attributes.realand.imagbut does not have a.complexattribute; this is why you are getting theAttributeError. Try the following:If you are going to be performing this functionality often I would recommend the following approach:
Whenever you are using
psspyfunctions referring to the documentation is very important.