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

Discontinuity just after sunset #155

Open
martinmCGG opened this issue Nov 4, 2022 · 1 comment
Open

Discontinuity just after sunset #155

martinmCGG opened this issue Nov 4, 2022 · 1 comment

Comments

@martinmCGG
Copy link

PySolar seems to produce discontinuous sun elevation/altitude around sunset (and also near sunrise): there is a ~0.6deg jump in the following test case. May be related to #115.

Minimal example showing the issue:

import pysolar.solar as solar
import datetime
import matplotlib.pyplot as plt
import numpy as np

lat, long = 37.249870621332086, -115.81458511013524 # a randomly picked position
strange_timestamp = 1565491275.92175
epsilon = 420 #3600*12 #0.00008 # <- scale
x = np.linspace(strange_timestamp - epsilon, strange_timestamp + epsilon, 100)
y = [solar.get_altitude(lat, long, datetime.datetime.fromtimestamp(t).astimezone(datetime.timezone.utc)) for t in x]
plt.scatter(x, y, label='pysolar')

# optional, for comparison (pip install pysolar suncalc)
import suncalc
y2 = [np.rad2deg(suncalc.get_position(datetime.datetime.fromtimestamp(t).astimezone(datetime.timezone.utc), long, lat)['altitude']) for t in x]
plt.scatter(x, y2, label='suncalc')
plt.legend()
plt.show()

pysolar

@pingswept
Copy link
Owner

Interesting. That certainly looks like a bug. Thanks for the test case.

My guess is that some correction factor is blowing up as altitude nears zero.

I’d welcome more details from anyone who wanted to dig into the details.

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

No branches or pull requests

2 participants