satpy.composites package
Submodules
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.
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, **kwargs)[source]
Bases:
GenericCompositor
Detect clouds based on thresholding and use it as a mask for compositing.
Collect custom configuration values.
- 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.
- 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 (List[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.
- 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 (List[arrays]) – Arrays to be checked
- 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 (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).
- 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'}
- 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.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.
- 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
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.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.