Skip to content

Commit

Permalink
Merge branch 'main' into feature-olci-fsfile
Browse files Browse the repository at this point in the history
  • Loading branch information
mraspaud committed Apr 6, 2022
2 parents cd1d863 + fd483d3 commit f1a8438
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 25 deletions.
1 change: 1 addition & 0 deletions continuous_integration/environment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ dependencies:
- Cython
- sphinx
- cartopy
- panel>=0.12.7
- pillow
- matplotlib
- scipy
Expand Down
3 changes: 2 additions & 1 deletion satpy/composites/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1101,7 +1101,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
21 changes: 4 additions & 17 deletions satpy/etc/composites/ahi.yaml
Original file line number Diff line number Diff line change
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
29 changes: 22 additions & 7 deletions satpy/tests/test_composites.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,16 +448,25 @@ def test_compositor(self):
np.testing.assert_allclose(res.data, 0.0, atol=1e-9)


class TestSandwichCompositor(unittest.TestCase):
class TestSandwichCompositor:
"""Test sandwich compositor."""

# Test RGB and RGBA
@pytest.mark.parametrize(
"input_shape,bands",
[
((3, 2, 2), ['R', 'G', 'B']),
((4, 2, 2), ['R', 'G', 'B', 'A'])
]
)
@mock.patch('satpy.composites.enhance2dataset')
def test_compositor(self, e2d):
def test_compositor(self, e2d, input_shape, bands):
"""Test luminance sharpening compositor."""
from satpy.composites import SandwichCompositor

rgb_arr = da.from_array(np.random.random((3, 2, 2)), chunks=2)
rgb = xr.DataArray(rgb_arr, dims=['bands', 'y', 'x'])
rgb_arr = da.from_array(np.random.random(input_shape), chunks=2)
rgb = xr.DataArray(rgb_arr, dims=['bands', 'y', 'x'],
coords={'bands': bands})
lum_arr = da.from_array(100 * np.random.random((2, 2)), chunks=2)
lum = xr.DataArray(lum_arr, dims=['y', 'x'])

Expand All @@ -467,9 +476,15 @@ def test_compositor(self, e2d):

res = comp([lum, rgb])

for i in range(3):
np.testing.assert_allclose(res.data[i, :, :],
rgb_arr[i, :, :] * lum_arr / 100.)
for band in rgb:
if band.bands != 'A':
# Check compositor has modified this band
np.testing.assert_allclose(res.loc[band.bands].to_numpy(),
band.to_numpy() * lum_arr / 100.)
else:
# Check Alpha band remains intact
np.testing.assert_allclose(res.loc[band.bands].to_numpy(),
band.to_numpy())
# make sure the compositor doesn't modify the input data
np.testing.assert_allclose(lum.values, lum_arr.compute())

Expand Down

0 comments on commit f1a8438

Please sign in to comment.