New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve support for mode P images #1844
Comments
It's possible to write P-mode images by using trollimage and the Writer class directly. For example: from satpy import Scene
from satpy.writers import to_image
from trollimage.colormap import Colormap
from sattools.io import plotdir
sc = Scene(
filenames=["/media/nas/x21308/scratch/NWCSAF/NWCSAF-NinjoTIFF-2/S_NWC_CT_MSG4_MSG-N-VISIR_20210930T100000Z.nc"],
reader=["nwcsaf-geo"])
sc.load(["ct", "ct_pal"])
ct_im = to_image(sc["ct"])
cmap = Colormap(*[(i, tuple(sc["ct_pal"][i, :].compute().data/256)) for i in range(256)])
ct_im.palettize(cmap)
ct_im.save(str(plotdir() / "test-palette.tif"), keep_palette=True, cmap=cmap) |
A P-mode image could also retain units information; there is no reason why this should be removed for something like a colorised cloud top height. This would require that |
Or maybe the whole sets of composites such as |
Summary of a discussion between @mraspaud and myself: I'll work on a |
Downside of a dedicated compositor: we would need to duplicate each and every composite that currently uses the From a user point of view, it would be preferable to do |
As @mraspaud has pointed out in slack, this parameter fits better in Would such a backward incompatibility be acceptable? |
The whole colormap creation in pytroll could use some refactoring. We have:
None of them call each other. The docstring for |
Feature Request
Is your feature request related to a problem? Please describe.
It is currently difficult or unclear to work with mode
P
images in Satpy. For example, the following produces an image in modeRGB
:Users may expect or at least want the option to retain an image in mode
P
. There are some references on GitHub to modeP
, for example, see #1432 and #1817. The composite documentation states only L, LA, RGB, and RGBA are supported.It's unclear if and how Satpy users can produce images of mode
P
.Describe the solution you'd like
I would like a clearly implemented and clearly documented way to produce images of mode
P
where appropriate.Describe any changes to existing user workflow
I don't know the current workflow, so I don't know if anything would change. Maybe it's just a matter of improving documentation, or maybe it requires to rewrite all of pytroll from scratch and start over. Most likely the solution lies somewhere in-between.
Additional context
It's possible to hack something together that converts an RGB image back to mode P. This is doubleplusungood.
The text was updated successfully, but these errors were encountered: