shbhuk / barycorrpy

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

Two errors when importing v0.2 (develbranch) #18

Closed gummiks closed 6 years ago

gummiks commented 6 years ago

Hi Shubham !

Testing @develbranch in Python 2.7, with a couple of errors:

First error:

In [1]: import barycorrpy
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-f8240f79aac9> in <module>()
----> 1 import barycorrpy

/Users/gks/anaconda/lib/python2.7/site-packages/barycorrpy/__init__.py in <module>()
----> 1 from . import utc_tdb
      2 from . import PINT_erfautils
      3 from . import read_HIP
      4 from . import sample_script
      5 from .barycorrpy import get_BC_vel,BCPy

/Users/gks/anaconda/lib/python2.7/site-packages/barycorrpy/utc_tdb.py in <module>()
     13 import scipy.constants as const
     14 from .read_HIP import find_hip
---> 15 from . import PINT_erfautils as PINT
     16
     17 # Parsing constants #

/Users/gks/anaconda/lib/python2.7/site-packages/barycorrpy/PINT_erfautils.py in <module>()
     16 from astropy.utils.iers import conf,IERS_A, IERS_A_URL, IERS_B, IERS_B_URL, IERS
     17 from astropy.utils.data import download_file
---> 18 from . import utc_tdb
     19
     20 conf.auto_max_age=15

ImportError: cannot import name utc_tdb

I was able to fix this by changing line 18 to: import utc_tdb 2nd error: After trying to import again, I get:

In [1]: import barycorrpy
The IERS Bulletin download may take a few minutes.
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-f8240f79aac9> in <module>()
----> 1 import barycorrpy

/Users/gks/anaconda/lib/python2.7/site-packages/barycorrpy/__init__.py in <module>()
      2 from . import PINT_erfautils
      3 from . import read_HIP
----> 4 from . import sample_script
      5 from .barycorrpy import get_BC_vel,BCPy
      6

/Users/gks/anaconda/lib/python2.7/site-packages/barycorrpy/sample_script.py in <module>()
      1 from __future__ import print_function
      2 from __future__ import division
----> 3 from .barycorrpy import get_BC_vel , exposure_meter_BC_vel
      4 from . import utc_tdb
      5 from astropy.time import Time

ImportError: cannot import name exposure_meter_BC_vel

This function seems to be missing ?

I hacked it by taking that out of the sample script to be able to run it on my computer.

indiajoe commented 6 years ago

@shbhuk The reason for this error is circular import. You are importing PINT_erfautils in utc_tdb and inside utc_tdb you are importing PINT_erfautils. In Python 2. it will not allow you to do such circular imports.

shbhuk commented 6 years ago

@indiajoe To fix this, should I do a selective import only inside the function that requires it?

In utc_tdb.py I am importing the PINT erfautils module to do the correction from JDUTC to BJDTDB. In PINT I need utc_tdb to convert JDUTC to JDTDB. I wanted to keep utc_tdb as the location for all the time conversion functions. Any suggestions?

shbhuk commented 6 years ago

I am unable to recreate the second error, do you think that is for the same reason?

shbhuk commented 6 years ago

I have fixed the first error (circular import) in commit 31bbd2845f54a74104e0a94d8a31166d4272279e . Thanks Joe!

Gummi, can you check and confirm that you no longer see this error.

gummiks commented 6 years ago

Awesome ! Thanks for fixing !

On Tue, Mar 20, 2018 at 10:52 AM, shbhuk notifications@github.com wrote:

Closed #18 https://github.com/shbhuk/barycorrpy/issues/18.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/shbhuk/barycorrpy/issues/18#event-1531117468, or mute the thread https://github.com/notifications/unsubscribe-auth/ABNtjU67HyLPeU2ZEgbVtyQGLOBbLnT_ks5tgRetgaJpZM4SWbQj .