Skip to content

Commit

Permalink
Merge pull request #2181 from gerritholl/fci-true-color
Browse files Browse the repository at this point in the history
Add true color RGB for FCI
  • Loading branch information
mraspaud committed Oct 5, 2022
2 parents b9002de + 718a27a commit 4baae95
Show file tree
Hide file tree
Showing 5 changed files with 131 additions and 35 deletions.
34 changes: 5 additions & 29 deletions satpy/composites/ahi.py
@@ -1,6 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2015-2021 Satpy developers
# Copyright (c) 2022- Satpy developers
#
# This file is part of satpy.
#
Expand All @@ -15,30 +13,8 @@
#
# You should have received a copy of the GNU General Public License along with
# satpy. If not, see <http://www.gnu.org/licenses/>.
"""Composite classes for the AHI instrument."""
"""Composite classes for AHI."""

import logging

from satpy.composites import GenericCompositor
from satpy.dataset import combine_metadata

LOG = logging.getLogger(__name__)


class GreenCorrector(GenericCompositor):
"""Corrector of the AHI green band to compensate for the deficit of chlorophyll signal."""

def __init__(self, *args, fractions=(0.85, 0.15), **kwargs):
"""Set default keyword argument values."""
# XXX: Should this be 0.93 and 0.07
self.fractions = fractions
super(GreenCorrector, self).__init__(*args, **kwargs)

def __call__(self, projectables, optional_datasets=None, **attrs):
"""Boost vegetation effect thanks to NIR (0.8µm) band."""
LOG.info('Boosting vegetation on green band')

projectables = self.match_data_arrays(projectables)
new_green = sum(fraction * value for fraction, value in zip(self.fractions, projectables))
new_green.attrs = combine_metadata(*projectables)
return super(GreenCorrector, self).__call__((new_green,), **attrs)
# The green corrector used to be defined here, but was moved to spectral.py
# in Satpy 0.38 because it also applies to FCI.
from .spectral import GreenCorrector # noqa: F401
70 changes: 70 additions & 0 deletions satpy/composites/spectral.py
@@ -0,0 +1,70 @@
# Copyright (c) 2015-2022 Satpy developers
#
# This file is part of satpy.
#
# satpy is free software: you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any later
# version.
#
# satpy is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# satpy. If not, see <http://www.gnu.org/licenses/>.
"""Composite classes for spectral adjustments."""

import logging

from satpy.composites import GenericCompositor
from satpy.dataset import combine_metadata

LOG = logging.getLogger(__name__)


class GreenCorrector(GenericCompositor):
"""Corrector of the FCI or AHI green band.
The green band in FCI and AHI deliberately misses the chlorophyll peak
in order to focus on aerosol and ash rather than on vegetation. This
affects true colour RGBs, because vegetation looks brown rather than green.
To make vegetation look greener again, this corrector allows
to simulate the green band as a fraction of two or more other channels.
To be used, the composite takes two or more input channels and a parameter
``fractions`` that should be a list of floats with the same length as the
number of channels.
For example, to simulate an FCI corrected green composite, one could use
a combination of 93% from the green band (vis_05) and 7% from the
near-infrared 0.8 µm band (vis_08)::
corrected_green:
compositor: !!python/name:satpy.composites.ahi.GreenCorrector
fractions: [0.93, 0.07]
prerequisites:
- name: vis_05
modifiers: [sunz_corrected, rayleigh_corrected]
- name: vis_08
modifiers: [sunz_corrected, rayleigh_corrected]
standard_name: toa_bidirectional_reflectance
Other examples can be found in the ``fci.yaml`` and ``ahi.yaml`` composite
files in the satpy distribution.
"""

def __init__(self, *args, fractions=(0.85, 0.15), **kwargs):
"""Set default keyword argument values."""
# XXX: Should this be 0.93 and 0.07
self.fractions = fractions
super(GreenCorrector, self).__init__(*args, **kwargs)

def __call__(self, projectables, optional_datasets=None, **attrs):
"""Boost vegetation effect thanks to NIR (0.8µm) band."""
LOG.info('Boosting vegetation on green band')

projectables = self.match_data_arrays(projectables)
new_green = sum(fraction * value for fraction, value in zip(self.fractions, projectables))
new_green.attrs = combine_metadata(*projectables)
return super(GreenCorrector, self).__call__((new_green,), **attrs)
6 changes: 3 additions & 3 deletions satpy/etc/composites/ahi.yaml
Expand Up @@ -16,7 +16,7 @@ modifiers:

