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

Moon Illumination Issue #17

Open
jindal12ketan opened this issue Apr 15, 2024 · 4 comments
Open

Moon Illumination Issue #17

jindal12ketan opened this issue Apr 15, 2024 · 4 comments

Comments

@jindal12ketan
Copy link
Contributor

jindal12ketan commented Apr 15, 2024

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 date

to 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
max_iterations = 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

theta = 2 * np.arctan(np.sqrt((1 + e) / (1 - e)) * np.tan(E / 2))
return theta`
@kylebarron
Copy link
Owner

Is this closed by #18 now?

@jindal12ketan
Copy link
Contributor Author

jindal12ketan commented Apr 16, 2024

`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?

@kylebarron
Copy link
Owner

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.

@jindal12ketan
Copy link
Contributor Author

Okay

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