First time here? We are a friendly community of Power Systems Engineers. Check out the FAQ!
1 | initial version |
In the end I found something like this:
thanks!
Blockquote
def getgenerationdata(owner, selected_areas):
try:
total_pgen = 0
total_pmax = 0
areanumbers = [area[0] for area in selectedareas]
ierr = psspy.bsys(0, 0, [1.0, 220.], len(areanumbers), areanumbers, 0, [], 1, [owner], 0, [])
if error:
print(f"Error defining base system for owner {owner}: {ierr}")
return 0, 0, 0
ierr, pgen = psspy.amachreal(0, 1, 'PGEN') if error: print(f"Error getting active supplier of {owner}: {ierr}") otherwise: total_pgen = sum(pgen[0])
ierr, pmax = psspy.amachreal(0, 2, 'PMAX') if error: print(f"Error getting maximum power of {owner}: {ierr}") otherwise: total_pmax = sum(pmax[0])
percentage = (totalpgen / totalpmax * 100) if totalpmax else 0 return totalpgen, total_pmax, percentage
except:
print(f"Unexpected error getting production data for owner {owner}: {sys.exc_info()[0]}") return 0, 0, 0
Blockquote
2 | No.2 Revision |
In the end I found something like this:
thanks!
Blockquote
def getgenerationdata(owner, selected_areas):
try:
total_pgen = 0
total_pmax = 0
areanumbers = [area[0] for area in selectedareas]
ierr = psspy.bsys(0, 0, [1.0, 220.], len(areanumbers), areanumbers, 0, [], 1, [owner], 0, [])
if error:
print(f"Error defining base system for owner {owner}: {ierr}")
return 0, 0, 0
ierr, pgen = psspy.amachreal(0, 1, 'PGEN')
if error:
error:
print(f"Error getting active supplier of {owner}: {ierr}")
otherwise:
otherwise:
total_pgen = sum(pgen[0])
ierr, pmax = psspy.amachreal(0, 2, 'PMAX')
if error:
'PMAX')
if error:
print(f"Error getting maximum power of {owner}: {ierr}")
otherwise:
otherwise:
total_pmax = sum(pmax[0])
percentage = (totalpgen / totalpmax * 100) if totalpmax else 0 return totalpgen, total_pmax, percentage
except:
print(f"Unexpected error getting production data for owner {owner}: {sys.exc_info()[0]}") return 0, 0, 0
Blockquote
3 | No.3 Revision |
In the end I found something like this:
thanks!
Blockquote
def getgenerationdata(owner, selected_areas):
try:
total_pgen = 0
total_pmax = 0
areanumbers = [area[0] for area in selectedareas]
ierr = psspy.bsys(0, 0, [1.0, 220.], len(areanumbers), areanumbers, 0, [], 1, [owner], 0, [])
if error:
print(f"Error defining base system for owner {owner}: {ierr}")
return 0, 0, 0
ierr, pgen = psspy.amachreal(0, 1, 'PGEN') if error:
print(f"Error getting active supplier of {owner}: {ierr}") otherwise:
total_pgen = sum(pgen[0])
ierr, pmax = psspy.amachreal(0, 2, 'PMAX')
if error:
print(f"Error getting maximum power of {owner}: {ierr}") otherwise:
total_pmax = sum(pmax[0])
percentage = (totalpgen / totalpmax * 100) if totalpmax total_pmax else 0
0
return totalpgen, total_pmax, totalpmax, percentage
except:
print(f"Unexpected error getting production data for owner {owner}: {sys.exc_info()[0]}") return 0, 0, 0
Blockquote
4 | No.4 Revision |
In the end I found something like this:
thanks!
Blockquote
def getgenerationdata(owner, selected_areas):
try:
total_pgen = 0
total_pmax = 0
areanumbers = [area[0] for area in selectedareas]
ierr = psspy.bsys(0, 0, [1.0, 220.], len(areanumbers), areanumbers, 0, [], 1, [owner], 0, [])
if error:
print(f"Error defining base system for owner {owner}: {ierr}")
return 0, 0, 0
ierr, pgen = psspy.amachreal(0, 1, 'PGEN') if error:
print(f"Error getting active supplier of {owner}: {ierr}") otherwise:
total_pgen = sum(pgen[0])
ierr, pmax = psspy.amachreal(0, 2, 'PMAX')
if error:
print(f"Error getting maximum power of {owner}: {ierr}") otherwise:
total_pmax = sum(pmax[0])
percentage = (totalpgen / totalpmax * 100) if total_pmax else 0
return totalpgen, totalpmax, percentage
except:
print(f"Unexpected error getting production data for owner {owner}: {sys.exc_info()[0]}") return 0, 0, 0
Blockquote