""" Data normalization operations. Normalizing input data into a valid range is a common operation and often required before further processing. The semantics of normalization are dependent on the element type being normalized making it difficult to provide a general and consistent interface. The Normalization class is used to define such an interface and subclasses are used to implement the appropriate normalization operations per element type. Unlike display normalization, data normalizations result in transformations to the stored data within each element. """ import param from ..core.operation import Operation from ..element import Raster from ..core import Overlay from ..core.util import match_spec class Normalization(Operation): """ Base class for all normalization operation. This class standardizes how normalization is specified using the ranges and keys parameter. The ranges parameter is designed to be very flexible, allowing a concise description for simple normalization while allowing complex key- and element- specific normalization to also be specified. """ data_range = param.Boolean(default=False, doc=""" Whether normalization is allowed to use the minimum and maximum values of the existing data to infer an appropriate range""") ranges = param.ClassSelector(default={}, allow_None=True, class_=(dict, list), doc=""" The simplest value of this parameter is None to skip all normalization. The next simplest value is an empty dictionary to only applies normalization to Dimensions with explicitly declared ranges. The next most common specification is a dictionary of values and tuple ranges. The value keys are the names of the dimensions to be normalized and the tuple ranges are of form (lower-bound, upper-bound). For instance, you could specify: {'Height':(0, 200), 'z':(0,1)} In this case, any element with a 'Height' or 'z' dimension (or both) will be normalized to the supplied ranges. Finally, element-specific normalization may also be specified by supplying a match tuple of form (, ,