pytroll/pyspectral

Getting the near infrared reflectance of a viirs scene crashes.

mraspaud opened this issue · 0 comments

Getting the near infrared reflectance of a viirs scene crashes.
I'll be filling this bug report properly when I'm in a well connected place again.

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

This is happening in a couple of places in solar.py

np.linspace(start, end, round((end - start) / self._dlambda) + 1)

Problem description

This is not working with numpy > 1.18 as round doesn't return an int (see numpy/numpy#11557 )

Expected Output

I expect this to run without crashing.

Actual Result, Traceback if applicable

  File "/san1/opt/ears_viirs_imagery_processor/releases/ears_viirs_imagery_processor-0.1.9/lib/python3.6/site-packages/pyspectral/solar.py", line 182, in _band_calculations
    xspl = np.linspace(start, end, round((end - start) / self._dlambda) + 1)
  File "<__array_function__ internals>", line 6, in linspace
  File "/san1/opt/ears_viirs_imagery_processor/releases/ears_viirs_imagery_processor-0.1.9/lib/python3.6/site-packages/numpy/core/function_base.py", line 121, in linspace
    .format(type(num)))
TypeError: object of type <class 'numpy.float64'> cannot be safely interpreted as an integer.

A simple solution would be to replace round with int(round)

Versions of Python, package at hand and relevant dependencies

Numpy 1.18.1