Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Data conversion/comparison python-PSSE-excel

I am having trouble when I compare PGen levels using by psspy.py reading from PSSE and data read from Excel using excelpy.

For example, I read PGen levels from a machine (using psspy.py psspy.amachreal) and store the data using excelpy in a spreadsheet. I then read the data back from excel using excelpy and compare this with the current machine PGen the number comparison in python "==" typically fails. In the code snippet below the IF statement is quite often false even though the excel and PSSE value look the same.

machPGens = psspy.amachreal(sid=-1, flag=4, string="PGEN")
machPGen = xlsfile.get_range((topRow, leftCol, bottomRow, rightCol),transpose=True)
#code here to find the matching machine idx2 and idx
if machPGen[idx2]==machPGens[idx]:

In this process there are a number of conversions of the data

Firstly from PSSE to python to excel

And from excel to python and the data comparison

The comparison is normally true when PGen is an integer. Another issue I notice is sometimes in PSSE a machine may have a PMax of 8.2 MW (as shown in PSSE), however when reading using psspy the machine PMax is 8.19963821. Even when the excel value is exactly 8.19963821 the comparison still fails.

I assume a simple fix to this is to check if the PGen is within some small range +/-0.001MW