diff --git a/docs/source/changelog.rst b/docs/source/changelog.rst index 6eb15fc..79fcddb 100644 --- a/docs/source/changelog.rst +++ b/docs/source/changelog.rst @@ -1,6 +1,15 @@ Changelog --------- +PyHamtools 0.7.9 +================ + +16. December 2021 + +* Calculating sunrise and sunset close to the artic region raised a ValueError due + to a bug in the underlying 3rd party libary ephem. This release upgrades the + dependency to ephem > 4.1.3 which has the bug already fixed. + PyHamTools 0.7.8 ================ diff --git a/pyhamtools/version.py b/pyhamtools/version.py index e9c73fb..51328ec 100644 --- a/pyhamtools/version.py +++ b/pyhamtools/version.py @@ -1,3 +1,3 @@ -VERSION = (0, 7, 8) +VERSION = (0, 7, 9) __release__ = ''.join(['-.'[type(x) == int]+str(x) for x in VERSION])[1:] __version__ = '.'.join((str(VERSION[0]), str(VERSION[1]))) diff --git a/setup.py b/setup.py index 02ffdcd..045c9e9 100755 --- a/setup.py +++ b/setup.py @@ -18,7 +18,7 @@ setup(name='pyhamtools', install_requires=[ "pytz>=2019.1", "requests>=2.21.0", - "pyephem>=3.7.6.0", + "ephem>=4.1.3", "beautifulsoup4>=4.7.1", "future>=0.17.1", "redis>=2.10.6", diff --git a/test/test_locator_sunrise_sunset.py b/test/test_locator_sunrise_sunset.py index 79f02a4..a11b6b8 100644 --- a/test/test_locator_sunrise_sunset.py +++ b/test/test_locator_sunrise_sunset.py @@ -25,17 +25,30 @@ class Test_calculate_sunrise_sunset_normal_case(): assert calculate_sunrise_sunset(locator, test_time)['sunset'] - result_JN48QM_1_1_2014_sunset < time_margin assert calculate_sunrise_sunset(locator, test_time)['sunrise'] - result_JN48QM_1_1_2014_sunrise < time_margin - def test_calculate_distance_edge_case(self): + + def test_calculate_sunrise_sunset_with_sun_never_rising(self): + + time_margin = timedelta(minutes=1) + locator = "IQ50PW" + # The sun never rises in winter time close to the north pole (e.g. at Jan Mayen) + # Therefore we expect no sunrise or sunset. + + test_time = datetime(year=2021, month=12, day=15, tzinfo=UTC) + + assert calculate_sunrise_sunset(locator, test_time)['morning_dawn'] == None + assert calculate_sunrise_sunset(locator, test_time)['evening_dawn'] == None + assert calculate_sunrise_sunset(locator, test_time)['sunset'] == None + assert calculate_sunrise_sunset(locator, test_time)['sunrise'] == None + + + def test_calculate_sunrise_sunset_with_sun_never_setting(self): time_margin = timedelta(minutes=1) locator = "AA00AA" - # no sunrise or sunset at southpol during arctic summer + # The sun never sets at the south pole during arctic summer + # Therefore we expect no sunrise or sunset. test_time = datetime(year=2014, month=1, day=1, tzinfo=UTC) - result_AA00AA_1_1_2014_evening_dawn = datetime(2014, 1, 1, 15, 38, tzinfo=UTC) - result_AA00AA_1_1_2014_morning_dawn = datetime(2014, 1, 1, 6, 36, tzinfo=UTC) - result_AA00AA_1_1_2014_sunrise = datetime(2014, 1, 1, 7, 14, tzinfo=UTC) - result_AA00AA_1_1_2014_sunset = datetime(2014, 1, 1, 16, 15, 23, 31016, tzinfo=UTC) assert calculate_sunrise_sunset(locator, test_time)['morning_dawn'] == None assert calculate_sunrise_sunset(locator, test_time)['evening_dawn'] == None