Beispiel #1
0
    def __call__(self, value):

        vmin = self.vmin
        vmax = self.vmax

        if type(value) in [IntType, FloatType]:
            vtype = 'scalar'
            val = array([value])
        else:
            vtype = 'array'
            val = asarray(value)
        if vmin is None or vmax is None:
            rval = ravel(val)
            if vmin is None: vmin = nxmin(rval)
            if vmax is None: vmax = nxmax(rval)
        if vmin > vmax:
            raise ValueError("minvalue must be less than or equal to maxvalue")
        elif vmin==vmax:
            return 0.*value
        else:
            
            val = where(val<vmin, vmin, val)
            val = where(val>vmax, vmax, val)
            result = (1.0/(vmax-vmin))*(val-vmin)
        if vtype == 'scalar':
            result = result[0]
        return result
Beispiel #2
0
    def __call__(self, value):

        vmin = self.vmin
        vmax = self.vmax

        if type(value) in [IntType, FloatType]:
            vtype = 'scalar'
            val = array([value])
        else:
            vtype = 'array'
            val = asarray(value)
        if vmin is None or vmax is None:
            rval = ravel(val)
            if vmin is None: vmin = nxmin(rval)
            if vmax is None: vmax = nxmax(rval)
        if vmin > vmax:
            raise ValueError("minvalue must be less than or equal to maxvalue")
        elif vmin==vmax:
            return 0.*value
        else:
            
            val = where(val<vmin, vmin, val)
            val = where(val>vmax, vmax, val)
            result = (1.0/(vmax-vmin))*(val-vmin)
        if vtype == 'scalar':
            result = result[0]
        return result
Beispiel #3
0
 def autoscale(self, A):
     if not self.scaled():
         rval = ravel(A)
         if self.vmin is None: self.vmin = nxmin(rval)
         if self.vmax is None: self.vmax = nxmax(rval)
Beispiel #4
0
 def autoscale(self, A):
     if not self.scaled():
         rval = ravel(A)
         if self.vmin is None: self.vmin = nxmin(rval)
         if self.vmax is None: self.vmax = nxmax(rval)