Hi Thaize,
1. Your `img_data` variable is the RGB color of the ash RGB. If you have
a way to detect what pixels you consider to have enough red. If you can
get that then you can create a mask or index array to use on any other
channel you load. For example:
scn.load(['ash', 'IR_108'])
... your existing code ...
img_data = img.data
# True where red pixels are greater than 0.8 and green and blue are less
than 0.2
red_mask = (img_data[:, :, 0] > 0.8) & (img_data[:, :, 1] < 0.2) &
(img_data[:, :, 2] < 0.2)
# .data is a dask array, we do .compute to get a numpy array
bt_data = local_scn['IR_108'].data.compute()
bt_for_red_pixels = bt_data[red_mask]
This is a simple approach and there are many optimizations that could be
made. Additionally, it may be easier or more accurate for you to figure
out what makes the ash RGB red-ish and do those calculations yourself to
come up with a better red_mask than what I've done below (use the bands
that make up the ash RGB).
2. The first thing to try might be to use the Scene's crop method:
https://satpy.readthedocs.io/en/stable/api/satpy.html#satpy.scene.Scene.crop
If that doesn't do what you want you could look at the methods for the
AreaDefinition (scn['IR_108'].attrs['area']) in pyresample for how to
convert lon/lat to the col/row in your array:
https://pyresample.readthedocs.io/en/latest/api/pyresample.html#pyresample.geometry.AreaDefinition.lonlat2colrow
That would give you the nearest index (row, column) to the lon/lat you
have which you could then use to slice the array:
your_square = scn['IR_108'][my_row - 3:my_row + 4, my_col - 3: my_col + 4]
I think that would work.
You could also look at making your own AreaDefinition. See
https://pyresample.readthedocs.io/en/latest/geometry_utils.html. You can
then resample to that AreaDefinition and the result would be the region
you want.
Hope that helps.
Dave
> --
> You received this message because you are subscribed to the Google
> Groups "pytroll" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to
pytroll+u...@googlegroups.com
> <mailto:
pytroll+u...@googlegroups.com>.
> To view this discussion on the web, visit
>
https://groups.google.com/d/msgid/pytroll/b739d91a-92d9-45c2-a2f9-1ff9b70630d2n%40googlegroups.com
> <
https://groups.google.com/d/msgid/pytroll/b739d91a-92d9-45c2-a2f9-1ff9b70630d2n%40googlegroups.com?utm_medium=email&utm_source=footer>.