pytroll / pyorbital

Orbital and astronomy computations in python
http://pyorbital.readthedocs.org/
GNU General Public License v3.0
224 stars 77 forks source link

get_observer_look raises IndexError on numpy 1.21.4 #90

Closed gerritholl closed 2 years ago

gerritholl commented 2 years ago

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

from datetime import datetime
from pyorbital.orbital import get_observer_look
print(get_observer_look(0, 0, 30_000_000, datetime.now(), 0, 0, 0))

Problem description

The code sample raises an IndexError in my Python 3.10 environment with numpy 1.21.4. It returns successfully in my Python 3.9 environment with numpy 1.20.3. It also fails in this GitHub CI environment with Python 3.8 and numpy 1.21.4.

Expected Output

With Python 3.9, numpy 1.20.3 I get:

(180.0, 89.99999914622636) 

Actual Result, Traceback if applicable

With Python 3.10, numpy 1.20.3 I get:

/data/gholl/mambaforge/envs/py310/lib/python3.10/site-packages/pyorbital/orbital.py:129: RuntimeWarning: divide by zero encountered in double_scalars
  az_ = np.arctan(-top_e / top_s)
Traceback (most recent call last):
  File "/home/gholl/checkouts/protocode/mwe/get-observer-look-indexerror.py", line 3, in <module>
    print(get_observer_look(0, 0, 30_000_000, datetime.now(), 0, 0, 0))
  File "/data/gholl/mambaforge/envs/py310/lib/python3.10/site-packages/pyorbital/orbital.py", line 140, in get_observer_look
    az_data[np.where(top_s > 0)] += np.pi
IndexError: invalid index to scalar variable.

Versions of Python, package at hand and relevant dependencies

gerritholl commented 2 years ago

Never mind, this was already fixed in #77. Somehow it wasn't using the version I thought it was.