satpy.composites package

Submodules

Module contents

Base classes for composite objects.

class satpy.composites.BackgroundCompositor(name, common_channel_mask=True, **kwargs)[source]

Bases: satpy.composites.GenericCompositor

A compositor that overlays one composite on top of another.

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: satpy.composites.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, **kwargs)[source]

Bases: satpy.composites.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

class satpy.composites.ColorizeCompositor(name, common_channel_mask=True, **kwargs)[source]

Bases: satpy.composites.ColormapCompositor

A compositor colorizing the data, interpolating the palette colors when needed.

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: satpy.composites.GenericCompositor

A compositor that uses colormaps.

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 on 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.

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.

apply_modifier_info(origin, destination)[source]

Apply the modifier info from origin to destination.

check_areas(data_arrays)[source]

Check that the areas of the data_arrays are compatible.

check_geolocation(data_arrays)[source]

Check that the geolocations of the data_arrays are compatible.

drop_coordinates(data_arrays)[source]

Drop neglible non-dimensional coordinates.

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.

class satpy.composites.DayNightCompositor(name, lim_low=85.0, lim_high=88.0, day_night='day_night', **kwargs)[source]

Bases: satpy.composites.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

class satpy.composites.DifferenceCompositor(name, prerequisites=None, optional_prerequisites=None, **kwargs)[source]

Bases: satpy.composites.CompositeBase

Make the difference of two data arrays.

Initialise the compositor.

class satpy.composites.Filler(name, common_channel_mask=True, **kwargs)[source]

Bases: satpy.composites.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: satpy.composites.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: satpy.composites.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.

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.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: satpy.composites.GenericCompositor

Masks areas outside defined longitudes.

Collect custom configuration values.

Parameters
  • lon_min (float) – lower longitude limit

  • lon_max (float) – upper longitude limit

class satpy.composites.LuminanceSharpeningCompositor(name, common_channel_mask=True, **kwargs)[source]

Bases: satpy.composites.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, **kwargs)[source]

Bases: satpy.composites.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.

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.

class satpy.composites.MultiFiller(name, common_channel_mask=True, **kwargs)[source]

Bases: satpy.composites.GenericCompositor

Fix holes in projectable 1 with data from the next projectables.

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.

satpy.composites.NEGLIBLE_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: satpy.composites.GenericCompositor

Enhanced version of natural color composite by Simon Proud.

Parameters
  • ch16_w (float) – weight for red channel (1.6 um). Default: 1.3

  • ch08_w (float) – weight for green channel (0.8 um). Default: 2.5

  • ch06_w (float) – weight for blue channel (0.6 um). Default: 2.2

Initialize the class.

class satpy.composites.PaletteCompositor(name, common_channel_mask=True, **kwargs)[source]

Bases: satpy.composites.ColormapCompositor

A compositor colorizing the data, not interpolating the palette colors.

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: satpy.composites.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.RatioSharpenedRGB(*args, **kwargs)[source]

Bases: satpy.composites.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

Instanciate the ration sharpener.

class satpy.composites.RealisticColors(name, common_channel_mask=True, **kwargs)[source]

Bases: satpy.composites.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: satpy.composites.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: satpy.composites.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.

static four_element_average_dask(d)[source]

Average every 4 elements (2x2) in a 2D array.

class satpy.composites.SingleBandCompositor(name, prerequisites=None, optional_prerequisites=None, **kwargs)[source]

Bases: satpy.composites.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: satpy.composites.GenericCompositor, satpy.aux_download.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. If url is provided (preferred), then this is used as the filename in the cache and will be appended to <data_dir>/composites/<class_name>/. If url is provided and filename is not then the filename will be guessed from the url. If url is not provided, then it is assumed filename refers to a local file. If the filename 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:
  1. 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.

  2. 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.

  3. No url + absolute filename: No download, filename is passed directly to generic_image reader. No hashing is done.

  4. 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.

register_data_files(data_files)[source]

Tell Satpy about files we may want to download.

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.add_bands(data, bands)[source]

Add bands so that they match bands.

satpy.composites.check_times(projectables)[source]

Check that projectables have compatible times.

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.

satpy.composites.sub_arrays(proj1, proj2)[source]

Substract two DataArrays and combine their attrs.

satpy.composites.zero_missing_data(data1, data2)[source]

Replace NaN values with zeros in data1 if the data is valid in data2.