GenericCompositor discards dataset metadata
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.2k
- Forks
- 335
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 10
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the GenericCompositor metadata handling shown in the issue and run the Scene reproduction using bands 3.8, 10.8, and 12.0. Trace how combine_metadata and the subsequent removals affect the composite dataset, then add a documented behavior that preserves useful band metadata or provides a supported way to edit it, with tests covering the resulting attributes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100