-
Notifications
You must be signed in to change notification settings - Fork 98
Description
There seems to be a bug in the computation of the boundaries and intersections between a cropped geostationary projection, like SEVIRI RSS, and a lon-lat area.
To reproduce:
from pyresample.geometry import AreaDefinition
from satpy.area import get_area_def
rss_area = get_area_def("msg_seviri_rss_3km")
# the saved areadef in satpy is for full-disc, so lets use the actual area_extent from real data
rss_area_loc = rss_area.copy(area_extent=(-5570248.477339745, 1393687.2705221176, 5567248.074173927, 5570248.477339745))
ll_bbox = [0, 40, 1, 41] # fails (South Spain)
# ll_bbox = [0, 50, 1, 51] # works (South UK)
crop_area = AreaDefinition(
"crop_area", "crop_area", "crop_latlong",
{"proj": "latlong"}, 100, 100, ll_bbox)
s = rss_area_loc.get_area_slices(crop_area)which results in
File "/tcenas/home/andream/.config/JetBrains/PyCharm2025.3/scratches/scratch_18.py", line 13, in <module>
s = rss_area_loc.get_area_slices(crop_area)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tcenas/home/andream/code/satpy_latest/pyresample/pyresample/geometry.py", line 2648, in get_area_slices
return get_area_slices(self, area_to_cover, shape_divisible_by)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tcenas/home/andream/code/satpy_latest/pyresample/pyresample/_caching.py", line 49, in __call__
return self._callable(*args)
^^^^^^^^^^^^^^^^^^^^^
File "/tcenas/home/andream/code/satpy_latest/pyresample/pyresample/future/geometry/_subset.py", line 55, in get_area_slices
raise NotImplementedError
NotImplementedErroras it fails to find an intersection here
pyresample/pyresample/future/geometry/_subset.py
Lines 48 to 55 in a7e1f25
| data_boundary = _get_area_boundary(src_area) | |
| area_boundary = _get_area_boundary(area_to_cover) | |
| intersection = data_boundary.contour_poly.intersection( | |
| area_boundary.contour_poly) | |
| if intersection is None: | |
| logger.debug('Cannot determine appropriate slicing. ' | |
| "Data and projection area do not overlap.") | |
| raise NotImplementedError |
The lon-lat bbox used is definitely in the area (it's somewhere in Spain). Using a bbox south of UK works again (see code example).
Additional context
This of course makes also the satpy Scene.crop fail accordingly, to reproduce:
import satpy
path = '/tcenas/fbf/MSG/in/MSG4/OPE4/SEVI-MSG15/MSG4-SEVI-MSG15-0100-NA-20251230083420.370000000Z-NA.nat'
scene = satpy.Scene(reader='seviri_l1b_native', filenames=[path], reader_kwargs={'fill_disk': False})
# load channel
channel = 'VIS008'
scene.load([channel], upper_right_corner='NE')
# crop on ll_box: (lon_min, lat_min, lon_max, lat_max)
ll_box = (0, 40, 1, 41)
scene_sub = scene.crop(ll_bbox=ll_box)here, the workaround is to use 'fill_disk': True
Additional context II
@simonrp84 reported this already on Slack in 2023 https://pytroll.slack.com/archives/C0LNH7LMB/p1686061927840339 and then also for Himawary when passing a single segment, see https://pytroll.slack.com/archives/C0LNH7LMB/p1716292859837229 .
Additional context III
According to my colleague, it doesn't happen with pyresample v1.25.1