Ejemplo n.º 1
0
    def getComposition(self, normalize=False, boundaryMethod=None):
        """Return numbers of each particle in a dictionary
        pass this dictionary to sensorProducers

        >>> a = _Environment()
        >>> a.fillSensorProducer()
        >>> a.getComposition()
        {}
        >>> a.advance() 
        >>> a.getComposition()
        {'a': 10}
        >>> a.advance() 
        >>> a.getComposition()
        {'a': 20}

        """
        post = {}
        for part in self._particleArray:  # part is a particle object
            state = part.getState()
            if state not in post:
                post[state] = 0
            post[state] = post[state] + 1
        if boundaryMethod != None:
            for key in post.keys():
                pre = post[key]
                post[key] = unit.boundaryFit(self.range[0], self.range[1], pre,
                                             boundaryMethod)
        if normalize:
            for key in post.keys():
                pre = post[key]
                post[key] = unit.unitNorm(pre, self.range)
        return post
Ejemplo n.º 2
0
    def getComposition(self, normalize=False, boundaryMethod=None):
        """Return numbers of each particle in a dictionary
        pass this dictionary to sensorProducers

        >>> a = _Environment()
        >>> a.fillSensorProducer()
        >>> a.getComposition()
        {}
        >>> a.advance() 
        >>> a.getComposition()
        {'a': 10}
        >>> a.advance() 
        >>> a.getComposition()
        {'a': 20}

        """
        post = {}
        for part in self._particleArray: # part is a particle object
            state = part.getState()
            if state not in post:
                post[state] = 0
            post[state] = post[state] + 1        
        if boundaryMethod != None:
            for key in post.keys():
                pre = post[key]
                post[key] = unit.boundaryFit(self.range[0], 
                    self.range[1], pre, boundaryMethod)
        if normalize:
            for key in post.keys():
                pre = post[key]
                post[key] = unit.unitNorm(pre, self.range)
        return post
Ejemplo n.º 3
0
 def __call__(self, valArray, tArray, refDictArray):
     # vale and time should always be the same length
     assert (len(valArray) == len(tArray)
             and len(tArray) == len(refDictArray))
     # process each value
     self.currentValue = []
     for i in range(len(valArray)):
         val = valArray[i]
         t = tArray[i]
         refDict = refDictArray[i]
         # get parameter obj values
         a = self.boundingPmtrObjA(t, refDict)
         b = self.boundingPmtrObjB(t, refDict)
         self.currentValue.append(
             unit.boundaryFit(a, b, val, self.boundaryMethod))
     # return list of values
     return self.currentValue
Ejemplo n.º 4
0
 def __call__(self, valArray, tArray, refDictArray):
      # vale and time should always be the same length
     assert (len(valArray) == len(tArray) and 
               len(tArray) == len(refDictArray))
     # process each value
     self.currentValue = []
     for i in range(len(valArray)):
         val = valArray[i]
         t = tArray[i]
         refDict = refDictArray[i]
         # get parameter obj values
         a = self.boundingPmtrObjA(t, refDict)
         b = self.boundingPmtrObjB(t, refDict)
         self.currentValue.append(unit.boundaryFit(a, b, val, 
                                         self.boundaryMethod))
     # return list of values
     return self.currentValue