shbhuk / barycorrpy

Python version of Barycorr
GNU General Public License v3.0
37 stars 6 forks source link

Does Not Work with Astropy==4.0.0 #33

Closed bjfultn closed 4 years ago

bjfultn commented 4 years ago

Here is the error I see when running under astropy==4.0.0. I recommend specific package versions be specified in a requirements.txt file to avoid this type of issue.

Traceback (most recent call last):
  File "./barytest.py", line 41, in <module>
    result = my_sample()
  File "./barytest.py", line 36, in my_sample
    result3=get_BC_vel(JDUTC=JDUTC, ra=ra, dec=dec, obsname=obsname, pmra=pmra, pmdec=pmdec, px=px, rv=rv, leap_update=True)
  File "/Users/bjfulton/anaconda3/envs/barycorr/lib/python3.7/site-packages/barycorrpy/barycorrpy.py", line 166, in get_BC_vel
    ephemeris=ephemeris, leap_dir=leap_dir, leap_update=leap_update,**star_output)
  File "/Users/bjfulton/anaconda3/envs/barycorr/lib/python3.7/site-packages/barycorrpy/barycorrpy.py", line 198, in BCPy
    r_pint, v_pint = PINT.gcrs_posvel_from_itrf(loc, JDUTC, JDTT)
  File "/Users/bjfulton/anaconda3/envs/barycorr/lib/python3.7/site-packages/barycorrpy/PINT_erfautils.py", line 88, in gcrs_posvel_from_itrf
    dX = np.interp(mjds, iers_tab['MJD'], iers_tab['dX_2000A']) * asec2rad
  File "<__array_function__ internals>", line 6, in interp
  File "/Users/bjfulton/anaconda3/envs/barycorr/lib/python3.7/site-packages/astropy/units/quantity.py", line 1498, in __array_function__
    args, kwargs, unit, out = function_helper(*args, **kwargs)
  File "/Users/bjfulton/anaconda3/envs/barycorr/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py", line 814, in interp
    (x, xp), _ = _quantities2arrays(x, xp)
  File "/Users/bjfulton/anaconda3/envs/barycorr/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py", line 350, in _quantities2arrays
    arrays = tuple((q._to_own_unit(arg)) for arg in args)
  File "/Users/bjfulton/anaconda3/envs/barycorr/lib/python3.7/site-packages/astropy/units/quantity_helper/function_helpers.py", line 350, in <genexpr>
    arrays = tuple((q._to_own_unit(arg)) for arg in args)
  File "/Users/bjfulton/anaconda3/envs/barycorr/lib/python3.7/site-packages/astropy/units/quantity.py", line 1339, in _to_own_unit
    _value = as_quantity.to_value(self.unit)
  File "/Users/bjfulton/anaconda3/envs/barycorr/lib/python3.7/site-packages/astropy/units/quantity.py", line 734, in to_value
    value = self._to_value(unit, equivalencies)
  File "/Users/bjfulton/anaconda3/envs/barycorr/lib/python3.7/site-packages/astropy/units/quantity.py", line 665, in _to_value
    equivalencies=equivalencies)
  File "/Users/bjfulton/anaconda3/envs/barycorr/lib/python3.7/site-packages/astropy/units/core.py", line 987, in to
    return self._get_converter(other, equivalencies=equivalencies)(value)
  File "/Users/bjfulton/anaconda3/envs/barycorr/lib/python3.7/site-packages/astropy/units/core.py", line 918, in _get_converter
    raise exc
  File "/Users/bjfulton/anaconda3/envs/barycorr/lib/python3.7/site-packages/astropy/units/core.py", line 904, in _get_converter
    self, other, self._normalize_equivalencies(equivalencies))
  File "/Users/bjfulton/anaconda3/envs/barycorr/lib/python3.7/site-packages/astropy/units/core.py", line 888, in _apply_equivalencies
    unit_str, other_str))
astropy.units.core.UnitConversionError: '' (dimensionless) and 'd' (time) are not convertible
bjfultn commented 4 years ago

I should mention that downgrading to astropy==3.2.3 allows the same script to run just fine.

shbhuk commented 4 years ago

Hi BJ, I tested this. Weird.

Could you please tell me the following when you get the error -

1) Astropy version 2) Astroquery version 3) Numpy version 4) Barycorrpy version

import numpy as np
import astropy
import astroquery
import barycorrpy

print("numpy = {}".format(np.__version__))
print("astropy = {}".format(astropy.__version__))
print("astroquery = {}".format(astroquery.__version__))
print("barycorrpy = {}".format(barycorrpy.__version__))
bjfultn commented 4 years ago
numpy = 1.18.1
astropy = 4.0
astroquery = 0.3.10
barycorrpy = 0.2.3
bjfultn commented 4 years ago

I now see that I seem to be running an older version of barycorrpy? Which is weird, because I'm messing with a fork of the repo that I just created yesterday.

bjfultn commented 4 years ago

Everything seems to indicate that I'm running version 0.3, especially since I'm making changes to the code that I see reflected after pip install .. However, the __init__.py file installed in my site-packages directory says 0.2.3.

bjfultn commented 4 years ago

Ah, this is because barycorrpy/build/lib/barycorrpy/__init__.py still has __version__==0.2.3

bjfultn commented 4 years ago

OK, I was able to fix this by removing the contents of the build directory and pip install . again. Then I get a proper install of barycorrpy==0.3 and it works with the following versions:

numpy = 1.18.1
astropy = 4.0
astroquery = 0.4
barycorrpy = 0.3
shbhuk commented 4 years ago

Oh I see. Do you know if there is a way I can prevent that from happening? Remove the build/ directory from the GitHub repo?

bjfultn commented 4 years ago

Yeah, I don't think the build directory needs to be in the GitHub repo. See PR #34

shbhuk commented 4 years ago

Will add it to the .gitignore