diff --git a/kosmorrolib/enum.py b/kosmorrolib/enum.py index a272e48..b4438e9 100644 --- a/kosmorrolib/enum.py +++ b/kosmorrolib/enum.py @@ -15,12 +15,14 @@ class MoonPhaseType(Enum): LAST_QUARTER = 7 WANING_CRESCENT = 8 + class SeasonType(Enum): MARCH_EQUINOX = 0 JUNE_SOLSTICE = 1 SEPTEMBER_EQUINOX = 2 DECEMBER_SOLSTICE = 3 + class EventType(Enum): """An enumeration for the supported event types.""" diff --git a/kosmorrolib/events.py b/kosmorrolib/events.py index c9495e0..a68f1d7 100644 --- a/kosmorrolib/events.py +++ b/kosmorrolib/events.py @@ -195,13 +195,13 @@ def _search_maximal_elongations( ) for i, time in enumerate(times): - elongation = elongations[i] + elongation = round(elongations[i],1) events.append( Event( EventType.MAXIMAL_ELONGATION, [aster], translate_to_timezone(time.utc_datetime(), timezone), - details={ 'deg': elongation}, + details={"deg": f"{elongation}°"}, ) ) @@ -263,7 +263,9 @@ def _search_moon_perigee(start_time: Time, end_time: Time, timezone: int) -> [Ev return events -def _search_earth_season_change(start_time: Time, end_time: Time, timezone: int) -> [Event]: +def _search_earth_season_change( + start_time: Time, end_time: Time, timezone: int +) -> [Event]: """Function to find earth season change event. **Warning:** this is an internal function, not intended for use by end-developers. @@ -284,18 +286,22 @@ def _search_earth_season_change(start_time: Time, end_time: Time, timezone: int) [] """ events = [] - event_time, event_id = almanac.find_discrete(start_time,end_time,almanac.seasons(get_skf_objects())) + event_time, event_id = almanac.find_discrete( + start_time, end_time, almanac.seasons(get_skf_objects()) + ) if len(event_time) == 0: return [] - events.append(Event( - EventType.SEASON_CHANGE, - [], - translate_to_timezone(event_time.utc_datetime()[0], timezone), - details={'season':SeasonType(event_id[0])})) + events.append( + Event( + EventType.SEASON_CHANGE, + [], + translate_to_timezone(event_time.utc_datetime()[0], timezone), + details={"season": SeasonType(event_id[0])}, + ) + ) return events - def get_events(for_date: date = date.today(), timezone: int = 0) -> [Event]: """Calculate and return a list of events for the given date, adjusted to the given timezone if any. @@ -340,7 +346,7 @@ def get_events(for_date: date = date.today(), timezone: int = 0) -> [Event]: _search_maximal_elongations, _search_moon_apogee, _search_moon_perigee, - _search_earth_season_change + _search_earth_season_change, ]: found_events.append(fun(start_time, end_time, timezone)) diff --git a/tests/events.py b/tests/events.py index 70f12a7..b022a4b 100644 --- a/tests/events.py +++ b/tests/events.py @@ -74,7 +74,7 @@ EXPECTED_EVENTS = [ EventType.MAXIMAL_ELONGATION, [ASTERS[2]], datetime(2020, 2, 10, 13, 46), - details="18.2°", + details={'deg':"18.2°"}, ), Event(EventType.MOON_PERIGEE, [ASTERS[1]], datetime(2020, 2, 10, 20, 34)), ], @@ -86,14 +86,14 @@ EXPECTED_EVENTS = [ EventType.MAXIMAL_ELONGATION, [ASTERS[2]], datetime(2020, 3, 24, 1, 56), - details="27.8°", + details={'deg':"27.8°"}, ), Event(EventType.MOON_APOGEE, [ASTERS[1]], datetime(2020, 3, 24, 15, 39)), Event( EventType.MAXIMAL_ELONGATION, [ASTERS[3]], datetime(2020, 3, 24, 21, 58), - details="46.1°", + details={'deg':"46.1°"}, ), ], ),