Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: footprint was calculated on wrong side of orbit #20

Merged
merged 1 commit into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions tle_sat/satellite.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,24 +163,24 @@ def footprint(
self, t: datetime | Time, view_angles: ViewAngles, fov=FieldOfView(2.0, 2.0)
) -> Polygon:
try:
fr = self.los(
fl = self.los(
t,
-view_angles.across - 0.5 * fov.x,
view_angles.across + 0.5 * fov.x,
view_angles.along + 0.5 * fov.y,
)
fl = self.los(
fr = self.los(
t,
-view_angles.across + 0.5 * fov.x,
view_angles.across - 0.5 * fov.x,
view_angles.along + 0.5 * fov.y,
)
rl = self.los(
rr = self.los(
t,
-view_angles.across + 0.5 * fov.x,
view_angles.across - 0.5 * fov.x,
view_angles.along - 0.5 * fov.y,
)
rr = self.los(
rl = self.los(
t,
-view_angles.across - 0.5 * fov.x,
view_angles.across + 0.5 * fov.x,
view_angles.along - 0.5 * fov.y,
)
except OverflowError as exc:
Expand Down
46 changes: 40 additions & 6 deletions tle_sat/satellite_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,11 @@ def test_view_angles(polar_tle, t, o, v):
nullcontext(
Polygon(
(
(127.7379246591503, 76.95181009374622),
(129.391022866435, 77.1132119968597),
(128.95920974658245, 77.3478604621005),
(127.26201922293443, 77.19358515346873),
(127.7379246591503, 76.95181009374622),
(175.60359680143947, 76.98714113663245),
(177.22394652541345, 76.81734966236745),
(177.71903131823174, 77.05665979118999),
(176.05545933500957, 77.21951692944646),
(175.60359680143947, 76.98714113663245),
)
)
),
Expand All @@ -130,10 +130,44 @@ def test_footprint(polar_tle, t, v, f, expectation):
assert _precision(e, 8).equals(_precision(footprint, 8))

if isinstance(e, Polygon):
assert is_ccw(e.exterior)
assert is_ccw(footprint.exterior)
assert all(not is_ccw(interior) for interior in e.interiors)


@mark.parametrize(
"target,t,footprint",
(
(
Point(13, 53, 0),
datetime(2024, 4, 19, 21, 39, 59, tzinfo=timezone.utc),
Polygon(
(
(13.20496447259038, 52.87415752284107),
(12.758567800131482, 52.90986652401911),
(12.799711072078717, 53.12031287404936),
(13.249444062185855, 53.090245713914435),
(13.20496447259038, 52.87415752284107),
)
),
),
),
)
def test_pass_footprint(polar_tle, target: Point, t: datetime, footprint: Polygon):
sat = Satellite(polar_tle)

passes = sat.passes(
TimeOfInterest(t - timedelta(minutes=15), t + timedelta(minutes=15)), target
)
assert len(passes) == 1
p = passes[0]

actual_footprint = sat.footprint(t=p.t, view_angles=p.view_angles)

assert _precision(footprint, 8).equals(_precision(actual_footprint, 8))
assert actual_footprint.contains(target)
assert _precision(footprint.centroid, 2).equals(_precision(target, 2))


@mark.parametrize(
"t,target,passes",
(
Expand Down