satpy.composites.core module

Core functionality of composites.

class satpy.composites.core.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.

__init__(name, prerequisites=None, optional_prerequisites=None, **kwargs)[source]

Initialise the compositor.

_add_missing_modifier(key, destination, origin)[source]
_check_areas_are_valid(areas)[source]
static _check_dimension_size(data_arrays, coordinate)[source]
_collect_modifier_info(origin, destination, dataset_keys)[source]
_is_existing_modifier(k)[source]
static align_geo_coordinates(data_arrays)[source]

Align DataArrays along geolocation coordinates.

See align() for more information. This function uses the “override” join method to essentially ignore differences between coordinates. The check_geolocation() should be called before this to ensure that geolocation coordinates and “area” are compatible. The drop_coordinates() method should be called before this to ensure that coordinates that are considered “negligible” when computing composites do not affect alignment.

Return type:

list[DataArray]

apply_modifier_info(origin, destination)[source]

Apply the modifier info from origin to destination.

check_geolocation(data_arrays)[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 (Sequence[DataArray]) – Arrays to be checked

Raises:
Return type:

None

static drop_coordinates(data_arrays)[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 (Sequence[DataArray]) – Arrays to be checked

Return type:

list[DataArray]

property id

Return the DataID of the object.

match_data_arrays(data_arrays)[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 (see satpy.utils.unify_chunks()).

Parameters:

data_arrays (Sequence[DataArray]) – Arrays to be checked

Return type:

list[DataArray]

Returns:

Arrays with negligible non-dimensional coordinates removed.

Raises:
class satpy.composites.core.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.

__init__(name, common_channel_mask=True, **kwargs)[source]

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.

_check_datasets_and_data(datasets, mode)[source]
_concat_datasets(projectables, mode)[source]
_get_mode(attrs, num)[source]
_get_sensors(projectables)[source]
_get_updated_attrs(datasets, attrs, mode)[source]
classmethod infer_mode(data_arr)[source]

Guess at the mode for a particular DataArray.

modes = {1: 'L', 2: 'LA', 3: 'RGB', 4: 'RGBA'}
exception satpy.composites.core.IncompatibleAreas[source]

Bases: Exception

Error raised upon compositing things of different shapes.

exception satpy.composites.core.IncompatibleTimes[source]

Bases: Exception

Error raised upon compositing things from different times.

satpy.composites.core.NEGLIGIBLE_COORDS = ['time']

Keywords identifying non-dimensional coordinates to be ignored during composite generation.

class satpy.composites.core.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.core.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.

static _update_missing_metadata(existing_attrs, new_attrs)[source]
satpy.composites.core._apply_palette_to_image(img)[source]
satpy.composites.core._check_alpha_band(data, bands)[source]
satpy.composites.core._check_mode_l(data, bands)[source]
satpy.composites.core._check_mode_p(data, bands)[source]
satpy.composites.core._collect_time_from_proj(times, proj)[source]
satpy.composites.core._get_average_time(times)[source]
satpy.composites.core._get_data_from_enhanced_image(dset, convert_p)[source]
satpy.composites.core.add_bands(data, bands)[source]

Add bands so that they match bands.

satpy.composites.core.check_times(projectables)[source]

Check that projectables have compatible times.

satpy.composites.core.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.