dhoomakethu / panchanga-cli

Command line version of drik-panchanga
GNU Affero General Public License v3.0
13 stars 5 forks source link

Finding full moon day #3

Open saikiran91 opened 4 years ago

saikiran91 commented 4 years ago

I finding a hard time converting the below code to calculate the last full moon and full moon day. Any help is greatly appreciated. Thanks.

# New moon day: sun and moon have same longitude (0 degrees = 360 degrees difference)
# Full moon day: sun and moon are 180 deg apart

def new_moon(jd, tithi_, opt = -1):
    """Returns JDN, where
       opt = -1:  JDN < jd such that lunar_phase(JDN) = 360 degrees
       opt = +1:  JDN >= jd such that lunar_phase(JDN) = 360 degrees
    """
    if opt == -1:  start = jd - tithi_         # previous new moon
    if opt == +1:  start = jd + (30 - tithi_)  # next new moon
    # Search within a span of (start +- 2) days
    x = [ -2 + offset/4 for offset in range(17) ]
    y = [lunar_phase(start + i) for i in x]
    y = unwrap_angles(y)
    y0 = inverse_lagrange(x, y, 360)
    return start + y0
dhoomakethu commented 4 years ago

What are you converting this code in to ? Are you trying to port it to another language?

saikiran91 commented 4 years ago

Firstly thanks for your quick response and sorry my question was different, I am struggling to calculate or find full moon day using the above code. The comment says Full moon day: sun and moon are 180 deg apart but tried this in a multiple-way, but fail to calculate last full moon and next full moon. I update the original question. @dhoomakethu

saikiran91 commented 4 years ago

@dhoomakethu Any update.