First time here? We are a friendly community of Power Systems Engineers. Check out the FAQ!

Ask Your Question
0

Dyntool _outextract_data equivalent function in PSSE V34.6

asked Nov 14 '19

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

3 answers

Sort by » oldest newest most voted
0

answered Nov 15 '19

Clarck gravatar image

updated Nov 15 '19

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]
link
0

answered Nov 14 '19

drsgao gravatar image

updated Nov 14 '19

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)
link
0

answered Nov 14 '19

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.

link

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.
Want to format code in your answer? Here is a one minute demo on Youtube

Add Answer

[hide preview]

Question Tools

2 followers

Stats

Asked: Nov 14 '19

Seen: 1,153 times

Last updated: Nov 15 '19