satpy.composites package
Submodules
- satpy.composites.abi module
- satpy.composites.agri module
- satpy.composites.ahi module
- satpy.composites.cloud_products module
- satpy.composites.config_loader module
_CompositeConfigHelper
_CompositeConfigHelper._create_comp_from_info()
_CompositeConfigHelper._get_compositor_loader_from_config()
_CompositeConfigHelper._handle_inline_comp_dep()
_CompositeConfigHelper._load_config_composite()
_CompositeConfigHelper._load_config_composites()
_CompositeConfigHelper._process_composite_deps()
_CompositeConfigHelper.parse_config()
_ModifierConfigHelper
_convert_dep_info_to_data_query()
_get_sensor_id_keys()
_load_config()
_lru_cache_with_config_path()
_update_cached_wrapper()
all_composite_sensors()
load_compositor_configs_for_sensor()
load_compositor_configs_for_sensors()
- satpy.composites.glm module
- satpy.composites.sar module
- satpy.composites.spectral module
- satpy.composites.viirs module
AdaptiveDNB
ERFDNB
HistogramDNB
NCCZinke
SnowAge
_calculate_weights()
_check_moon_phase()
_compute_tile_dist_and_bin_info()
_get_cumul_bin_info_for_tile()
_histogram_equalization_helper()
_histogram_equalize_one_tile()
_interpolate_local_equalized_tiles()
_linear_normalization_from_0to1()
histogram_equalization()
local_histogram_equalization()
make_day_night_masks()
Module contents
Base classes for composite objects.
- class satpy.composites.BackgroundCompositor(name, common_channel_mask=True, **kwargs)[source]
Bases:
GenericCompositor
A compositor that overlays one composite on top of another.
The output image mode will be determined by both foreground and background. Generally, when the background has an alpha band, the output image will also have one.
Foreground
Background
Result
L
L
L
L
LA
LA
L
RGB
RGB
L
RGBA
RGBA
LA
L
L
LA
LA
LA
LA
RGB
RGB
LA
RGBA
RGBA
RGB
L
RGB
RGB
LA
RGBA
RGB
RGB
RGB
RGB
RGBA
RGBA
RGBA
L
RGB
RGBA
LA
RGBA
RGBA
RGB
RGB
RGBA
RGBA
RGBA
Collect custom configuration values.
- Parameters:
common_channel_mask (bool) – If True, mask all the channels with a mask that combines all the invalid areas of the given data.
- class satpy.composites.CategoricalDataCompositor(name, lut=None, **kwargs)[source]
Bases:
CompositeBase
Compositor used to recategorize categorical data using a look-up-table.
Each value in the data array will be recategorized to a new category defined in the look-up-table using the original value as an index for that look-up-table.
Example
data = [[1, 3, 2], [4, 2, 0]] lut = [10, 20, 30, 40, 50] res = [[20, 40, 30], [50, 30, 10]]
Get look-up-table used to recategorize data.
- Parameters:
lut (list) – a list of new categories. The lenght must be greater than the maximum value in the data array that should be recategorized.
- class satpy.composites.CloudCompositor(name, transition_min=258.15, transition_max=298.15, transition_gamma=3.0, invert_alpha=False, **kwargs)[source]
Bases:
GenericCompositor
Detect clouds based on thresholding and use it as a mask for compositing.
Collect custom configuration values.
- Parameters:
transition_min (float) – Values below or equal to this are clouds -> opaque white
transition_max (float) – Values above this are cloud free -> transparent
transition_gamma (float) – Gamma correction to apply at the end
invert_alpha (bool) – Invert the alpha channel to make low data values transparent and high data values opaque.
- class satpy.composites.ColorizeCompositor(name, common_channel_mask=True, **kwargs)[source]
Bases:
ColormapCompositor
A compositor colorizing the data, interpolating the palette colors when needed.
Warning
Deprecated since Satpy 0.39. See the
ColormapCompositor
docstring for documentation on the alternative.Collect custom configuration values.
- Parameters:
common_channel_mask (bool) – If True, mask all the channels with a mask that combines all the invalid areas of the given data.
- class satpy.composites.ColormapCompositor(name, common_channel_mask=True, **kwargs)[source]
Bases:
GenericCompositor
A compositor that uses colormaps.
Warning
Deprecated since Satpy 0.39.
This compositor is deprecated. To apply a colormap, use a
SingleBandCompositor
composite with acolorize()
orpalettize()
enhancement instead. For example, to make acloud_top_height
composite based on a datasetctth_alti
palettized byctth_alti_pal
, the composite would be:cloud_top_height: compositor: !!python/name:satpy.composites.SingleBandCompositor prerequisites: - ctth_alti tandard_name: cloud_top_height
and the enhancement:
cloud_top_height: standard_name: cloud_top_height operations: - name: palettize method: !!python/name:satpy.enhancements.palettize kwargs: palettes: - dataset: ctth_alti_pal color_scale: 255 min_value: 0 max_value: 255
Collect custom configuration values.
- Parameters:
common_channel_mask (bool) – If True, mask all the channels with a mask that combines all the invalid areas of the given data.
- static build_colormap(palette, dtype, info)[source]
Create the colormap from the raw_palette and the valid_range.
Colormaps come in different forms, but they are all supposed to have color values between 0 and 255. The following cases are considered:
Palettes comprised of only a list of colors. If dtype is uint8, the values of the colormap are the enumeration of the colors. Otherwise, the colormap values will be spread evenly from the min to the max of the valid_range provided in info.
Palettes that have a palette_meanings attribute. The palette meanings will be used as values of the colormap.
- class satpy.composites.CompositeBase(name, prerequisites=None, optional_prerequisites=None, **kwargs)[source]
Bases:
object
Base class for all compositors and modifiers.
A compositor in Satpy is a class that takes in zero or more input DataArrays and produces a new DataArray with its own identifier (name). The result of a compositor is typically a brand new “product” that represents something different than the inputs that went into the operation.
See the
ModifierBase
class for information on the similar concept of “modifiers”.Initialise the compositor.
- static align_geo_coordinates(data_arrays: Sequence[DataArray]) list[DataArray] [source]
Align DataArrays along geolocation coordinates.
See
align()
for more information. This function uses the “override” join method to essentially ignore differences between coordinates. Thecheck_geolocation()
should be called before this to ensure that geolocation coordinates and “area” are compatible. Thedrop_coordinates()
method should be called before this to ensure that coordinates that are considered “negligible” when computing composites do not affect alignment.
- apply_modifier_info(origin, destination)[source]
Apply the modifier info from origin to destination.
- check_geolocation(data_arrays: Sequence[DataArray]) None [source]
Check that the geolocations of the data_arrays are compatible.
For the purpose of this method, “compatible” means:
All arrays should have the same dimensions.
Either all arrays should have an area, or none should.
If all have an area, the areas should be all the same.
- Parameters:
data_arrays – Arrays to be checked
- Raises:
IncompatibleAreas – If dimension or areas do not match.
ValueError – If some, but not all data arrays lack an area attribute.
- static drop_coordinates(data_arrays: Sequence[DataArray]) list[DataArray] [source]
Drop negligible non-dimensional coordinates.
Drops negligible coordinates if they do not correspond to any dimension. Negligible coordinates are defined in the
NEGLIGIBLE_COORDS
module attribute.- Parameters:
data_arrays (List[arrays]) – Arrays to be checked
- property id
Return the DataID of the object.
- match_data_arrays(data_arrays: Sequence[DataArray]) list[DataArray] [source]
Match data arrays so that they can be used together in a composite.
For the purpose of this method, “can be used together” means:
All arrays should have the same dimensions.
Either all arrays should have an area, or none should.
If all have an area, the areas should be all the same.
In addition, negligible non-dimensional coordinates are dropped (see
drop_coordinates()
) and dask chunks are unified (seesatpy.utils.unify_chunks()
).- Parameters:
data_arrays (List[arrays]) – Arrays to be checked
- Returns:
Arrays with negligible non-dimensional coordinates removed.
- Return type:
data_arrays (List[arrays])
- Raises:
IncompatibleAreas – If dimension or areas do not match.
ValueError – If some, but not all data arrays lack an area attribute.
- class satpy.composites.DayNightCompositor(name, lim_low=85.0, lim_high=88.0, day_night='day_night', include_alpha=True, **kwargs)[source]
Bases:
GenericCompositor
A compositor that blends day data with night data.
Using the day_night flag it is also possible to provide only a day product or only a night product and mask out (make transparent) the opposite portion of the image (night or day). See the documentation below for more details.
Collect custom configuration values.
- Parameters:
lim_low (float) – lower limit of Sun zenith angle for the blending of the given channels
lim_high (float) – upper limit of Sun zenith angle for the blending of the given channels
day_night (string) – “day_night” means both day and night portions will be kept “day_only” means only day portion will be kept “night_only” means only night portion will be kept
include_alpha (bool) – This only affects the “day only” or “night only” result. True means an alpha band will be added to the output image for transparency. False means the output is a single-band image with undesired pixels being masked out (replaced with NaNs).
- _get_data_for_single_side_product(foreground_data: DataArray, weights: DataArray) tuple[DataArray, DataArray, DataArray] [source]
- class satpy.composites.DifferenceCompositor(name, prerequisites=None, optional_prerequisites=None, **kwargs)[source]
Bases:
CompositeBase
Make the difference of two data arrays.
Initialise the compositor.
- class satpy.composites.Filler(name, common_channel_mask=True, **kwargs)[source]
Bases:
GenericCompositor
Fix holes in projectable 1 with data from projectable 2.
Collect custom configuration values.
- Parameters:
common_channel_mask (bool) – If True, mask all the channels with a mask that combines all the invalid areas of the given data.
- class satpy.composites.FillingCompositor(name, common_channel_mask=True, **kwargs)[source]
Bases:
GenericCompositor
Make a regular RGB, filling the RGB bands with the first provided dataset’s values.
Collect custom configuration values.
- Parameters:
common_channel_mask (bool) – If True, mask all the channels with a mask that combines all the invalid areas of the given data.
- class satpy.composites.GenericCompositor(name, common_channel_mask=True, **kwargs)[source]
Bases:
CompositeBase
Basic colored composite builder.
Collect custom configuration values.
- Parameters:
common_channel_mask (bool) – If True, mask all the channels with a mask that combines all the invalid areas of the given data.
- modes = {1: 'L', 2: 'LA', 3: 'RGB', 4: 'RGBA'}
- class satpy.composites.HighCloudCompositor(name, transition_min_limits=(210.0, 230.0), latitude_min_limits=(30.0, 60.0), transition_max=300, transition_gamma=1.0, **kwargs)[source]
Bases:
CloudCompositor
Detect high clouds based on latitude-dependent thresholding and use it as a mask for compositing.
This compositor aims at identifying high clouds and assigning them a transparency based on the brightness temperature (cloud opacity). In contrast to the CloudCompositor, the brightness temperature threshold at the lower end, used to identify high opaque clouds, is made a function of the latitude in order to have tropopause level clouds appear opaque at both high and low latitudes. This follows the Geocolor implementation of high clouds in Miller et al. (2020, DOI:10.1175/JTECH-D-19-0134.1), but with some adjustments to the thresholds based on recent developments and feedback from CIRA.
The two brightness temperature thresholds in transition_min are used together with the corresponding latitude limits in latitude_min to compute a modified version of transition_min that is later used when calling CloudCompositor. The modified version of transition_min will be an array with the same shape as the input projectable dataset, where the actual values of threshold_min are a function of the dataset latitude:
transition_min = transition_min[0] where abs(latitude) < latitude_min(0)
transition_min = transition_min[1] where abs(latitude) > latitude_min(0)
- transition_min = linear interpolation between transition_min[0] and transition_min[1] as a function
of where abs(latitude).
Collect custom configuration values.
- Parameters:
transition_min_limits (tuple) – Brightness temperature values used to identify opaque white clouds at different latitudes
transition_max (float) – Brightness temperatures above this value are not considered to be high clouds -> transparent
latitude_min_limits (tuple) – Latitude values defining the intervals for computing latitude-dependent transition_min values from transition_min_limits.
transition_gamma (float) – Gamma correction to apply to the alpha channel within the brightness temperature range (transition_min to transition_max).
- exception satpy.composites.IncompatibleAreas[source]
Bases:
Exception
Error raised upon compositing things of different shapes.
- exception satpy.composites.IncompatibleTimes[source]
Bases:
Exception
Error raised upon compositing things from different times.
- class satpy.composites.LongitudeMaskingCompositor(name, lon_min=None, lon_max=None, **kwargs)[source]
Bases:
SingleBandCompositor
Masks areas outside defined longitudes.
Collect custom configuration values.
- class satpy.composites.LowCloudCompositor(name, values_land=(1,), values_water=(0,), range_land=(0.0, 4.0), range_water=(0.0, 4.0), transition_gamma=1.0, invert_alpha=True, **kwargs)[source]
Bases:
CloudCompositor
Detect low-level clouds based on thresholding and use it as a mask for compositing during night-time.
This compositor computes the brightness temperature difference between a window channel (e.g. 10.5 micron) and the near-infrared channel e.g. (3.8 micron) and uses this brightness temperature difference, BTD, to create a partially transparent mask for compositing.
Pixels with BTD values below a given threshold will be transparent, whereas pixels with BTD values above another threshold will be opaque. The transparency of all other BTD values will be a linear function of the BTD value itself. Two sets of thresholds are used, one set for land surface types (range_land) and another one for water surface types (range_water), respectively. Hence, this compositor requires a land-water-mask as a prerequisite input. This follows the GeoColor implementation of night-time low-level clouds in Miller et al. (2020, DOI:10.1175/JTECH-D-19-0134.1), but with some adjustments to the thresholds based on recent developments and feedback from CIRA.
Please note that the spectral test and thus the output of the compositor (using the expected input data) is only applicable during night-time.
Init info.
Collect custom configuration values.
- Parameters:
values_land (list) – List of values used to identify land surface pixels in the land-water-mask.
values_water (list) – List of values used to identify water surface pixels in the land-water-mask.
range_land (tuple) – Threshold values used for masking low-level clouds from the brightness temperature difference over land surface types.
range_water (tuple) – Threshold values used for masking low-level clouds from the brightness temperature difference over water.
transition_gamma (float) – Gamma correction to apply to the alpha channel within the brightness temperature difference range.
invert_alpha (bool) – Invert the alpha channel to make low data values transparent and high data values opaque.
- class satpy.composites.LuminanceSharpeningCompositor(name, common_channel_mask=True, **kwargs)[source]
Bases:
GenericCompositor
Create a high resolution composite by sharpening a low resolution using high resolution luminance.
This is done by converting to YCbCr colorspace, replacing Y, and convertin back to RGB.
Collect custom configuration values.
- Parameters:
common_channel_mask (bool) – If True, mask all the channels with a mask that combines all the invalid areas of the given data.
- class satpy.composites.MaskingCompositor(name, transparency=None, conditions=None, mode='LA', **kwargs)[source]
Bases:
GenericCompositor
A compositor that masks e.g. IR 10.8 channel data using cloud products from NWC SAF.
Collect custom configuration values.
- Kwargs:
- transparency (dict): transparency for each cloud type as
key-value pairs in a dictionary. Will be converted to conditions. DEPRECATED.
- conditions (list): list of three items determining the masking
settings.
- mode (str, optional): Image mode to return. For single-band input,
this shall be “LA” (default) or “RGBA”. For multi-band input, this argument is ignored as the result is always RGBA.
Each condition in conditions consists of three items:
- method: Numpy method name. The following are supported
operations: less, less_equal, equal, greater_equal, greater, not_equal, isnan, isfinite, isinf, isneginf, or isposinf.
- value: threshold value of the mask applied with the
operator. Can be a string, in which case the corresponding value will be determined from flag_meanings and flag_values attributes of the mask. NOTE: the value should not be given to ‘is*` methods.
- transparency: transparency from interval [0 … 100] used
for the method/threshold. Value of 100 is fully transparent.
Example:
>>> conditions = [{'method': 'greater_equal', 'value': 0, 'transparency': 100}, {'method': 'greater_equal', 'value': 1, 'transparency': 80}, {'method': 'greater_equal', 'value': 2, 'transparency': 0}, {'method': 'isnan', 'transparency': 100}] >>> compositor = MaskingCompositor("masking compositor", transparency=transparency) >>> result = compositor([data, mask])
This will set transparency of data based on the values in the mask dataset. Locations where mask has values of 0 will be fully transparent, locations with 1 will be semi-transparent and locations with 2 will be fully visible in the resulting image. In the end all NaN areas in the mask are set to full transparency. All the unlisted locations will be visible.
The transparency is implemented by adding an alpha layer to the composite. The locations with transparency of 100 will be set to NaN in the data. If the input data contains an alpha channel, it will be discarded.
- _get_alpha_bands(data, mask_in, alpha_attrs)[source]
Get alpha bands.
From input data, masks, and attributes, get alpha band.
- _get_mask(method, value, mask_data)[source]
Get mask array from mask_data using method and threshold value.
The method is the name of a numpy function.
- _select_data_bands(data_in)[source]
Select data to be composited from input data.
From input data, select the bands that need to have masking applied.
- _set_data_nans(data, mask, attrs)[source]
Set data to nans where mask is True.
The attributes attrs* will be written to each band in data.
- _supported_modes = {'LA', 'RGBA'}
- class satpy.composites.MultiFiller(name, prerequisites=None, optional_prerequisites=None, **kwargs)[source]
Bases:
SingleBandCompositor
Fix holes in projectable 1 with data from the next projectables.
Initialise the compositor.
- satpy.composites.NEGLIGIBLE_COORDS = ['time']
Keywords identifying non-dimensional coordinates to be ignored during composite generation.
- class satpy.composites.NaturalEnh(name, ch16_w=1.3, ch08_w=2.5, ch06_w=2.2, *args, **kwargs)[source]
Bases:
GenericCompositor
Enhanced version of natural color composite by Simon Proud.
- Parameters:
Initialize the class.
- class satpy.composites.PaletteCompositor(name, common_channel_mask=True, **kwargs)[source]
Bases:
ColormapCompositor
A compositor colorizing the data, not interpolating the palette colors.
Warning
Deprecated since Satpy 0.39. See the
ColormapCompositor
docstring for documentation on the alternative.Collect custom configuration values.
- Parameters:
common_channel_mask (bool) – If True, mask all the channels with a mask that combines all the invalid areas of the given data.
- class satpy.composites.RGBCompositor(name, common_channel_mask=True, **kwargs)[source]
Bases:
GenericCompositor
Make a composite from three color bands (deprecated).
Collect custom configuration values.
- Parameters:
common_channel_mask (bool) – If True, mask all the channels with a mask that combines all the invalid areas of the given data.
- class satpy.composites.RatioCompositor(name, prerequisites=None, optional_prerequisites=None, **kwargs)[source]
Bases:
CompositeBase
Make the ratio of two data arrays.
Initialise the compositor.
- class satpy.composites.RatioSharpenedRGB(*args, **kwargs)[source]
Bases:
GenericCompositor
Sharpen RGB bands with ratio of a high resolution band to a lower resolution version.
Any pixels where the ratio is computed to be negative or infinity, it is reset to 1. Additionally, the ratio is limited to 1.5 on the high end to avoid high changes due to small discrepancies in instrument detector footprint. Note that the input data to this compositor must already be resampled so all data arrays are the same shape.
Example:
R_lo - 1000m resolution - shape=(2000, 2000) G - 1000m resolution - shape=(2000, 2000) B - 1000m resolution - shape=(2000, 2000) R_hi - 500m resolution - shape=(4000, 4000) ratio = R_hi / R_lo new_R = R_hi new_G = G * ratio new_B = B * ratio
In some cases, there could be multiple high resolution bands:
R_lo - 1000m resolution - shape=(2000, 2000) G_hi - 500m resolution - shape=(4000, 4000) B - 1000m resolution - shape=(2000, 2000) R_hi - 500m resolution - shape=(4000, 4000)
To avoid the green band getting involved in calculating ratio or sharpening, add “neutral_resolution_band: green” in the YAML config file. This way only the blue band will get sharpened:
ratio = R_hi / R_lo new_R = R_hi new_G = G_hi new_B = B * ratio
Instanciate the ration sharpener.
- class satpy.composites.RealisticColors(name, common_channel_mask=True, **kwargs)[source]
Bases:
GenericCompositor
Create a realistic colours composite for SEVIRI.
Collect custom configuration values.
- Parameters:
common_channel_mask (bool) – If True, mask all the channels with a mask that combines all the invalid areas of the given data.
- class satpy.composites.SandwichCompositor(name, common_channel_mask=True, **kwargs)[source]
Bases:
GenericCompositor
Make a sandwich product.
Collect custom configuration values.
- Parameters:
common_channel_mask (bool) – If True, mask all the channels with a mask that combines all the invalid areas of the given data.
- class satpy.composites.SelfSharpenedRGB(*args, **kwargs)[source]
Bases:
RatioSharpenedRGB
Sharpen RGB with ratio of a band with a strided-version of itself.
Example:
R - 500m resolution - shape=(4000, 4000) G - 1000m resolution - shape=(2000, 2000) B - 1000m resolution - shape=(2000, 2000) ratio = R / four_element_average(R) new_R = R new_G = G * ratio new_B = B * ratio
Instanciate the ration sharpener.
- class satpy.composites.SingleBandCompositor(name, prerequisites=None, optional_prerequisites=None, **kwargs)[source]
Bases:
CompositeBase
Basic single-band composite builder.
This preserves all the attributes of the dataset it is derived from.
Initialise the compositor.
- class satpy.composites.StaticImageCompositor(name, filename=None, url=None, known_hash=None, area=None, **kwargs)[source]
Bases:
GenericCompositor
,DataDownloadMixin
A compositor that loads a static image from disk.
Environment variables in the filename are automatically expanded.
Collect custom configuration values.
- Parameters:
filename (str) – Name to use when storing and referring to the file in the
data_dir
cache. Ifurl
is provided (preferred), then this is used as the filename in the cache and will be appended to<data_dir>/composites/<class_name>/
. Ifurl
is provided andfilename
is not then thefilename
will be guessed from theurl
. Ifurl
is not provided, then it is assumedfilename
refers to a local file. If thefilename
does not come with an absolute path,data_dir
will be used as the directory path. Environment variables are expanded.url (str) – URL to remote file. When the composite is created the file will be downloaded and cached in Satpy’s
data_dir
. Environment variables are expanded.known_hash (str or None) – Hash of the remote file used to verify a successful download. If not provided then the download will not be verified. See
satpy.aux_download.register_file()
for more information.area (str) – Name of area definition for the image. Optional for images with built-in area definitions (geotiff).
- Use cases:
url + no filename: Satpy determines the filename based on the filename in the URL, then downloads the URL, and saves it to <data_dir>/<filename>. If the file already exists and known_hash is also provided, then the pooch library compares the hash of the file to the known_hash. If it does not match, then the URL is re-downloaded. If it matches then no download.
url + relative filename: Same as case 1 but filename is already provided so download goes to <data_dir>/<filename>. Same hashing behavior. This does not check for an absolute path.
No url + absolute filename: No download, filename is passed directly to generic_image reader. No hashing is done.
No url + relative filename: Check if <data_dir>/<filename> exists. If it does then make filename an absolute path. If it doesn’t, then keep it as is and let the exception at the bottom of the method get raised.
- class satpy.composites.SumCompositor(name, prerequisites=None, optional_prerequisites=None, **kwargs)[source]
Bases:
CompositeBase
Make the sum of two data arrays.
Initialise the compositor.
- satpy.composites._get_flag_value(mask, val)[source]
Get a numerical value of the named flag.
This function assumes the naming used in product generated with NWC SAF GEO/PPS softwares.
- satpy.composites.add_alpha_bands(data)[source]
Only used for DayNightCompositor.
Add an alpha band to L or RGB composite as prerequisites for the following band matching to make the masked-out area transparent.
- satpy.composites.enhance2dataset(dset, convert_p=False)[source]
Return the enhancement dataset dset as an array.
If convert_p is True, enhancements generating a P mode will be converted to RGB or RGBA.