Revision history [back]
In the end I found something like this:
thanks!
Blockquote
def get_generation_data(owner, selected_areas):
try:
total_pgen = 0
total_pmax = 0
area_numbers = [area[0] for area in selected_areas]
ierr = psspy.bsys(0, 0, [1.0, 220.], len(area_numbers), area_numbers, 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 = (total_pgen / total_pmax * 100) if total_pmax else 0
return total_pgen, total_pmax, percentage
except:
print(f"Unexpected error getting production data for owner {owner}: {sys.exc_info()[0]}") return 0, 0, 0
Blockquote
In the end I found something like this:
thanks!
Blockquote
def get_generation_data(owner, selected_areas):
try:
total_pgen = 0
total_pmax = 0
area_numbers = [area[0] for area in selected_areas]
ierr = psspy.bsys(0, 0, [1.0, 220.], len(area_numbers), area_numbers, 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 = (total_pgen / total_pmax * 100) if total_pmax else 0
return total_pgen, total_pmax, percentage
except:
print(f"Unexpected error getting production data for owner {owner}: {sys.exc_info()[0]}") return 0, 0, 0
Blockquote
In the end I found something like this:
thanks!
Blockquote
def get_generation_data(owner, selected_areas):
try:
total_pgen = 0
total_pmax = 0
area_numbers = [area[0] for area in selected_areas]
ierr = psspy.bsys(0, 0, [1.0, 220.], len(area_numbers), area_numbers, 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 = (total_pgen / total_pmax * 100) if total_pmax else 0
0 return total_pgen, total_pmax, percentage
except:
print(f"Unexpected error getting production data for owner {owner}: {sys.exc_info()[0]}") return 0, 0, 0
Blockquote
In the end I found something like this:
thanks!
Blockquote
def get_generation_data(owner, selected_areas):
try:
total_pgen = 0
total_pmax = 0
area_numbers = [area[0] for area in selected_areas]
ierr = psspy.bsys(0, 0, [1.0, 220.], len(area_numbers), area_numbers, 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')
'PMAX')
if error:
error:
print(f"Error getting maximum power of {owner}: {ierr}")
otherwise:
otherwise: total_pmax = sum(pmax[0])
percentage = (total_pgen / total_pmax * 100) if total_pmax else 0 return total_pgen, total_pmax, percentage
except:
print(f"Unexpected error getting production data for owner {owner}: {sys.exc_info()[0]}") return 0, 0, 0
Blockquote