Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Hi, I took what Jervis did and modified a little the script. Here is my version

sid = -1
flag = 4
string1 = 'NUMBER'
string2 = ['NAME','ID']

TEMPLATE = "CONTINGENCY %(name)s REMOVE MACHINE %(id)s FROM BUS %(number)s\n"
ierr1, numbers = psspy.amachint(sid, flag, string1)  # machines at all buses
#print numbers, ierr1
ierr2, name_id = psspy.amachchar(sid, flag, string2) # names and ids
#print name_id, ierr2

# convert from columns to rows [(num, name, id), (num, name, id)]
num_name_id = zip(*(numbers + name_id))
confile = open("contingency.con", "wb")
for number, name, id in num_name_id:
    confile.write(TEMPLATE % dict(name=name, id=id, number=number))
confile.close()

I couldn't work whit the original script, so I did the modifications

Hi, I took what Jervis did and modified a little the script. Here is my version

sid = -1
flag = 4
string1 = 'NUMBER'
string2 = ['NAME','ID']

TEMPLATE = "CONTINGENCY ""CONTINGENCY %(name)s REMOVE MACHINE \nREMOVE UNIT %(id)s FROM BUS %(number)s\n"
%(number)s\nEND\n""
ierr1, numbers = psspy.amachint(sid, flag, string1)  # machines at all buses
#print numbers, ierr1
ierr2, name_id = psspy.amachchar(sid, flag, string2) # names and ids
#print name_id, ierr2

# convert from columns to rows [(num, name, id), (num, name, id)]
num_name_id = zip(*(numbers + name_id))
confile = open("contingency.con", "wb")
for number, name, id in num_name_id:
    confile.write(TEMPLATE % dict(name=name, id=id, number=number))
confile.close()

I couldn't work whit the original script, so I did the modifications

click to hide/show revision 3
No.3 Revision

Hi, I took what Jervis did and modified a little the script. Here is my version

sid = -1
flag = 4
string1 = 'NUMBER'
string2 = ['NAME','ID']

TEMPLATE = ""CONTINGENCY "CONTINGENCY %(name)s \nREMOVE UNIT %(id)s FROM BUS %(number)s\nEND\n""
%(number)s\nEND\n"
ierr1, numbers = psspy.amachint(sid, flag, string1)  # machines at all buses
#print numbers, ierr1
ierr2, name_id = psspy.amachchar(sid, flag, string2) # names and ids
#print name_id, ierr2

# convert from columns to rows [(num, name, id), (num, name, id)]
num_name_id = zip(*(numbers + name_id))
confile = open("contingency.con", "wb")
for number, name, id in num_name_id:
    confile.write(TEMPLATE % dict(name=name, id=id, number=number))
confile.close()

I couldn't work whit the original script, so I did the modifications

click to hide/show revision 4
Edited to fit line width online.

Hi, I took what Jervis did and modified a little the script. Here is my version

sid = -1
flag = 4
string1 = 'NUMBER'
string2 = ['NAME','ID']

TEMPLATE = "CONTINGENCY %(name)s \nREMOVE """
CONTINGENCY %(name)s
REMOVE UNIT %(id)s FROM BUS %(number)s\nEND\n"
%(number)s
END
"""
ierr1, numbers = psspy.amachint(sid, flag, string1)  # machines at all buses
#print numbers, ierr1
ierr2, name_id = psspy.amachchar(sid, flag, string2) # names and ids
#print name_id, ierr2

# convert from columns to rows [(num, name, id), (num, name, id)]
num_name_id = zip(*(numbers + name_id))
confile = open("contingency.con", "wb")
for number, name, id in num_name_id:
    confile.write(TEMPLATE % dict(name=name, id=id, number=number))
confile.close()

I couldn't work whit the original script, so I did the modifications