composites:
green:
compositor: !!python/name:satpy.composites.ahi.GreenCorrector
compositor: !!python/name:satpy.composites.spectral.GreenCorrector
# FUTURE: Set a wavelength...see what happens. Dependency finding
# probably wouldn't work.
prerequisites:
Expand All @@ -31,7 +31,7 @@ composites:
green_true_color_reproduction:
# JMA True Color Reproduction green band
# http://www.jma.go.jp/jma/jma-eng/satellite/introduction/TCR.html
compositor: !!python/name:satpy.composites.ahi.GreenCorrector
compositor: !!python/name:satpy.composites.spectral.GreenCorrector
fractions: [0.6321, 0.2928, 0.0751]
prerequisites:
- name: B02
Expand All @@ -43,7 +43,7 @@ composites:
standard_name: none

green_nocorr:
compositor: !!python/name:satpy.composites.ahi.GreenCorrector
compositor: !!python/name:satpy.composites.spectral.GreenCorrector
# FUTURE: Set a wavelength...see what happens. Dependency finding
# probably wouldn't work.
prerequisites:
Expand Down
6 changes: 3 additions & 3 deletions satpy/etc/composites/ami.yaml
Expand Up @@ -2,7 +2,7 @@ sensor_name: visir/ami

composites:
green_raw:
compositor: !!python/name:satpy.composites.ahi.GreenCorrector
compositor: !!python/name:satpy.composites.spectral.GreenCorrector
prerequisites:
- name: VI005
modifiers: [sunz_corrected]
Expand All @@ -12,7 +12,7 @@ composites:
fractions: [0.85, 0.15]

green:
compositor: !!python/name:satpy.composites.ahi.GreenCorrector
compositor: !!python/name:satpy.composites.spectral.GreenCorrector
prerequisites:
- name: VI005
modifiers: [sunz_corrected, rayleigh_corrected]
Expand All @@ -22,7 +22,7 @@ composites:
fractions: [0.85, 0.15]

green_nocorr:
compositor: !!python/name:satpy.composites.ahi.GreenCorrector
compositor: !!python/name:satpy.composites.spectral.GreenCorrector
prerequisites:
- name: VI005
- name: VI008
Expand Down
50 changes: 50 additions & 0 deletions satpy/etc/composites/fci.yaml
Expand Up @@ -2,6 +2,31 @@ sensor_name: visir/fci


composites:
corrected_green:
description: >
The FCI green band at 0.51 µm deliberately misses the chlorophyl band, such that
the signal comes rather from aerosols and ash rather than vegetation. An effect
is that vegetation in a true colour RGB looks rather brown than green. Mixing in
some part of the NIR 0.8 channel reduced this effect. Note that the fractions
currently implemented are experimental and may change in future versions of Satpy.
compositor: !!python/name:satpy.composites.spectral.GreenCorrector
fractions: [0.93, 0.07]
prerequisites:
- name: vis_05
modifiers: [sunz_corrected, rayleigh_corrected]
- name: vis_08
modifiers: [sunz_corrected, rayleigh_corrected]
standard_name: toa_bidirectional_reflectance

corrected_green_raw:
description: >
Alternative to corrected_green, but without solar zenith or rayleigh correction.
compositor: !!python/name:satpy.composites.spectral.GreenCorrector
fractions: [0.93, 0.07]
prerequisites:
- name: vis_05
- name: vis_08
standard_name: toa_bidirectional_reflectance

binary_cloud_mask:
# This will set all clear pixels to '0', all pixles with cloudy features (meteorological/dust/ash clouds) to '1' and
Expand All @@ -11,3 +36,28 @@ composites:
- name: 'cloud_state'
lut: [.nan, 0, 1, 1, 1, 1, 1, 1, 0, .nan]
standard_name: binary_cloud_mask

true_color:
compositor: !!python/name:satpy.composites.SelfSharpenedRGB
description: >
FCI true color composite. The green band is simulated based on a combination of
channels. This simulation may change in future versions of Satpy. See the description
of the corrected_green composites for details.
prerequisites:
- name: vis_06
modifiers: [sunz_corrected, rayleigh_corrected]
- name: corrected_green
- name: vis_04
modifiers: [sunz_corrected, rayleigh_corrected]
standard_name: true_color

true_color_raw_with_corrected_green:
compositor: !!python/name:satpy.composites.SelfSharpenedRGB
description: >
FCI true color without solar zenith or rayleigh corrections, but with the
corrected green composite.
prerequisites:
- name: vis_06
- name: corrected_green_raw
- name: vis_04
standard_name: true_color_raw

0 comments on commit 4baae95

Please sign in to comment.