Exemple #1
0
    def __init__( self, name='', unit='1', attributes = None,
                  length = 0, storage = None, mapper = None, centers = None):
        """HistogramAxis( attributes={},
        length=0, storage=None)
        Inputs:
            attributes: additional user defined attributes 
            length: number of cells in axis (int >= 1)
            storage: raw array/vector etc. holding BIN BOUNDARIES
        Output:
            new HistogramAxis object
        Exceptions: None
        Notes: Meant to hold histogram bin boundaries
        """
        
        if length == 0 and storage is not None: length = storage.size()-1
        elif length !=0 and storage is not None:
            if int(length) !=  int(storage.size()-1) :
                raise "incompatible inputs: length = %s, storage.shape = %s" % (
                    length, storage.shape())
            pass
        shape = [length+1]

        Dataset.__init__( self, name, unit, attributes, shape, storage)

        self._mapper = mapper
        if isinstance( mapper, DiscreteAxisMapper ): 
            self._isDiscrete = True
        else: 
            self._isDiscrete = False

        self._cache = {}

        if centers is not None: centers = N.array(centers)
        self._centers = centers
        self.__isslice = False
        return