diff --git a/ecoscope/analysis/astronomy.py b/ecoscope/analysis/astronomy.py index f9e0992f..825fb23d 100644 --- a/ecoscope/analysis/astronomy.py +++ b/ecoscope/analysis/astronomy.py @@ -1,7 +1,8 @@ import warnings + import numpy as np -import pyproj import pandas as pd +import pyproj try: import astroplan @@ -109,4 +110,4 @@ def get_daynight_ratio(traj, n_grid_points=150) -> pd.Series: day_distance += (day_night_df.dist_meters * i).sum() night_distance += ((1 - i) * day_night_df.dist_meters).sum() - return day_distance / night_distance + return night_distance / day_distance diff --git a/tests/test_astronomy.py b/tests/test_astronomy.py index 9d483317..50f53e75 100644 --- a/tests/test_astronomy.py +++ b/tests/test_astronomy.py @@ -1,7 +1,8 @@ -import pyproj import pandas as pd -from ecoscope.base import Trajectory +import pyproj + from ecoscope.analysis import astronomy +from ecoscope.base import Trajectory def test_to_EarthLocation(movebank_relocations): @@ -36,8 +37,8 @@ def test_daynight_ratio(movebank_relocations): trajectory = Trajectory.from_relocations(movebank_relocations) expected = pd.Series( [ - 2.212816, - 0.656435, + 0.451912, + 1.523379, ], index=pd.Index(["Habiba", "Salif Keita"], name="groupby_col"), )