Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

outer_boundary_corners and __contains__ raise ValueError on some areas #393

Open
gerritholl opened this issue Nov 9, 2021 · 1 comment

Comments

@gerritholl
Copy link
Collaborator

gerritholl commented Nov 9, 2021

Checking the outer boundary corners of some areas fails with ValueError. In this case, checking if a certain point is contained also fails.

Code Sample, a minimal, complete, and verifiable piece of code

from pyresample.area_config import parse_area_file
area = parse_area_file(
    "/data/gholl/checkouts/satpy/satpy/etc/areas.yaml",
    "seviri_0deg")[0]
print((0, 0) in area)
print(area.outer_boundary_corners)

Problem description

raises ValueError, probably because the Earth is round and has no corners.

Expected Output

For the outer_boundary_corners, maybe NaN would be appropriate, or maybe a ValueError is actually correct. However, I don't think (lon, lat) in area should raise a ValueError for any valid lon/lat (see also #268). For valid input, this should always return either True or False.

Actual Result, Traceback if applicable

Traceback (most recent call last):
  File "/data/gholl/checkouts/protocode/mwe/outer-corners.py", line 5, in <module>
    print(area.outer_boundary_corners)
  File "/data/gholl/checkouts/pyresample/pyresample/geometry.py", line 2134, in outer_boundary_corners
    return [Coordinate(corner_lons[0], corner_lats[0]),
  File "/data/gholl/checkouts/pyresample/pyresample/spherical_geometry.py", line 50, in __init__
    raise ValueError('Illegal (lon, lat) coordinates: (%s, %s)'
ValueError: Illegal (lon, lat) coordinates: (inf, inf)

Versions of Python, package at hand and relevant dependencies

pyresample v1.22.0-8-gee7c1b9

@gerritholl
Copy link
Collaborator Author

gerritholl commented Nov 9, 2021

This also affects __contains__:

from pyresample.area_config import parse_area_file
area = parse_area_file(
    "/data/gholl/checkouts/satpy/satpy/etc/areas.yaml",
    "seviri_0deg")[0]
print((0, 0) in area)
print(area.outer_boundary_corners)

fails already at the (0, 0) in area line:

Traceback (most recent call last):
  File "/data/gholl/checkouts/protocode/mwe/outer-corners.py", line 5, in <module>
    print((0, 0) in area)
  File "/data/gholl/checkouts/pyresample/pyresample/geometry.py", line 371, in __contains__
    corners = self.corners
  File "/data/gholl/checkouts/pyresample/pyresample/geometry.py", line 360, in corners
    return [Coordinate(*self.get_lonlat(0, 0)),
  File "/data/gholl/checkouts/pyresample/pyresample/spherical_geometry.py", line 50, in __init__
    raise ValueError('Illegal (lon, lat) coordinates: (%s, %s)'
ValueError: Illegal (lon, lat) coordinates: (inf, inf)

See also issue #268 which is specifically about __contains__.

@gerritholl gerritholl changed the title accessing outer_boundary_corners raises ValueError on some areas outer_boundary_corners and __contains__ raise ValueError on some areas Nov 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant