astral
astral copied to clipboard
No moonrise when official almanac states there is (ditto sunrise)
INPUT
place = 'Auckland'
region = 'New Zealand'
latitude = -36.8509
longitude = 174.7645
elevation = 196 # metres above sea level
Timezone: Pacific/Auckland
Date: 2023-01-13
OUTPUT
moonrise: None moonset: 2023-01-13 11:37:00+13:00
Date: 2023-01-27
OUTPUT
moonrise: Moon never rises on this date. moonset: 2023-01-27 23:58:00+13:00
NOTE: The above times are New Zealand Daylight Saving Time (New Zealand Standard Time +01:00) in operation at these lunar events.
New Zealand Nautical Almanac 2022/23
(https://www.linz.govt.nz/sites/default/files/cust/hydro_almanac_moonrise-moonset_auckland_202223.pdf)
13 January 2023
moonrise: 23:14 moonset:10:37 These times are New Zealand Standard Time - add one hour for Daylight Saving Time
27 January 2023
moonrise: 11:15 moonset: 22:58 These times are New Zealand Standard Time - add one hour for Daylight Saving Time
In the absence of a moonrise or moonset, Astral.moon appears to returns None (when a moonrise (moonset) is found but is not for the required dat) - or a ValueError if no moonrise(moonset) is found.
Hope this is useful.
Have a similar issue, a missing moonset in Salt Lake City. To reproduce:
import datetime
from astral.geocoder import database, lookup
from astral.moon import moonrise, moonset
def test():
format_data = "%m/%d/%y %H:%M:%S.%f %Z"
print("====== test missing data on 5/17/23 =========")
day = datetime.date(year=2023, month=5, day=17)
slc = lookup("Salt Lake City", database())
try:
print(moonset(slc.observer, day).strftime(format_data))
except ValueError as e:
print(f'caught exception: {str(e)}')
test()
Running this results in:
❯ python3 test.py
====== test missing data on 5/17/23 =========
caught exception: Moon never sets on this date, at this location
This seems incorrect, since there was a moonset reported by timeanddate.com and pyephem
dawn, dusk, moonrise and moonset calculations for the rest of May look good, just this oddity.
Similar problem, missing moonrise at Russia/Moscow 2024 January 5 ValueError: Moon never rises on this date, at this location
Minimal repro:
import datetime
from astral.moon import moonrise
import astral
def repro(lat = 55.7522200, long = 37.6155600, search_date = datetime.date(2024, 1, 13)):
"""Latitude and longitude of Russia/Moscow 2024 January 5\n
ValueError: Moon never rises on this date, at this location"""
city = astral.LocationInfo(latitude=lat, longitude=long)
rise = moonrise(city.observer, search_date)
return rise
repro()
Im using Python 3.11.7
Every other moonrise in this month looks correct according to timeanddate.com
The following dates also produce this error: 2024-02-03 2024-03-03 2024-03-31 2024-04-30 2024-06-06 2024-07-05 2024-08-03 2024-09-01 2024-09-29 2024-10-28 2024-11-26 2024-12-24