Closed SamothKoc closed 5 months ago
You'll need to "enhance" your RGB image so that it gets each band stretched to the expected limits. Satpy's .show
does this for you. Satpy also does this as part of the writing step in .save_datasets
. The simple workaround is to change the code like this:
from satpy.writers import get_enhanced_image
image = get_enhanced_image(scn_resample_nc["dust"]).data.data.compute().transpose(1, 2, 0)
instead of what you're doing now which is this:
image = np.asarray(scn_resample_nc["dust"]).transpose(1,2,0)
Note that get_enhanced_image
is returning a special XRImage
object. The first .data
is the underlying enhanced DataArray object. The second .data
is the dask array inside the DataArray. .compute()
on the dask array returns a numpy array and then you can do the transpose as you did before.
Now for my question, what does this line do:
image = np.interp(image, (np.percentile(image,1), np.percentile(image,99)), (0, 1))
Well... imshow scales the color range between 0 and 1, so you can adjust the scaling to customize the color scale. That's why I thought... In summary, this line performs a contrast adjustment where the pixel values of the image are scaled to increase contrast and range between 0 and 1 to highlight and customize specific features in the image.... that was my first idea :D but it doesn't workd :D...
Ah, if I'm understanding you correctly that shouldn't be needed once get_enhanced_image
is used. That normalization to a 0 to 1 range is done by the "enhancement".
Yes :D that is it... A further question... is there a way to get the pixel coordinate to combine model data with the current Seviri plt?
Greetings
Just to make sure we're talking about the same thing, what do you mean by "pixel coordinate"?
Normally I would recommend resampling the SEVIRI data and the model data to the same projection/grid (an AreaDefinition in satpy/pyresample terms).
Pyresample was the key :) thanks.
Hello, I'm new to Satpy and I'm facing a bit of trouble. I've tried various approaches and couldn't find a solution through Google either. I'm able to work with natural-color images without any issues. I want to integrate the image into Cartopy to add latitude and longitude gridlines. My next step is to incorporate model data, which has worked well for other satellites.
Even with natural-color images, everything is fine. However, when I use imshow() on the Seviri dust product, the image suddenly turns blue. When I use the show() method itself and work with the temporarily generated image, it appears correct. Is there a trick to make imshow() display the normal RGB dust color scheme? It seems that imshow() is altering the color scheme between 0 and 1. .show():
imshow:
![plot](https://github.com/pytroll/satpy/assets/156442850/04faab7a-77d0-40fd-b2c0-83c8531fba99)
I hope someone can assist me with this.