Ask Your Question
0

Dyntool _outextract_data equivalent function in PSSE V34.6

asked 2019-11-14 10:03:37 -0600

Clarck gravatar image

Hi folks,

Dyntools in PSSE V34.6 does not have function "outextractdata". I am trying to replace it with "CHNF" but after using function "get_data", chandata only brings the first variable (time) . How I can fix it.

Thanks

edit retag flag offensive close merge delete

3 answers

Sort by ยป oldest newest most voted
0

answered 2019-11-15 12:08:38 -0600

Clarck gravatar image

updated 2019-11-15 12:15:53 -0600

Thanks Everyone, I fixed it. The problem was the Out file name in get_data() function:

class ChannelData:

def __init__(self, fileName):
    self.timeChannelName = 'time'
    temp0 = dyntools.CHNF(fileName , outvrsn = 1)
    (short_title, chanid, chandata) = temp0.get_data()
    temp = [short_title, dict(), dict()]
    temp[1] = dict(chanid).copy()
    temp[2] = dict(chandata).copy()
    self.fileName = os.path.abspath(fileName)
    self.titles = short_title.split("\n")
    self.channelNameRef = dict(chanid).copy()
    del self.channelNameRef[self.timeChannelName]
    self.channelByName = dict([(self.channelNameRef[name], name) for name in self.channelNameRef.keys()])
    self.channelData = dict()
    self.n = len(temp[2][self.timeChannelName])
    for cn in self.channelNameRef.keys():
        values = temp[2][cn]
        assert(self.n == len(values))
        x = numpy.array(values)
        if (numpy.isnan(x).any()): 
            raise Exception('NaN in channel %s' % cn)
        self.channelData[cn] = x
    self.time = numpy.array(temp[2][self.timeChannelName])
def getTime(self):
    return self.time
def readChannel(self, channelName):
    k = self.channelByName[channelName]
    return self.channelData[k]
edit flag offensive delete link more
0

answered 2019-11-14 17:14:07 -0600

drsgao gravatar image

updated 2019-11-14 17:20:04 -0600

The follows are docstrings of the dyntools module in v34.6.1 (PY27 version). Read it and see what you can use.

CLASSES
    CHNF
    OUTDATA

    class CHNF
     |  This class reads PSSE dynamics simulation studies channel output binary (.out) files, and
     |  provides methods to access and post process the data from those files.
     |  
     |  Methods defined here:
     |  
     |  __init__(self, *outfiles, **kwds)
     |      Create CHNF object as below and apply various methods defined here.
     |      
     |      Syntax:
     |          chnfobj = dyntools.CHNF(*outfiles, **kwds)
     |      
     |      Arguments:
     |          outfiles = Provide one or more PSSE dynamics channel output file names separated by comma.
     |                     At least one file name must be provided.
     |      Allowed Keywords:
     |          outvrsn  = 0, for no Extended Channel output file type (.out)
     |                   = 1, for Extended Channel output file type (.outx) (default)
     |  
     |  csvout(self, channels='', csvfile='', outfile='', ntimestep=1)
     |      Write PSSE Dynamic Simulation Channel Output File Data to ASCII text file.
     |      chnfobj.csvout(outfile, channels, csvfile, ntimestep)
     |      channels = Channel numbers to extract, specified as a channel number or
     |                 list of channel numbers to extract.
     |                 If not specified, all channels are extracted, default.
     |      csvfile  = Data saved to this Text File
     |                 Default extension - .csv
     |                 Default name - outfile name with .csv extension
     |      outfile  = PSSE Dynamic Simulation Channel Output File Name (.out), when not
     |                 provided, used 1st file from the files provided during object creation.
     |      ntimestep= Number of timesteps per data export, i.e., for every 'ntimestep' data
     |                 is exported. Default=1, i.e., export data for every time step.
     |  
     |  get_data(self, channels='', outfile='')
     |      Return short_title, chanid and chandata for outfile.
     |      short_title, chanid, chandata = chnfobj.get_data(channels,outfile)
     |      channels    = Channel numbers to extract, specified as a channel number or
     |                    list of channel numbers to extract.
     |                    If not specified, all channels are extracted, default.
     |      outfile     = PSSE Dynamic Simulation Channel Output File Name (.out), when not
     |                    provided, used 1st file from the files provided during object creation.
     |      Returns
     |      short_title = String of Short title of the PSSE case
     |      chanid      = Dictionary of Channel IDs, {'time':'Time(s)',1:id1,2:id2,...,n:idn}
     |      chandata    = Dictionary of Channel Data, {'time':[v],1:[v1],2:[v2],...,n:[vn]}
     |                    where 1, 2, ..n are channel numbers available in the input file
     |                          id1, id2, ...idn are the channel identifiers.
     |                          v, v1, v2, ...vn are data values.
     |  
     |  get_id(self, outfile='')
     |      Return short_title and chanid for outfile.
     |      short_title, chanid = chnfobj.get_id(outfile)
     |      outfile     = PSSE Dynamic Simulation Channel Output File Name (.out), when not
     |                    provided, used 1st file from the files provided during object creation.
     |      Returns
     |      short_title = String of Short title of the PSSE case
     |      chanid      = Dictionary of Channel IDs, {'time':'Time(s)',1:id1,2:id2,...,n:idn}
     |  
     |  get_range(self, outfile='')
     |      Return actual minimum and maximum channel values (range) for outfile.
     |      chanrange = chnfobj.get_range(outfile)
     |      outfile   = PSSE Dynamic Simulation Channel Output File Name (.out), when not
     |                  provided, used 1st file from the files provided during object creation.
     |      Returns
     |      chanrange = Dictionary of Channel range values
     |                = {'time':{'min':v,'max':v},
     |                       1 :{'min':v,'max':v},......
     |                       n :{'min':v,'max':v} }
     |                  where 1, 2, ..n are channel numbers available in the outfile
     |                        'min':v are minumum values, and ...
(more)
edit flag offensive delete link more
0

answered 2019-11-14 10:17:00 -0600

jconto gravatar image

can you show a few lines of the code? If it is able to extract 'time', it should be able to extract any other channels.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

[hide preview]

Question Tools

2 followers

Stats

Asked: 2019-11-14 10:03:37 -0600

Seen: 1,099 times

Last updated: Nov 15 '19