pytroll / pytroll/pyresample

`get_area_slices` method returns wrong slices

Open
#371 8 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

If a geos area is sliced with the results of get_area_slices called with an area which is a subset of the area the resulting area is bigger than the subset area.

from satpy.resample import get_area_def

a = get_area_def("seviri_0deg")
b = a[slice(54, 822), slice(1461, 2485)]
print(b)
c = a.crop_around(b))
print(c)
a.get_area_slices(b)

I would expect b and c to have the same number of rows/columns.
I think the problem is the rounding in get_area_slices:

https://github.com/pytroll/pyresample/blob/2456508a6d18e04dcce517a0c09238fd5e7bb0da/pyresample/geometry.py#L2201

This in turn affects the scene crop method in Satpy. Interestingly while the scene resample method also uses get_area_slices for data reduction at least the nearest neighbour resampler "corrects" the wrong slices somewhere.

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 in pyresample/geometry.py at get_area_slices, especially the rounding referenced near line 2201, and run the issue's example with the seviri_0deg area. Compare the dimensions of b, crop_around(b), and the returned slices; done means the sliced area and cropped area have matching row and column counts.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.