satpy.enhancements package¶
Submodules¶
satpy.enhancements.abi module¶
Enhancement functions specific to the ABI sensor.
satpy.enhancements.mimic module¶
Mimic TPW Color enhancements.
satpy.enhancements.viirs module¶
Module contents¶
Enhancements.
-
satpy.enhancements.
apply_enhancement
(data, func, exclude=None, separate=False, pass_dask=False)[source]¶ Apply func to the provided data.
- Parameters
data (xarray.DataArray) – Data to be modified inplace.
func (callable) – Function to be applied to an xarray
exclude (iterable) – Bands in the ‘bands’ dimension to not include in the calculations.
separate (bool) – Apply func one band at a time. Default is False.
pass_dask (bool) – Pass the underlying dask array instead of the xarray.DataArray.
-
satpy.enhancements.
btemp_threshold
(img, min_in, max_in, threshold, threshold_out=None, **kwargs)[source]¶ Scale data linearly in two separate regions.
This enhancement scales the input data linearly by splitting the data into two regions; min_in to threshold and threshold to max_in. These regions are mapped to 1 to threshold_out and threshold_out to 0 respectively, resulting in the data being “flipped” around the threshold. A default threshold_out is set to 176.0 / 255.0 to match the behavior of the US National Weather Service’s forecasting tool called AWIPS.
- Parameters
img (XRImage) – Image object to be scaled
min_in (float) – Minimum input value to scale
max_in (float) – Maximum input value to scale
threshold (float) – Input value where to split data in to two regions
threshold_out (float) – Output value to map the input threshold to. Optional, defaults to 176.0 / 255.0.
-
satpy.enhancements.
cira_stretch
(img, **kwargs)[source]¶ Logarithmic stretch adapted to human vision.
Applicable only for visible channels.
-
satpy.enhancements.
colorize
(img, **kwargs)[source]¶ Colorize the given image.
- Parameters
img – image to be colorized
- Kwargs:
palettes: colormap(s) to use
- The palettes kwarg can be one of the following:
a trollimage.colormap.Colormap object
- list of dictionaries with each of one of the following forms:
- {‘filename’: ‘/path/to/colors.npy’,
‘min_value’: <float, min value to match colors to>, ‘max_value’: <float, min value to match colors to>, ‘reverse’: <bool, reverse the colormap if True (default: False)}
- {‘colors’: <trollimage.colormap.Colormap instance>,
‘min_value’: <float, min value to match colors to>, ‘max_value’: <float, min value to match colors to>, ‘reverse’: <bool, reverse the colormap if True (default: False)}
- {‘colors’: <tuple of RGB(A) tuples>,
‘min_value’: <float, min value to match colors to>, ‘max_value’: <float, min value to match colors to>, ‘reverse’: <bool, reverse the colormap if True (default: False)}
- {‘colors’: <tuple of RGB(A) tuples>,
‘values’: <tuple of values to match colors to>, ‘min_value’: <float, min value to match colors to>, ‘max_value’: <float, min value to match colors to>, ‘reverse’: <bool, reverse the colormap if True (default: False)}
If multiple palettes are supplied, they are concatenated before applied.
-
satpy.enhancements.
create_colormap
(palette)[source]¶ Create colormap of the given numpy file, color vector, or colormap.
- Parameters
palette (dict) – Information describing how to create a colormap object. See below for more details.
From a file
Colormaps can be loaded from
.npy
files as 2D raw arrays with rows for each color. The filename to load can be provided with thefilename
key in the provided palette information. The colormap is interpreted as 1 of 4 different “colormap modes”:RGB
,RGBA
,VRGB
, orVRGBA
. The colormap mode can be forced with thecolormap_mode
key in the provided palette information. If it is not provided then a default will be chosen based on the number of columns in the array (3: RGB, 4: VRGB, 5: VRGBA).The “V” in the possible colormap modes represents the control value of where that color should be applied. If “V” is not provided in the colormap data it defaults to the row index in the colormap array (0, 1, 2, …) divided by the total number of colors to produce a number between 0 and 1. See the “Set Range” section below for more information. The remaining elements in the colormap array represent the Red (R), Green (G), and Blue (B) color to be mapped to.
See the “Color Scale” section below for more information on the value range of provided numbers.
From a list
Colormaps can be loaded from lists of colors provided by the
colors
key in the provided dictionary. Each element in the list represents a single color to be mapped to and can be 3 (RGB) or 4 (RGBA) elements long. By default the value or control point for a color is determined by the index in the list (0, 1, 2, …) divided by the total number of colors to produce a number between 0 and 1. This can be overridden by providing avalues
key in the provided dictionary. See the “Set Range” section below for more information.See the “Color Scale” section below for more information on the value range of provided numbers.
From a builtin colormap
Colormaps can be loaded by name from the builtin colormaps in the
trollimage`
package. Specify the name with thecolors
key in the provided dictionary (ex.{'colors': 'blues'}
). See Colormap for the full list of available colormaps.Color Scale
By default colors are expected to be in a 0-255 range. This can be overridden by specifying
color_scale
in the provided colormap information. A common alternative to 255 is1
to specify floating point numbers between 0 and 1. The resulting Colormap uses the normalized color values (0-1).Set Range
By default the control points or values of the Colormap are between 0 and 1. This means that data values being mapped to a color must also be between 0 and 1. When this is not the case, the expected input range of the data can be used to configure the Colormap and change the control point values. To do this specify the input data range with
min_value
andmax_value
. Seetrollimage.colormap.Colormap.set_range()
for more information.
-
satpy.enhancements.
crefl_scaling
(img, **kwargs)[source]¶ Apply non-linear stretch used by CREFL-based RGBs.