pytroll / pytroll/pyresample

`AreaDefinition.get_area_slices` doesn't work for cropped geostationary areas like SEVIRI RSS

Open
#694 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
385
Forks
102
Avg merge
4d 2h
Merged PRs (30d)
9

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
NotImplementedError

as it fails to find an intersection here https://github.com/pytroll/pyresample/blob/a7e1f2508dcd49acc56f99b63e9e427cf6b53e9c/pyresample/future/geometry/_subset.py#L48-L55

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with AreaDefinition.get_area_slices and the intersection handling in pyresample/future/geometry/_subset.py, then run the provided SEVIRI RSS reproduction with the Spain and UK bounding boxes. Compare the behavior with pyresample v1.25.1 and verify that cropped geostationary areas find the Spain intersection without raising NotImplementedError; the related Satpy crop should also work without fill_disk=True.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.