Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

There is no API in PSSE for that. I have written my own "API, as shown below:

def get_last_channel():
    """ Returns last used channel number.
    """
    for n in range(1,999999):
        ierr, rval = psspy.chnval(n)
        if ierr == 9:
            print 'Dynamics data not present in working memory'
            return None
        if ierr > 0: break
    return n-1

You can get the number of channels with:

nchan = get_last_channel()

There is no API in PSSE for that. I have written my own "API, "API", as shown below:

def get_last_channel():
    """ Returns last used channel number.
    """
    for n in range(1,999999):
        ierr, rval = psspy.chnval(n)
        if ierr == 9:
            print 'Dynamics data not present in working memory'
            return None
        if ierr > 0: break
    return n-1

You can get the number of channels with:

nchan = get_last_channel()

There is no API in PSSE for that. I have written my own "API", as shown below:

def get_last_channel():
    """ Returns last used channel number.
    """
    for n in range(1,999999):
        ierr, rval = psspy.chnval(n)
        if ierr == 9:
            print 'Dynamics data not present in working memory'
            return None
        if ierr > 0: break
    return n-1

You can get the number of channels with:

nchan = get_last_channel()

EDIT: Below there is a self-made API to return the last used index in CON, STATE, VAR and ICON vector as well as the number of channels.

def get_dyn_index(type='VARS'):
    """ Returns number of used index in ICON, CON, STATE, VAR or CHANNEL vector
    type: index to be returned ('ICONS', 'CONS', 'STATES', 'VARS' or 'CHANNELS'
    """
    import os
    d = {'CONS':1,'STATES':2,'VARS':3,'ICONS':4,'CHANNELS':5}
    type = type.upper()
    if type not in d:
        print 'Invalid value of type (%s)' % type
        return None
    filnamn = "get_dyn_index_dummy_file.dat"
    psspy.report_output(2,filnamn,[1,0])
    psspy.size_ds()
    psspy.report_output(1,"",[0,0])
    with open(filnamn) as f: lines = f.readlines()
    if type == 'CHANNELS': line = lines[11].split()
    else: line = lines[5].split()
    os.remove(filnamn)
    return int(line[d[type]])

For example, the last VAR is returned with

get_dyn_index('VARS')