Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into fix_generic_open_mode
Browse files Browse the repository at this point in the history
  • Loading branch information
pdebuyl committed Apr 6, 2022
2 parents 9d0bd6a + 48b2356 commit fc5f776
Show file tree
Hide file tree
Showing 12 changed files with 326 additions and 222 deletions.
1 change: 1 addition & 0 deletions continuous_integration/environment.yaml
Expand Up @@ -11,6 +11,7 @@ dependencies:
- Cython
- sphinx
- cartopy
- panel>=0.12.7
- pillow
- matplotlib
- scipy
Expand Down
61 changes: 61 additions & 0 deletions doc/source/enhancements.rst
Expand Up @@ -93,6 +93,67 @@ lookup
colorize
--------


The colorize enhancement can be used to map scaled/calibrated physical values
to colors. One or several `standard Trollimage color maps`_ may be used as in
the example here::

- name: colorize
method: !!python/name:satpy.enhancements.colorize
kwargs:
palettes:
- {colors: spectral, min_value: 193.15, max_value: 253.149999}
- {colors: greys, min_value: 253.15, max_value: 303.15}

It is also possible to provide your own custom defined color mapping by
specifying a list of RGB values and the corresponding min and max values
between which to apply the colors. This is for instance a common use case for
Sea Surface Temperature (SST) imagery, as in this example with the EUMETSAT
Ocean and Sea Ice SAF (OSISAF) GHRSST product::

- name: osisaf_sst
method: !!python/name:satpy.enhancements.colorize
kwargs:
palettes:
- colors: [
[255, 0, 255],
[195, 0, 129],
[129, 0, 47],
[195, 0, 0],
[255, 0, 0],
[236, 43, 0],
[217, 86, 0],
[200, 128, 0],
[211, 154, 13],
[222, 180, 26],
[233, 206, 39],
[244, 232, 52],
[255.99609375, 255.99609375, 63.22265625],
[203.125, 255.99609375, 52.734375],
[136.71875, 255.99609375, 27.34375],
[0, 255.99609375, 0],
[0, 207.47265625, 0],
[0, 158.94921875, 0],
[0, 110.42578125, 0],
[0, 82.8203125, 63.99609375],
[0, 55.21484375, 127.9921875],
[0, 27.609375, 191.98828125],
[0, 0, 255.99609375],
[100.390625, 100.390625, 255.99609375],
[150.5859375, 150.5859375, 255.99609375]]
min_value: 296.55
max_value: 273.55

The RGB color values will be interpolated to give a smooth result. This is
contrary to using the palettize enhancement.

The above examples are just two different ways to apply colors to images with
Satpy. There is a wealth of other options for how to declare a colormap, please
see :func:`~satpy.enhancements.create_colormap` for more inspiration.

.. _`standard Trollimage color maps`: https://trollimage.readthedocs.io/en/latest/colormap.html#default-colormaps


palettize
---------

Expand Down
12 changes: 9 additions & 3 deletions satpy/composites/__init__.py
Expand Up @@ -920,7 +920,10 @@ def _get_band(self, high_res, low_res, color, ratio):
return ret

def __call__(self, datasets, optional_datasets=None, **info):
"""Sharpen low resolution datasets by multiplying by the ratio of ``high_res / low_res``."""
"""Sharpen low resolution datasets by multiplying by the ratio of ``high_res / low_res``.
The resulting RGB has the units attribute removed.
"""
if len(datasets) != 3:
raise ValueError("Expected 3 datasets, got %d" % (len(datasets), ))
if not all(x.shape == datasets[0].shape for x in datasets[1:]) or \
Expand Down Expand Up @@ -979,7 +982,9 @@ def __call__(self, datasets, optional_datasets=None, **info):
info.update(self.attrs)
# Force certain pieces of metadata that we *know* to be true
info.setdefault("standard_name", "true_color")
return super(RatioSharpenedRGB, self).__call__((r, g, b), **info)
res = super(RatioSharpenedRGB, self).__call__((r, g, b), **info)
res.attrs.pop("units", None)
return res


def _mean4(data, offset=(0, 0), block_id=None):
Expand Down Expand Up @@ -1101,7 +1106,8 @@ def __call__(self, projectables, *args, **kwargs):

# Get the enhanced version of the RGB composite to be sharpened
rgb_img = enhance2dataset(projectables[1])
rgb_img *= luminance
# Ignore alpha band when applying luminance
rgb_img = rgb_img.where(rgb_img.bands == 'A', rgb_img * luminance)
return super(SandwichCompositor, self).__call__(rgb_img, *args, **kwargs)


