nws_tools.
normalize
(arr, vmin=0, vmax=1)[source]¶Re-scales a NumPy ndarray
Parameters: | arr : NumPy ndarray
vmin : float
vmin : float
|
---|---|
Returns: | arrn : NumPy ndarray
|
See also
Notes
In contrast to Matplotlib’s Normalize, all values of the input array are re-scaled, even if outside the specified bounds. For instance, if arr.min() == -1 and arr.max() == 0.5 then calling normalize with bounds vmin = 0 and vmax = 1 will result in an array arrn satisfying arrn.min() == 0 and arrn.max() == 1.
Examples
>>> arr = array([[-1,.2],[100,0]])
>>> arrn = normalize(arr,vmin=-10,vmax=12)
>>> arrn
array([[-10. , -9.73861386],
[ 12. , -10. ]])