0

Send data to Excel whit NaN values

Hi folks!, Thanks to the help of this forum I made many script in python. Once again: Thank you all! I made a script to detect under voltage buses in post-mortem .SAVs cases and then send the info to Excel. The script work fine but can´t handle buses with NaN values…. The full issue is:

  • I make a dynamic simulation of a branch trip connected to a generator.
  • After the simulation, the system survives.
  • All voltage and branch currents are ok, but the bus voltage of the generator (isolated after the trip) has a mysterious value of “-1,$” (NaN!)
  • When I try to send the information to Excel, the script fails (stops)
  • The version of my PSS/E is 33.5 and Python 2.7.

Should I write any type of exception in my script? Should a try not to trip generators without transformers?... Any ideas? Thanks a lot in advance!


 import os,sys
sys.path.append(r"C:\Program Files\PTI\PSSE33\PSSBIN")
os.environ['PATH'] = (r"C:\Program Files\PTI\PSSE33\PSSBIN;"
                      + os.environ['PATH'])
import psspy
import redirect
import excelpy
redirect.psse2py()
psspy.psseinit(10000)

# Case to search
Escenarios=['Case1', 'Case2', 'Case3', 'Case4']

SizeEscenarios=len(Escenarios)

# Open and Show excel
x1 = excelpy.workbook()
x1.show()

# start counter
rowid = 0

for jj in range(0,SizeEscenarios): 

    rowid +=1

    CASE=Escenarios[jj]
    psspy.case(r'%s.SAV' %CASE)

    # Buses in service 
    ierr, nbuses = psspy.abuscount(-1, 1)

    # BUSES
    ierr, number11 = psspy.abusint(-1,2,string='NUMBER')
    ierr, name11 = psspy.abuschar(-1,2,string='NAME')
    ierr, area11 = psspy.abusint(-1,2, string='AREA')
    ierr, owner11 = psspy.abusint(-1,2, string='OWNER')
    ierr, base11 = psspy.abusreal(-1,2,string='BASE')
    ierr, pu11 = psspy.abusreal(-1,2,string='PU')

    # BUSES
    number1 = number11[0]
    name1 = name11[0]
    area1 = area11[0]
    owner1 = owner11[0]
    base1 = base11[0]
    pu1 = pu11[0]

    # BUSES
    # Write Titel on Excel
    x1.set_cell((rowid, 1), 'CASO: %s' %CASE)
    rowid +=1
    x1.set_cell((rowid, 1), 'NUMBER')
    x1.set_cell((rowid, 2), 'NAME')
    x1.set_cell((rowid, 3), 'AREA')
    x1.set_cell((rowid, 4), 'OWNER')
    x1.set_cell((rowid, 5), 'BASE')
    x1.set_cell((rowid, 6), 'PU')
    # Select what to send   
    for k in range(len(number1)):
        number = number1[k]
        name = name1[k]
        area = area1[k]
        owner = owner1[k]
        base = base1[k]
        pu = pu1[k]
        if area ==1 or area == 2:
            if pu < 0.9:
               rowid +=1
               x1.set_cell((rowid, 1), number)
               x1.set_cell((rowid, 2), name)
               x1.set_cell((rowid, 3), area)
               x1.set_cell((rowid, 4), owner)
               x1.set_cell((rowid, 5), base)
               x1.set_cell((rowid, 6), pu)
            elif pu > 1.1:
               rowid +=1
               x1.set_cell((rowid, 1), number)
               x1.set_cell((rowid, 2), name)
               x1.set_cell((rowid, 3), area)
               x1.set_cell((rowid, 4), owner)
               x1.set_cell((rowid, 5), base)
               x1.set_cell((rowid, 6), pu)

# for End!  

# Save Workbook
x1.save('VoltageCheck.xlsx')
# Close PSS            
psspy.pssehalt_2()
import winsound
winsound.Beep(440,250)
SAE_2016's avatar
13
SAE_2016
asked 2016-12-13 20:07:28 -0500
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

1 Answer

0

I found a solution!: trip the generator not the branch!!!. Thats all ;)

SAE_2016's avatar
13
SAE_2016
answered 2016-12-16 10:37:46 -0500
edit flag offensive 0 remove flag delete link

Comments

That will work, but to be on the safe side, you should check the returned ierr value before doing anything with the value, which will tell you if the bus is out of service or not.

mjinli's avatar mjinli (2016-12-17 11:59:23 -0500) edit
add a comment see more comments

Your Answer

Login/Signup to Answer