Skip to content

Commit

Permalink
add checks for coordinates out of range (#198)
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgeEfstathiadis authored Aug 17, 2023
1 parent df75066 commit 5375bc5
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions forest/jasmine/traj2stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,23 @@ def gps_stats_main(
logger.error("Error: %s", e)
continue
traj = imp_to_traj(imp_table, mobmat2, params_w)
# raise error if traj coordinates are not in the range of
# [-90, 90] and [-180, 180]
if traj.shape[0] > 0:
if (
np.max(traj[:, 1]) > 90
or np.min(traj[:, 1]) < -90
or np.max(traj[:, 2]) > 180
or np.min(traj[:, 2]) < -180
or np.max(traj[:, 4]) > 90
or np.min(traj[:, 4]) < -90
or np.max(traj[:, 5]) > 180
or np.min(traj[:, 5]) < -180
):
raise ValueError(
"Trajectory coordinates are not in the range of "
"[-90, 90] and [-180, 180]."
)
# save all_memory_dict and all_bv_set
with open(f"{output_folder}/all_memory_dict.pkl", "wb") as f:
pickle.dump(all_memory_dict, f)
Expand Down

0 comments on commit 5375bc5

Please sign in to comment.