Open jindal12ketan opened 2 months ago
Is this closed by https://github.com/kylebarron/suncalc-py/pull/18 now?
`def getMoonIllumination(date):
d = to_days(date)
s = sun_coords(d)
m = moon_coords(d)
# distance from Earth to Sun in km
sdist = 149598000
phi = acos(
sin(s['dec']) * sin(m['dec']) +
cos(s['dec']) * cos(m['dec']) * cos(s['ra'] - m['ra']))
inc = atan(sdist * sin(phi), m['dist'] - sdist * cos(phi))
angle = atan(
cos(s['dec']) * sin(s['ra'] - m['ra']),
sin(s['dec']) * cos(m['dec']) -
cos(s['dec']) * sin(m['dec']) * cos(s['ra'] - m['ra']))
return {
'fraction': (1 + cos(inc)) / 2,
'phase': 0.5 + 0.5 * inc * np.sign(angle) / PI,
'angle': angle}
`
Why do we keep the distance of the sun-earth constant? Isn't the distance between Earth and the sun by date and time?
This library is a direct port of the upstream https://github.com/mourner/suncalc. It's been a while since I've worked with the code, so you'd have to look at the upstream version and ask questions there.
Okay
Here in function for Moon Illumination there should be some changes to be happen: 1)
inc = atan(sdist * sin(phi), m['dist'] - sdist * cos(phi)),
# comma should not be there after calculating atan 2)sdist = 149597870.7
position of sun should not be constant for given dateto calculate the distance between sun and earth we should use true_anomaly of sun like below.
`def true_anomaly(days): M = solar_mean_anomaly(days) E = M epsilon = 1e-6 maxiterations = 100 for in range(max_iterations): E_new = E - (E - e np.sin(E) - M) / (1 - e np.cos(E)) if abs(E_new - E) < epsilon: break E = E_new