Expand Down
31 changes: 18 additions & 13 deletions satpy/composites/viirs.py
Expand Up @@ -953,18 +953,19 @@ class SnowAge(GenericCompositor):
Product is based on method presented at the second
CSPP/IMAPP users' meeting at Eumetsat in Darmstadt on 14-16 April 2015
# Bernard Bellec snow Look-Up Tables V 1.0 (c) Meteo-France
# These Look-up Tables allow you to create the RGB snow product
# for SUOMI-NPP VIIRS Imager according to the algorithm
# presented at the second CSPP/IMAPP users' meeting at Eumetsat
# in Darmstadt on 14-16 April 2015
# The algorithm and the product are described in this
# presentation :
# http://www.ssec.wisc.edu/meetings/cspp/2015/Agenda%20PDF/Wednesday/Roquet_snow_product_cspp2015.pdf
# For further information you may contact
# Bernard Bellec at Bernard.Bellec@meteo.fr
# or
# Pascale Roquet at Pascale.Roquet@meteo.fr
Bernard Bellec snow Look-Up Tables V 1.0 (c) Meteo-France
These Look-up Tables allow you to create the RGB snow product
for SUOMI-NPP VIIRS Imager according to the algorithm
presented at the second CSPP/IMAPP users' meeting at Eumetsat
in Darmstadt on 14-16 April 2015
The algorithm and the product are described in this
presentation :
http://www.ssec.wisc.edu/meetings/cspp/2015/Agenda%20PDF/Wednesday/Roquet_snow_product_cspp2015.pdf
as well as in the paper http://dx.doi.org/10.1016/j.rse.2017.04.028
For further information you may contact
Bernard Bellec at Bernard.Bellec@meteo.fr
or
Pascale Roquet at Pascale.Roquet@meteo.fr
"""

def __call__(self, projectables, nonprojectables=None, **info):
Expand All @@ -973,11 +974,13 @@ def __call__(self, projectables, nonprojectables=None, **info):
The algorithm and the product are described in this
presentation :
http://www.ssec.wisc.edu/meetings/cspp/2015/Agenda%20PDF/Wednesday/Roquet_snow_product_cspp2015.pdf
as well as in the paper http://dx.doi.org/10.1016/j.rse.2017.04.028
For further information you may contact
Bernard Bellec at Bernard.Bellec@meteo.fr
or
Pascale Roquet at Pascale.Roquet@meteo.fr
The resulting RGB has the units attribute removed.
"""
if len(projectables) != 5:
raise ValueError("Expected 5 datasets, got %d" %
Expand Down Expand Up @@ -1006,4 +1009,6 @@ def __call__(self, projectables, nonprojectables=None, **info):
ch2.attrs = info
ch3.attrs = info

return super(SnowAge, self).__call__([ch1, ch2, ch3], **info)
res = super(SnowAge, self).__call__([ch1, ch2, ch3], **info)
res.attrs.pop("units", None)
return res
21 changes: 4 additions & 17 deletions satpy/etc/composites/ahi.yaml
Expand Up @@ -2,19 +2,6 @@ sensor_name: visir/ahi

modifiers:
rayleigh_corrected:
modifier: !!python/name:satpy.modifiers.PSPRayleighReflectance
atmosphere: us-standard
aerosol_type: marine_clean_aerosol
prerequisites:
- wavelength: 0.64
modifiers: [sunz_corrected]
optional_prerequisites:
- satellite_azimuth_angle
- satellite_zenith_angle
- solar_azimuth_angle
- solar_zenith_angle

no_aerosol_rayleigh_corrected:
modifier: !!python/name:satpy.modifiers.PSPRayleighReflectance
atmosphere: us-standard
aerosol_type: rayleigh_only
Expand Down Expand Up @@ -48,9 +35,9 @@ composites:
fractions: [0.6321, 0.2928, 0.0751]
prerequisites:
- name: B02
modifiers: [sunz_corrected, no_aerosol_rayleigh_corrected]
modifiers: [sunz_corrected, rayleigh_corrected]
- name: B03
modifiers: [sunz_corrected, no_aerosol_rayleigh_corrected]
modifiers: [sunz_corrected, rayleigh_corrected]
- name: B04
modifiers: [sunz_corrected]
standard_name: none
Expand Down Expand Up @@ -247,10 +234,10 @@ composites:
compositor: !!python/name:satpy.composites.SelfSharpenedRGB
prerequisites:
- name: B03
modifiers: [sunz_corrected, no_aerosol_rayleigh_corrected]
modifiers: [sunz_corrected, rayleigh_corrected]
- name: green_true_color_reproduction
- name: B01
modifiers: [sunz_corrected, no_aerosol_rayleigh_corrected]
modifiers: [sunz_corrected, rayleigh_corrected]
standard_name: true_color_reproduction

# true_color_reducedsize_land:
Expand Down

0 comments on commit fc5f776

Please sign in to comment.