def __call__(self, value, clip=None): if clip is None: clip = self.clip if isinstance(value, (int, float)): vtype = 'scalar' val = ma.array([value]) else: vtype = 'array' val = ma.asarray(value) self.autoscale(val) vmin, vmax = self.vmin, self.vmax if vmin > vmax: raise ValueError("minvalue must be less than or equal to maxvalue") elif vmin<=0: raise ValueError("values must all be positive") elif vmin==vmax: return 0.*value else: if clip: mask = ma.getmask(val) val = ma.array(nx.clip(val.filled(vmax), vmin, vmax), mask=mask) result = (ma.log(val)-nx.log(vmin))/(nx.log(vmax)-nx.log(vmin)) if vtype == 'scalar': result = result[0] return result
def __call__(self, value): if isinstance(value, (int, float)): vtype = 'scalar' val = ma.array([value]) else: vtype = 'array' val = ma.asarray(value) self.autoscale(val) vmin, vmax = self.vmin, self.vmax if vmin > vmax: raise ValueError("minvalue must be less than or equal to maxvalue") elif vmin == vmax: return 0. * value else: if self.clip: mask = ma.getmaskorNone(val) val = ma.array(clip(val.filled(vmax), vmin, vmax), mask=mask) result = (val - vmin) / float(vmax - vmin) if vtype == 'scalar': result = result[0] return result
def __call__(self, value): if isinstance(value, (int, float)): vtype = 'scalar' val = ma.array([value]) else: vtype = 'array' val = ma.asarray(value) self.autoscale(val) vmin, vmax = self.vmin, self.vmax if vmin > vmax: raise ValueError("minvalue must be less than or equal to maxvalue") elif vmin==vmax: return 0.*value else: if self.clip: val = clip(val.filled(vmax), vmin, vmax) result = (1.0/(vmax-vmin))*(val-vmin) if vtype == 'scalar': result = result[0] return result