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

Sunrise time calculation error #81

Open
tz850 opened this issue Nov 10, 2022 · 0 comments
Open

Sunrise time calculation error #81

tz850 opened this issue Nov 10, 2022 · 0 comments

Comments

@tz850
Copy link

tz850 commented Nov 10, 2022

version 3.2

I used latitude 39.3528 and longitude 106.7333 to calculate the sunrise and sunset times for the whole year of 2015, starting on February 3, 2015, the calculated sunrise time was later than the sunset time, and this was the case until December 7, 2015.

my code:

lat_station_val = 39.35277777777778
lon_station_val = 106.73333333333333

location_staion9 = LocationInfo('shizuishan','china','Asia/Shanghai',lat_station_val,lon_station_val)

data_file = open("result.csv", 'w') 
data_file.write("date,sunrise,sunset\n")

start_date = date(2015, 1, 1)
for i in range(0,365):
    delta=timedelta(days=i)
    cal_date = start_date + delta

    s = sun(location_staion9.observer, date=cal_date)
    utc_sunrise = s["sunrise"]
    utc_sunset = s["sunset"]

    data_file.write("{},{},{}\n".format(cal_date.strftime('%Y-%m-%d'), utc_sunrise.strftime('%Y-%m-%d %H:%M:%S'), utc_sunset.strftime('%Y-%m-%d %H:%M:%S')))

the result:

2015-01-28,2015-01-28 00:04:28,2015-01-28 10:07:44
2015-01-29,2015-01-29 00:03:41,2015-01-29 10:08:55
2015-01-30,2015-01-30 00:02:52,2015-01-30 10:10:06
2015-01-31,2015-01-31 00:02:01,2015-01-31 10:11:16
2015-02-01,2015-02-01 00:01:08,2015-02-01 10:12:27
2015-02-02,2015-02-02 00:00:14,2015-02-02 10:13:38
**2015-02-03,2015-02-03 23:58:20,2015-02-03 10:14:49**
2015-02-04,2015-02-04 23:57:21,2015-02-04 10:16:00
2015-02-05,2015-02-05 23:56:20,2015-02-05 10:17:11
2015-02-06,2015-02-06 23:55:18,2015-02-06 10:18:21
2015-02-07,2015-02-07 23:54:14,2015-02-07 10:19:32
2015-02-08,2015-02-08 23:53:09,2015-02-08 10:20:42
2015-02-09,2015-02-09 23:52:02,2015-02-09 10:21:53
2015-02-10,2015-02-10 23:50:54,2015-02-10 10:23:03
2015-02-11,2015-02-11 23:49:45,2015-02-11 10:24:13
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

1 participant