hitranonline / hapi

HITRAN Application Programming Interface (HAPI)
Other
80 stars 35 forks source link

linspace needs an int #19

Closed DanHickstein closed 4 years ago

DanHickstein commented 4 years ago

On line 161, the linspace function needs to be called with an integer for number of points. So,

return linspace(lower,upper_new,npnt)

needs to be

return linspace(lower,upper_new,int(npnt))

I'm using Python 3, so this may be a Py3 issue, or related to a new version of numpy (I'm using 1.18.1).

@hitranonline Is this repository being actively maintained? If so, I can make a PR.

The error that I was getting before this change was the following:

Traceback (most recent call last):
  File "/Users/danhickstein/Documents/NIST/2017-10-30 - Dual Comb/HITRAN/plot_HITRAN0.4.py", line 58, in <module>
    nu,c = hapi.absorptionCoefficient_Lorentz(((m, 1),), filename, HITRAN_units=False, Environment=environ)
  File "/Users/danhickstein/Documents/NIST/2017-10-30 - Dual Comb/HITRAN/hapi.py", line 19201, in absorptionCoefficient_Lorentz
    Omegas = arange_(OmegaRange[0],OmegaRange[1],OmegaStep) # fix
  File "/Users/danhickstein/Documents/NIST/2017-10-30 - Dual Comb/HITRAN/hapi.py", line 161, in arange_
    return linspace(lower,upper_new,npnt)
  File "<__array_function__ internals>", line 6, in linspace
  File "/Users/danhickstein/opt/anaconda3/lib/python3.7/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.
erwanp commented 4 years ago

I believe it's related to #15 too !

DanHickstein commented 4 years ago

Yup, looks like this is a duplicate of #15. I'll close this one. Thanks for pointing this out @erwanp, and thanks for (via email) pointing me towards the RADIS package. It looks really useful.

erwanp commented 4 years ago

Cool if it can help until HAPI is updated to Python 3!!