Skip to content

Commit

Permalink
Flip day/night ratio to night/day (#292)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yun-Wu authored Oct 14, 2024
1 parent 45aa020 commit 9eee138
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
5 changes: 3 additions & 2 deletions ecoscope/analysis/astronomy.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import warnings

import numpy as np
import pyproj
import pandas as pd
import pyproj

try:
import astroplan
Expand Down Expand Up @@ -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
9 changes: 5 additions & 4 deletions tests/test_astronomy.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down Expand Up @@ -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"),
)
Expand Down

0 comments on commit 9eee138

Please sign in to comment.