Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions doc/source/composites.rst
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ Simple RGB composite
This is the overview composite shown in the first code example above
using :class:`satpy.composites.core.GenericCompositor`::

sensor_name: visir
instrument: visir

composites:
overview:
Expand All @@ -341,10 +341,10 @@ using :class:`satpy.composites.core.GenericCompositor`::

For an instrument specific version (here MSG/SEVIRI), we should use
the channel _names_ instead of wavelengths. Note also that the
sensor_name is now combination of visir and seviri, which means that
instrument is now combination of visir and seviri, which means that
it extends the generic visir composites::

sensor_name: visir/seviri
instrument: visir/seviri

composites:

Expand All @@ -357,7 +357,7 @@ it extends the generic visir composites::
standard_name: overview

In the following examples only the composite receipes are shown, and
the header information (sensor_name, composites) and intendation needs
the header information (instrument, composites) and intendation needs
to be added.

Using modifiers
Expand Down
15 changes: 13 additions & 2 deletions satpy/composites/config_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,20 @@ def _load_config(composite_configs):
with open(composite_config, "r", encoding="utf-8") as conf_file:
recursive_dict_update(conf, yaml.load(conf_file, Loader=UnsafeLoader))
try:
sensor_name = conf["sensor_name"]
sensor_name = conf["instrument"]
except KeyError:
logger.debug('No "sensor_name" tag found in %s, skipping.',
# 8< v1.0
sensor_name_legacy = conf.get("sensor_name")
if sensor_name_legacy:
warnings.warn(
"The 'sensor_name' composite property is deprecated and "
"will be ignored in Satpy v1.0. Use 'instrument' instead.",
DeprecationWarning,
stacklevel=2
)
sensor_name = sensor_name_legacy
# >8 v1.0
logger.debug('No "instrument" tag found in %s, skipping.',
composite_configs)
return {}, {}, {}

Expand Down
2 changes: 1 addition & 1 deletion satpy/etc/composites/abi.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sensor_name: visir/abi
instrument: visir/abi

modifiers:
rayleigh_corrected_crefl:
Expand Down
2 changes: 1 addition & 1 deletion satpy/etc/composites/agri.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sensor_name: visir/agri
instrument: visir/agri

composites:
green:
Expand Down
2 changes: 1 addition & 1 deletion satpy/etc/composites/ahi.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sensor_name: visir/ahi
instrument: visir/ahi

modifiers:
rayleigh_corrected:
Expand Down
2 changes: 1 addition & 1 deletion satpy/etc/composites/ami.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sensor_name: visir/ami
instrument: visir/ami

composites:
green_raw:
Expand Down
2 changes: 1 addition & 1 deletion satpy/etc/composites/amsr2.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sensor_name: amsr2
instrument: amsr2

composites:
rgb_color:
Expand Down
2 changes: 1 addition & 1 deletion satpy/etc/composites/atms.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sensor_name: atms
instrument: atms

composites:
mw183_humidity:
Expand Down
2 changes: 1 addition & 1 deletion satpy/etc/composites/avhrr-3.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sensor_name: visir/avhrr-3
instrument: visir/avhrr-3

composites:

Expand Down
2 changes: 1 addition & 1 deletion satpy/etc/composites/ec_msi.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sensor_name: visir/ec_msi
instrument: visir/ec_msi


modifiers:
Expand Down
2 changes: 1 addition & 1 deletion satpy/etc/composites/epic.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sensor_name: visir/epic
instrument: visir/epic

modifiers:
sunz_corrected:
Expand Down
2 changes: 1 addition & 1 deletion satpy/etc/composites/fci.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sensor_name: visir/fci
instrument: visir/fci

composites:
### L2
Expand Down
2 changes: 1 addition & 1 deletion satpy/etc/composites/ghi.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sensor_name: visir/ghi
instrument: visir/ghi

composites:
true_color:
Expand Down
2 changes: 1 addition & 1 deletion satpy/etc/composites/glm.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sensor_name: visir/glm
instrument: visir/glm
composites:
C14_flash_extent_density:
compositor: !!python/name:satpy.composites.fill.BackgroundCompositor
Expand Down
2 changes: 1 addition & 1 deletion satpy/etc/composites/goes_imager.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# XXX arb
sensor_name: visir/goes_imager
instrument: visir/goes_imager

composites:
overview:
Expand Down
2 changes: 1 addition & 1 deletion satpy/etc/composites/hsaf.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sensor_name: hsaf
instrument: hsaf

composites:
instantaneous_rainrate_3:
Expand Down
2 changes: 1 addition & 1 deletion satpy/etc/composites/insat3d_img.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sensor_name: visir/insat_img
instrument: visir/insat_img

composites:
cloud_phase_distinction:
Expand Down
2 changes: 1 addition & 1 deletion satpy/etc/composites/li.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
# we use li only here, and not visir/li, since the second can cause dependency issues when creating composites
# combined with imagers in a multi-reader Scene. visir composites do not apply to LI anyway.
sensor_name: li
instrument: li

# these are tentative recipes that will need to be further tuned as we gain experience with LI data
composites:
Expand Down
2 changes: 1 addition & 1 deletion satpy/etc/composites/mersi-1.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sensor_name: visir/mersi-1
instrument: visir/mersi-1

modifiers:
rayleigh_corrected:
Expand Down
2 changes: 1 addition & 1 deletion satpy/etc/composites/mersi-2.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sensor_name: visir/mersi-2
instrument: visir/mersi-2

modifiers:
rayleigh_corrected:
Expand Down
2 changes: 1 addition & 1 deletion satpy/etc/composites/mersi-3.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sensor_name: visir/mersi-3
instrument: visir/mersi-3

modifiers:
rayleigh_corrected:
Expand Down
2 changes: 1 addition & 1 deletion satpy/etc/composites/mersi-ll.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sensor_name: visir/mersi-ll
instrument: visir/mersi-ll

composites:

Expand Down
2 changes: 1 addition & 1 deletion satpy/etc/composites/mersi-rm.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sensor_name: visir/mersi-rm
instrument: visir/mersi-rm

modifiers:
rayleigh_corrected:
Expand Down
2 changes: 1 addition & 1 deletion satpy/etc/composites/mhs.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sensor_name: mhs
instrument: mhs

composites:
mw183_humidity:
Expand Down
2 changes: 1 addition & 1 deletion satpy/etc/composites/microwave.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sensor_name: microwave
instrument: microwave
2 changes: 1 addition & 1 deletion satpy/etc/composites/modis.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sensor_name: visir/modis
instrument: visir/modis
modifiers:
rayleigh_corrected_crefl:
modifier: !!python/name:satpy.modifiers.atmosphere.ReflectanceCorrector
Expand Down
2 changes: 1 addition & 1 deletion satpy/etc/composites/msu-gs.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sensor_name: visir/msu-gs
instrument: visir/msu-gs

composites:
overview_raw:
Expand Down
2 changes: 1 addition & 1 deletion satpy/etc/composites/msu_gsa.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sensor_name: visir/msu_gsa
instrument: visir/msu_gsa

composites:
overview_raw:
Expand Down
2 changes: 1 addition & 1 deletion satpy/etc/composites/mwr.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sensor_name: microwave/mwr
instrument: microwave/mwr

composites:
mw183_humidity:
Expand Down
2 changes: 1 addition & 1 deletion satpy/etc/composites/oci.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sensor_name: visir/oci
instrument: visir/oci
2 changes: 1 addition & 1 deletion satpy/etc/composites/olci.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sensor_name: visir/olci
instrument: visir/olci


modifiers:
Expand Down
2 changes: 1 addition & 1 deletion satpy/etc/composites/oli_tirs.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sensor_name: visir/oli_tirs
instrument: visir/oli_tirs

modifiers:
rayleigh_corrected:
Expand Down
2 changes: 1 addition & 1 deletion satpy/etc/composites/sar-c.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sensor_name: sar/sar-c
instrument: sar/sar-c
2 changes: 1 addition & 1 deletion satpy/etc/composites/sar.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sensor_name: sar
instrument: sar

composites:
sar-ice:
Expand Down
2 changes: 1 addition & 1 deletion satpy/etc/composites/scatterometer.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sensor_name: visir/scatterometer
instrument: visir/scatterometer

composites:
scat_wind_speed:
Expand Down
2 changes: 1 addition & 1 deletion satpy/etc/composites/sen2_msi.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sensor_name: visir/sen2_msi
instrument: visir/sen2_msi

modifiers:
rayleigh_corrected:
Expand Down
2 changes: 1 addition & 1 deletion satpy/etc/composites/seviri.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sensor_name: visir/seviri
instrument: visir/seviri

modifiers:
sunz_corrected:
Expand Down
2 changes: 1 addition & 1 deletion satpy/etc/composites/sgli.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sensor_name: visir/sgli
instrument: visir/sgli


modifiers:
Expand Down
2 changes: 1 addition & 1 deletion satpy/etc/composites/slstr.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sensor_name: visir/slstr
instrument: visir/slstr
composite_identification_keys:
name:
required: true
Expand Down
2 changes: 1 addition & 1 deletion satpy/etc/composites/tropomi.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sensor_name: tropomi
instrument: tropomi

composites:

Expand Down
2 changes: 1 addition & 1 deletion satpy/etc/composites/vii.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sensor_name: visir/vii
instrument: visir/vii
modifiers:
nir_reflectance:
modifier: !!python/name:satpy.modifiers.NIRReflectance
Expand Down
2 changes: 1 addition & 1 deletion satpy/etc/composites/viirs.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sensor_name: visir/viirs
instrument: visir/viirs

modifiers:
rayleigh_corrected_crefl:
Expand Down
2 changes: 1 addition & 1 deletion satpy/etc/composites/virr.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sensor_name: visir/virr
instrument: visir/virr

modifiers:
sunz_corrected:
Expand Down
2 changes: 1 addition & 1 deletion satpy/etc/composites/visir.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sensor_name: visir
instrument: visir
composite_identification_keys:
name:
required: true
Expand Down
2 changes: 1 addition & 1 deletion satpy/modifiers/parallax.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ class ParallaxCorrectionModifier(ModifierBase):
To use this, add to ``composites/visir.yaml`` within ``SATPY_CONFIG_PATH``
something like::

sensor_name: visir
instrument: visir

modifiers:
parallax_corrected:
Expand Down
56 changes: 42 additions & 14 deletions satpy/tests/compositor_tests/test_config_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@

"""Tests for compositor config handling."""

from typing import Optional

import pytest

import satpy
from satpy.composites.config_loader import load_compositor_configs_for_sensors


def test_bad_sensor_yaml_configs(tmp_path):
Expand All @@ -26,8 +31,6 @@ def test_bad_sensor_yaml_configs(tmp_path):
But the bad YAML also shouldn't crash composite configuration loading.

"""
from satpy.composites.config_loader import load_compositor_configs_for_sensors

comp_dir = tmp_path / "composites"
comp_dir.mkdir()
comp_yaml = comp_dir / "fake_sensor.yaml"
Expand All @@ -40,19 +43,44 @@ def test_bad_sensor_yaml_configs(tmp_path):
assert "fake_composite" not in comps["fake_sensor"]


def _create_fake_composite_config(yaml_filename: str):
def _create_fake_composite_config(yaml_filename: str, extra_content: Optional[dict]=None):
import yaml

from satpy.composites.aux_data import StaticImageCompositor

content = {
"composites": {
"fake_composite": {
"compositor": StaticImageCompositor,
"url": "http://example.com/image.png",
}
}
}
if extra_content:
content.update(extra_content)
with open(yaml_filename, "w") as comp_file:
yaml.dump({
"composites": {
"fake_composite": {
"compositor": StaticImageCompositor,
"url": "http://example.com/image.png",
},
},
},
comp_file,
)
yaml.dump(content, comp_file)


# 8< v1.0
class TestUserConfigWithDeprecatedSensorNameProperty:
"""Test loading user config with deprecated sensor_name property."""

@pytest.fixture
def user_comp_dir(self, tmp_path):
"""Get directory with user composites."""
return tmp_path / "etc" / "composites"

@pytest.fixture
def user_config_file(self, user_comp_dir):
"""Write user config with old sensor_name property."""
filename = user_comp_dir / "myinstrument.yaml"
user_comp_dir.mkdir(parents=True)
_create_fake_composite_config(filename, {"sensor_name": "myinstrument"})

def test_finding_user_config(self, user_comp_dir, user_config_file):
"""Test loading user config with deprecated sensor_name property."""
with satpy.config.set(config_path=[str(user_comp_dir.parent)]):
with pytest.warns(DeprecationWarning, match="Use 'instrument' instead."):
comps, _ = load_compositor_configs_for_sensors(["MyInstrument"])
assert "MyInstrument" in comps
# >8 v1.0
2 changes: 1 addition & 1 deletion satpy/tests/etc/composites/fake_sensor.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sensor_name: visir/fake_sensor
instrument: visir/fake_sensor

modifiers:
mod1:
Expand Down
Loading
Loading