jyotisham / jyotisha

Python tools for the astronomical / astrological vedAnga of Hindus
MIT License
88 stars 53 forks source link

Sunset computation broken beyond polar circle - raise exception. #13

Closed vvasuki closed 6 years ago

vvasuki commented 6 years ago

The code was working yesterday - https://github.com/sanskrit-coders/jyotisha/issues/10 . After I did some non-functional changes (renaming functions, reformatting code and the like), I faced a brentq error, which I fixed. But now I get the below:

No precomputed data available. Computing panchangam... DEBUG: 2017-12-15 15:03:57,622 {spatio_temporal.py:161}: 0.0 
DEBUG: 2017-12-15 15:03:57,622 {spatio_temporal.py:162}: 10 
DEBUG: 2017-12-15 15:03:57,623 {spatio_temporal.py:163}: -0.634040778754029 
DEBUG: 2017-12-15 15:03:57,623 {spatio_temporal.py:164}: 0.5376589639327491 
ERROR: 2017-12-15 15:03:57,769 {spatio_temporal.py:246}: 11 
[2017-12-15 15:03:57,770] ERROR in app: Exception on /jyotisha/v1/calendars/coordinates/80:16:12/13:05:24/years/2017 [GET]
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1612, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.6/dist-packages/flask/app.py", line 1598, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/usr/local/lib/python3.6/dist-packages/flask_restplus/api.py", line 313, in wrapper
    resp = resource(*args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/flask/views.py", line 84, in view
    return self.dispatch_request(*args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/flask_restplus/resource.py", line 44, in dispatch_request
    resp = meth(*args, **kwargs)
  File "/home/vvasuki/jyotisha/jyotisha/rest_api/api_v1.py", line 40, in get
    panchangam = scripts.get_panchangam(city=city, year=int(year), script=args['encoding'])
  File "/home/vvasuki/jyotisha/jyotisha/panchangam/scripts/__init__.py", line 32, in get_panchangam
    panchangam.compute_angams(computeLagnams=computeLagnams)
  File "/home/vvasuki/jyotisha/jyotisha/panchangam/spatio_temporal.py", line 247, in compute_angams
    raise (ValueError('Dec 31 does not appear to be Dhanurmasa!'))
ValueError: Dec 31 does not appear to be Dhanurmasa!

I fancy that karthik may be able to deduce what went wrong faster. In the meantime, I'll try to shift from doctests to pytest so as to enable continuous automated testing.

vvasuki commented 6 years ago

From the logs, it seems that the following call is returning 0:

  jd_sunset = swe.rise_trans(jd_start=jd_start, body=swe.SUN, lon=city.longitude,
                             lat=city.latitude, rsmi=swe.CALC_SET | swe.BIT_DISC_CENTER)[1][0]
vvasuki commented 6 years ago

As https://github.com/astrorigin/pyswisseph/issues/13 shows, this is false alarm. Leaving thread open so as to raise an exception for illegal input.

karthikraman commented 6 years ago

Fixed vide 171b70731504de298a944ebc496ee304c0c8f7e9