pytroll / satpy

Python package for earth-observing satellite data processing
http://satpy.readthedocs.org/en/latest/
GNU General Public License v3.0
1.04k stars 287 forks source link

GenericCompositor discards dataset metadata #2829

Open BoehnkeC opened 1 week ago

BoehnkeC commented 1 week ago

Describe the bug Creating a composite with the GenericCompositor overwrites initial band/dataset metadata. This is also directly commented in the code itself although I find this behavior disputable:

new_attrs = combine_metadata(*datasets)
        # remove metadata that shouldn't make sense in a composite
        new_attrs["wavelength"] = None
        new_attrs.pop("units", None)
        new_attrs.pop("calibration", None)
        new_attrs.pop("modifiers", None)

To Reproduce

composite = composites.GenericCompositor(name="overview")
composite = composite(scene[3.8],
                      scene[10.8],
                      scene[12.0]
)

with scene being an instance of Satpy's Scene class.

Calling the attributes of an individual dataset, e.g. scene[3.8].attrs["wavelength"] prints: 3.8 µm (3.71-3.89 µm). Calling the attributes of the same dataset in the composite with composite[0].attrs["wavelength"] prints None.

It is not possible to alter the dataset attributes within the composite.

Expected behavior Discarding the original dataset attributes removes a lot of useful metadata and hampers visualization of the written composite file as crucial band information is missing. If band metadata would be forwarded or if there would be an option editing the metadata of the composite directly, further offline work with the saved image would be possible.

gerritholl commented 1 week ago

What value would you expect for a "wavelength" attribute for a composite RGB built with channels 3.8 µm, 10.8 µm, and 12.0 µm? How about "calibration"?