def __getitem__(self, outputname=None): """Returns a Waveform object if the parameter is swept and a scalar otherwise. A Struct is given as a dictionary. If outputname is None it will return a dictionary of all outputs keyed by the output names >>> result=PSFResult('./test/psf/srcSweep') >>> result[None] {'R0': Waveform([ 1. 2. 3. 4.],[-0.006 -0.004 -0.002 0. ]), 'VIN': Waveform([ 1. 2. 3. 4.],[ 1. 2. 3. 4.]), 'VOUT': Waveform([ 1. 2. 3. 4.],[-6. -4. -2. 0.])} >>> result["VOUT"] Waveform([ 1. 2. 3. 4.],[-6. -4. -2. 0.]) >>> result["VIN"] Waveform([ 1. 2. 3. 4.],[ 1. 2. 3. 4.]) >>> result['VIN'] Waveform([ 1. 2. 3. 4.],[ 1. 2. 3. 4.]) >>> result=PSFResult('./test/psf/dcOpInfo.info') >>> result["R0"] {'i': 2.5000000000000002e-06, 'res': 99999.999999999985, 'pwr': 6.2500000000000005e-07, 'v': 0.25} """ if outputname is None: res = {} for output in self.keys(): res[output] = self[output] return res else: if self.psfobj.getNSweeps() > 0: return waveform.Waveform( self.psfobj.getSweepParamValues(0), self.psfobj.getValuesByName(outputname), xlabels=self.psfobj.getSweepParamNames(), ylabel=outputname) else: return self.psfobj.getValuesByName(outputname)
def __getitem__(self, outputname): """Returns a Waveform object if the parameter is swept and a scalar otherwise. A Struct is given as a dictionary. If outputname is None it will return a dictionary of all outputs keyed by the output names >>> resultset=PSFResultSet('./test/resultdirs/parsweep/psf') >>> result=resultset['ac-ac'] >>> result['net3'] apa """ if outputname is None: res = {} # for output in self.keys(): # res[output] = self[output] return res else: if self.psfobjects[0].getNSweeps() > 0: xvalues = self.sweepvalues + [ self.psfobjects[0].getSweepParamValues(0) ] xlabels = self.sweepvariables + tuple( self.psfobjects[0].getSweepParamNames()) yvalues = numpy.concatenate([ psfobj.getValuesByName(outputname) for psfobj in self.psfobjects ]) yvalues = numpy.array(yvalues) yvalues = numpy.reshape(yvalues, map(len, xvalues)) return waveform.Waveform(xvalues, yvalues, xlabels=xlabels, ylabel=outputname) else: xvalues = self.sweepvalues xlabels = self.sweepvariables yvalues = [ psfobj.getValuesByName(outputname) for psfobj in self.psfobjects ] yvalues = numpy.array(yvalues) yvalues = numpy.reshape(yvalues, map(len, xvalues)) return waveform.Waveform(xvalues, yvalues, xlabels=xlabels, ylabel=outputname)