def __init__(self, stretch='linear', exponent=5, vmid=None, vmin=None, vmax=None, clip=False): ''' Initalize an APLpyNormalize instance. Optional Keyword Arguments: *vmin*: [ None | float ] Minimum pixel value to use for the scaling. *vmax*: [ None | float ] Maximum pixel value to use for the scaling. *stretch*: [ 'linear' | 'log' | 'sqrt' | 'arcsinh' | 'power' ] The stretch function to use (default is 'linear'). *vmid*: [ None | float ] Mid-pixel value used for the log and arcsinh stretches. If set to None, a default value is picked. *exponent*: [ float ] if self.stretch is set to 'power', this is the exponent to use. *clip*: [ True | False ] If clip is True and the given value falls outside the range, the returned value will be 0 or 1, whichever is closer. ''' if vmax < vmin: raise Exception("vmax should be larger than vmin") # Call original initalization routine Normalize.__init__(self, vmin=vmin, vmax=vmax, clip=clip) # Save parameters self.stretch = stretch self.exponent = exponent if stretch == 'power' and np.equal(self.exponent, None): raise Exception("For stretch=='power', an exponent should be specified") if np.equal(vmid, None): if stretch == 'log': if vmin > 0: self.midpoint = vmax / vmin else: raise Exception("When using a log stretch, if vmin < 0, then vmid has to be specified") elif stretch == 'arcsinh': self.midpoint = -1./30. else: self.midpoint = None else: if stretch == 'log': if vmin < vmid: raise Exception("When using a log stretch, vmin should be larger than vmid") self.midpoint = (vmax - vmid) / (vmin - vmid) elif stretch == 'arcsinh': self.midpoint = (vmid - vmin) / (vmax - vmin) else: self.midpoint = None
def __init__(self, vmin=None, vmax=None, clip=False,fpos=(lambda x: x**0.5),finvpos=(lambda x: x**2)): if vmin is not None and vmax is not None: if vmin > vmax: raise ValueError("vmin must be less than vmax") self.fpos=fpos self.finvpos=finvpos Normalize.__init__(self, vmin, vmax, clip)
def __init__(self, stretch='linear', exponent=5, vmid=None, vmin=None, vmax=None, clip=False): """ Initalize an APLpyNormalize instance. Optional Keyword Arguments: *vmin*: [ None | float ] Minimum pixel value to use for the scaling. *vmax*: [ None | float ] Maximum pixel value to use for the scaling. *stretch*: [ 'linear' | 'log' | 'sqrt' | 'arcsinh' | 'power' ] The stretch function to use (default is 'linear'). *vmid*: [ None | float ] Mid-pixel value used for the log and arcsinh stretches. If set to None, a default value is picked. *exponent*: [ float ] if self.stretch is set to 'power', this is the exponent to use. *clip*: [ True | False ] If clip is True and the given value falls outside the range, the returned value will be 0 or 1, whichever is closer. """ if vmax < vmin: raise Exception("vmax should be larger than vmin") # Call original initalization routine Normalize.__init__(self, vmin=vmin, vmax=vmax, clip=clip) # Save parameters self.stretch = stretch self.exponent = exponent if stretch == 'power' and np.equal(self.exponent, None): raise Exception("For stretch=='power', an exponent should be specified") if np.equal(vmid, None): if stretch == 'log': if vmin > 0: self.midpoint = vmax / vmin else: raise Exception("When using a log stretch, if vmin < 0, then vmid has to be specified") elif stretch == 'arcsinh': self.midpoint = -1. / 30. else: self.midpoint = None else: if stretch == 'log': if vmin < vmid: raise Exception("When using a log stretch, vmin should be larger than vmid") self.midpoint = (vmax - vmid) / (vmin - vmid) elif stretch == 'arcsinh': self.midpoint = (vmid - vmin) / (vmax - vmin) else: self.midpoint = None
def __init__(self): Normalize.__init__(self) self.stretch = "linear" self.bias = 0.5 self.contrast = 0.5 self.clip_lo = 5.0 self.clip_hi = 95.0
def __init__(self, vmin=None, vmax=None, midpoint=None, clip=False): self.midpoint = midpoint Normalize.__init__(self, vmin, vmax, clip)
def __init__(self, vmin=None, vmax=None, img=None, Q=10, clip=False): """Initialize Parameters ---------- vmin: float, default=`None` Minimum pixel value. If `vmin` is `None`, the minimum value of `img` will be used. vmax: float, default=`None` Maximum pixel value. If `vmin` is `None`, the maximum value of `img` will be used. img: array_like, default=`None` This should be an array with dimensions (bands, height, width). Either `vmin` and `vmax` or `img` is required to create an Asinh mapping Q: float, default=`10` Stretching parameter for the arcsinh function. This reduces to a linear stretch when Q=0 clip: bool, default=`False` Whether or not to clip values. This is a default from matplotlib, but clip=True is currently not supported. """ self.Q = Q Normalize.__init__(self, vmin, vmax, clip) if img is not None: if vmin is None: vmin = np.ma.min(img) if vmax is None: vmax = np.ma.max(img) if vmin is not None and vmax is not None: self._set_scale(vmin, vmax)
def __init__(self): Normalize.__init__(self) self.stretch = 'linear' self.bias = 0.5 self.contrast = 0.5 self.clip_lo = 5. self.clip_hi = 95.
def __init__(self, vmin: float = None, vmax: float = None, midpoint: float = None, clip: bool = False) -> None: self.midpoint = midpoint Normalize.__init__(self, vmin, vmax, clip)
def __init__(self, vmin=None, vmax=None, sealevel=0, col_val=0.5, clip=False): # sealevel is the fix point of the colormap (in data units) self.sealevel = sealevel # col_val is the color value in the range [0,1] that should represent # the sealevel. self.col_val = col_val Normalize.__init__(self, vmin, vmax, clip)
def __init__(self, vmin=None, vmax=None, vanchor=None, clip=False, canchor=0.5): self.vanchor = vanchor self.canchor = canchor Normalize.__init__(self, vmin, vmax, clip)
def __init__( self, midpoint: float = 0, vmin: Optional[float] = None, vmax: Optional[float] = None, clip: bool = False, ) -> None: Normalize.__init__(self, vmin, vmax, clip) self.midpoint = midpoint
def __init__(self, threshold, vmax, clip=False): assert threshold >= 0 if vmax is None: vmin = None else: assert vmax > threshold vmin = -vmax self.threshold = threshold Normalize.__init__(self, vmin, vmax, clip)
def __init__(self, vc=0, cc=0.5, vmin=None, vmax=None, clip=False): ''' Args: vc value of center cc color of center ''' Normalize.__init__(self, vmin, vmax, clip) assert 0< cc < 1, "Central color should be in (0, 1)" self.vc = vc self.cc = cc
def __init__(self, vmin=None, vmax=None, midpoint=0, clip=False): """ Copied from SO answer: http://stackoverflow.com/questions/20144529/shifted-colorbar-matplotlib :param vmin: :param vmax: :param midpoint: :param clip: """ self.midpoint = midpoint Normalize.__init__(self, vmin, vmax, clip)
def __init__(self, vmin=None, vmax=None, midpoint=None, clip=False): """ Generate an instance of matplotlib.Normalize that is centred at the supplied midpoint. Copied verbatim from a SO answer. :param vmin: :param vmax: :param midpoint: :param clip: """ self.midpoint = midpoint Normalize.__init__(self, vmin, vmax, clip)
def __init__(self, stretch='linear', exponent=5, vmid=None, vmin=None, vmax=None, clip=False): """ Initalize an APLpyNormalize instance. :param vmin: Float. Minimum pixel value to use for the scaling. :param vmax: Float. Maximum pixel value to use for the scaling. :param stretch: String. ('linear', 'log', 'sqrt', 'arcsinh', 'power') The stretch function to use (default is 'linear'). :param vmid: Float. Mid-pixel value used for the log and arcsinh stretches. If set to None, a default value is picked. :param exponent: Float. If self.stretch is set to 'power', this is the exponent to use. :param clip: Bool. If clip is True and the given value falls outside the range, the returned value will be 0 or 1, whichever is closer. """ self.stretch = stretch self.exponent = exponent if vmax < vmin: raise Exception("vmax should be larger than vmin") # Call original initalization routine Normalize.__init__(self, vmin=vmin, vmax=vmax, clip=clip) if stretch == 'power' and self.exponent == 'None': raise Exception( "For stretch=='power', an exponent should be specified") if vmid == 'None': if stretch == 'log': if vmin > 0: self.midpoint = vmax / vmin else: raise Exception( "When using a log stretch, if vmin < 0, then vmid has to be specified" ) elif stretch == 'arcsinh': self.midpoint = -1. / 30. else: self.midpoint = None else: if stretch == 'log': if vmin < vmid: raise Exception( "When using a log stretch, vmin should be larger than vmid" ) self.midpoint = (vmax - vmid) / (vmin - vmid) elif stretch == 'arcsinh': self.midpoint = (vmid - vmin) / (vmax - vmin) else: self.midpoint = None
def __init__(self, vmin=None, vmax=None, stretch=None, clip=False): if HAS_MATPLOTLIB and MATPLOTLIB_LT_12: # Normalize is an old-style class Normalize.__init__(self, vmin=vmin, vmax=vmax, clip=clip) else: # Normalize is a new-style class super(ImageNormalize, self).__init__(vmin=vmin, vmax=vmax, clip=clip) self.vmin = vmin self.vmax = vmax self.stretch = stretch self.inverse_stretch = stretch.inverse
def __init__(self, vmin=None, vmax=None, midpoint=None, clip=False, nlevs=9): """.. warning:: MidpointNormalize is deprecated and will be removed in future versions. Please use :class:`timutils.get_discrete_midpt_cmap_norm` instead returns a colormap and a matplotlib.colors.Normalize instance that implement a *continuous* colormap with an arbitrary midpoint. ARGS: vmin (real): the minimum value in the colormap vmax (real): the maximum value in the colormap midpoint (real): the midpoint to center on clip (boolean): nlevs (integer): number of levels to divide the colormap into. Not currently functional. EXAMPLE: >>> import matplotlib.pyplot as plt >>> import numpy as np >>> from timutils.midpt_norm import MidpointNormalize >>> plt.close('all') >>> data = np.random.randint(-120, 20, [124, 124]) >>> fix, ax = plt.subplots(1, 2) >>> mycmap = plt.get_cmap('Blues') >>> mynorm = MidpointNormalize(vmin=-120, vmax=20, midpoint=0.0) >>> cm = ax[0].pcolormesh(data, norm=mynorm, cmap=mycmap) >>> plt.colorbar(cm, cax=ax[1], norm=mynorm, cmap=mycmap) >>> plt.show() adapted by Timothy W. Hilton from `code posted by Joe Kington <http://stackoverflow.com/questions/20144529/shifted-colorbar-matplotlib>`_ accessed 19 January 2015 """ warnings.warn(('MidpointNormalize is (1) deprecated and (2)' 'buggy and will be' 'removed in future versions. ' 'Please use get_discrete_midpt_cmap_norm instead')) self.midpoint = midpoint self.nlevs = nlevs Normalize.__init__(self, vmin, vmax, clip)
def __init__(self, vmin=None, vmax=None, img=None, clip=False): """Initialize Parameters ---------- vmin: float, default=`None` Minimum pixel value. If `vmin` is `None`, the minimum value of `img` will be used. vmax: float, default=`None` Maximum pixel value. If `vmin` is `None`, the maximum value of `img` will be used. img: array_like, default=`None` This should be an array with dimensions (bands, height, width). Either `vmin` and `vmax` or `img` is required to create an Asinh mapping clip: bool, default=`False` Whether or not to clip values. This is a default from matplotlib, but clip=True is currently not supported. """ Normalize.__init__(self, vmin, vmax, clip) if img is not None: vmin, vmax = self._get_scale(vmin, vmax, img) if vmin is not None and vmax is not None: self._set_scale(vmin, vmax)
def __init__(self, vmin=None, vmax=None, midpoint=None, clip=False): """ Requires a midpoint value """ self.midpoint = midpoint Normalize.__init__(self, vmin, vmax, clip)
def __init__(self, epoch0, epoch1): Normalize.__init__(self, self.mktime(epoch0), self.mktime(epoch1))
def __init__(self, vmin=None, vmax=None, midpoint=None, clip=False): """Initialise utility function.""" self.midpoint = midpoint Normalize.__init__(self, vmin, vmax, clip)
def __init__(self,linthresh,vmin=None,vmax=None,clip=False): Normalize.__init__(self,vmin,vmax,clip) self.linthresh=linthresh self.vmin, self.vmax = vmin, vmax
def __init__(self, func, *args, **kwargs): Normalize.__init__(self, *args, **kwargs) self._func = func
def __init__(self, levels): Normalize.__init__(self) self.x, self.y = levels, np.linspace(0, 1, num=len(levels))
def __init__(self, vmin=None, vmax=None, clip=False, vin=None, cin=0.01): self.vin = vin self.cin = cin Normalize.__init__(self, vmin, vmax, clip)
def __init__(self, fn, invfn, vmin=None, vmax=None, clip=False): Normalize.__init__(self, vmin, vmax, clip) self.fn = fn self.invfn = invfn
def __init__(self,vmin=None,vmax=None,clip=False): Normalize.__init__(self,vmin,vmax,clip)
def __init__(self, vmin=None, vmax=None, transition=None, clip=False): self.transition = transition Normalize.__init__(self, vmin, vmax, clip)
def __init__(self, vmin=None, vmax=None, clip=False): Normalize.__init__(self, vmin, vmax, clip)
def __init__(self, xvalues, cvalues): self.xvalues = xvalues self.cvalues = cvalues Normalize.__init__(self)
def __init__(self, levels, clip=False): # the input levels self._levels = np.sort(levels) # corresponding normalized values between 0 and 1 self._normed = np.linspace(0, 1, len(levels)) Normalize.__init__(self, None, None, clip)
def __init__(self, stretch='Linear', exponent=5, vmid=None, vmin=None, vmax=None, clip=False): """ MyNormalize-class is used for re-scalling the color-scheme Parameters ---------- stretch: str The stretch function to use (default is 'linear') for re-ordering the color-scaling. The options are: *'linear' *'log' *'sqrt' *'arcsinh' *'arccosh' *'power' *'exp' exponent: float exponent is set the 'power' of the exponent if used use. vmin: float Minimum pixel value to use for the scaling. vmax: float Maximum pixel value to use for the scaling. vmid: float Mid-pixel value used for the log and arcsinh stretches. If set to None, a default value is picked. clip: bool If clip is True and the given value falls outside the range, the returned value will be 0 or 1, whichever is closer. """ if vmax < vmin: raise Exception("vmax should be larger than vmin") # Call original initalization routine Normalize.__init__(self, vmin=vmin, vmax=vmax, clip=clip) # Save parameters self.stretch = stretch self.exponent = exponent if stretch == 'Power' and np.equal(self.exponent, None): raise Exception( "For stretch=='Power', an exponent should be specified") if np.equal(vmid, None): if stretch == 'Log': if vmin > 0: self.midpoint = vmax / vmin elif vmin <= 0: vmin = 0.00001 self.midpoint = vmax / vmin else: raise Exception( "When using a Log stretch, if vmin < 0, then vmid has to be specified" ) elif stretch == 'Arcsinh' or stretch == 'Arccosh': self.midpoint = -1. / 30. else: self.midpoint = None else: if stretch == 'Log': if vmin < vmid: raise Exception( "When using a Log stretch, vmin should be larger than vmid" ) self.midpoint = (vmax - vmid) / (vmin - vmid) elif stretch == 'Arcsinh' or stretch == 'Arccosh': self.midpoint = (vmid - vmin) / (vmax - vmin) else: self.midpoint = None
def __init__(self, vmin=None, vmax=None, midpoint=None, clip=False): self.midpoint = midpoint # m=max(abs(vmin),abs(vmax)) Normalize.__init__(self, vmin, vmax, clip)
def __init__(self): vmin = min(-1e-10, np.min([np.min(i) for i in images])) vmax = max(1e-10, np.max([np.max(i) for i in images])) Normalize.__init__(self, vmin, vmax)
def __init__(self, x): r = max(x.max(), -x.min()) Normalize.__init__(self, -r, r, False)