Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sunset time calculation with swe.rise_trans broken #13

Closed
vvasuki opened this issue Dec 15, 2017 · 4 comments
Closed

Sunset time calculation with swe.rise_trans broken #13

vvasuki opened this issue Dec 15, 2017 · 4 comments

Comments

@vvasuki
Copy link

vvasuki commented Dec 15, 2017

jd_sunset = swe.rise_trans(jd_start=2457753.5, body=swe.SUN, lon=13.09,
                             lat=80.27, rsmi=swe.CALC_SET | swe.BIT_DISC_CENTER)[1][0]

is returning 0 on my computer, which cannot possibly be the sunset time. And thereby leading to this problem: jyotisham/jyotisha#13 .

Could you please take a look?

PS: I installed the latest code with:

[~] 15:30:52$ sudo pip3 install git+https://github.com/astrorigin/pyswisseph@master -U
The directory '/home/vvasuki/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/vvasuki/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting git+https://github.com/astrorigin/pyswisseph@master
  Cloning https://github.com/astrorigin/pyswisseph (to master) to /tmp/pip-csolktm6-build
Installing collected packages: pyswisseph
  Found existing installation: pyswisseph 2.0.0.post2
    Uninstalling pyswisseph-2.0.0.post2:
      Successfully uninstalled pyswisseph-2.0.0.post2
  Running setup.py install for pyswisseph ... done
Successfully installed pyswisseph-2.5.1.post0
@astrorigin
Copy link
Owner

Inspect the whole result:

jd_sunset = swe.rise_trans(jd_start=2457753.5, body=swe.SUN, lon=13.09,
... lat=80.27, rsmi=swe.CALC_SET | swe.BIT_DISC_CENTER)
jd_sunset
((-2,), (0.0, 2.695100435457e-312, 2.7874627029316465e-291, 1.818790777727e-311, 2.7874625367389016e-291, 9.766745e-317, 4.343725384106e-311, 5.2865984597206454e-303, 9.76668e-317, nan))

Function has returned (-2), object is circumpolar

By exchanging lon/lat you get:

jd_sunset = swe.rise_trans(jd_start=2457753.5, body=swe.SUN, lon=80.27,
... lat=13.09, rsmi=swe.CALC_SET | swe.BIT_DISC_CENTER)
jd_sunset
((0,), (2457754.015392543, 2.695100435457e-312, 2.7874627029316465e-291, 3.84528846805e-313, 2.7874625367389016e-291, 9.746423e-317, 4.343725384106e-311, 5.2865976774675737e-303, 9.7666284e-317, nan))

@vvasuki
Copy link
Author

vvasuki commented Dec 16, 2017

Oh! I was beyond the arctic circle!
Sorry for the false alarm. 🙏
Wouldn't it be better to raise an exception in such a case though?

@astrorigin
Copy link
Owner

http://www.astro.com/swisseph/swephprg.htm#_Toc471829085

Conforming to the docs, an exception/error is raised if returned result is (-1) (internal - calc or ephemeris error)

In my opinion you could raise an exception on your side if you find returned result[0][0]==-2

And double-check your input variables

@vvasuki
Copy link
Author

vvasuki commented Dec 16, 2017

OK, Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants