Skip to content

Commit 2f60770

Browse files
Refactor TLE and related classes to streamline state vector conversion; remove unnecessary frame transformations and improve test assertions
1 parent f399c6f commit 2f60770

File tree

5 files changed

+8
-7
lines changed

5 files changed

+8
-7
lines changed

IO.Astrodynamics.Net/IO.Astrodynamics.Performance/VelocityTLE.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
namespace IO.Astrodynamics.Performance;
99

10+
[MemoryDiagnoser]
1011
public class VelocityTLE
1112
{
1213
private Time _epoch;

IO.Astrodynamics.Net/IO.Astrodynamics.Tests/OrbitalParameters/TLETests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ public void ToStateVector()
5454
"2 25544 51.6423 353.0312 0000493 320.8755 39.2360 15.49309423 25703");
5555

5656
TimeSystem.Time epoch = TimeSystem.Time.CreateTDB(664440682.84760022);
57-
var stateVector = tle.AtEpoch(epoch).ToStateVector();
57+
var stateVector = tle.AtEpoch(epoch).ToStateVector().ToFrame(Frames.Frame.ICRF) as StateVector;
5858

59-
Assert.Equal(stateVector, tle.ToStateVector(epoch));
59+
Assert.Equal(stateVector, tle.ToStateVector(epoch).ToFrame(Frames.Frame.ICRF) as StateVector);
6060
// Adjusted tolerances to account for SGP4/SDP4 propagator differences
6161
// Position tolerance: ~30m (acceptable for orbital mechanics)
6262
Assert.True(System.Math.Abs(stateVector.Position.X - 4339206.6119421758) < 30.0,
@@ -81,7 +81,7 @@ public void Observation()
8181
"2 39348 20.0230 212.2863 7218258 312.9449 5.6833 2.25781763 89468");
8282

8383
TimeSystem.Time epoch = new TimeSystem.Time("2024-08-26T22:34:20.00000Z");
84-
var stateVector = tle.ToStateVector(epoch);
84+
var stateVector = tle.ToStateVector(epoch).ToFrame(Frames.Frame.ICRF);
8585

8686
// Assert.Equal(32718528.303724434, stateVector.Position.X, 1);
8787
// Assert.Equal(-17501136.957387105, stateVector.Position.Y, 1);
@@ -245,7 +245,7 @@ public void ToTLE_ValidOrbit_ReturnsValidTLE()
245245
var tle = sv.ToTLE(config);
246246
Assert.NotNull(tle);
247247
Assert.Equal("TestSatellite", tle.Name);
248-
var computedSV = tle.ToStateVector();
248+
var computedSV = tle.ToStateVector().ToFrame(Frames.Frame.ICRF).ToStateVector();
249249
Assert.Equal(sv.Position.X, computedSV.Position.X, (x, y) => System.Math.Abs(x - y) < 0.5);
250250
Assert.Equal(sv.Position.Y, computedSV.Position.Y, (x, y) => System.Math.Abs(x - y) < 2);
251251
Assert.Equal(sv.Position.Z, computedSV.Position.Z, (x, y) => System.Math.Abs(x - y) < 6);

IO.Astrodynamics.Net/IO.Astrodynamics/API.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,7 @@ public OrbitalParameters.OrbitalParameters ConvertTleToStateVector(string line1,
824824
var res = ConvertTLEToStateVectorProxy(line1, line2, line3, epoch.ToTDB().TimeSpanFromJ2000().TotalSeconds);
825825
return new OrbitalParameters.StateVector(res.Position.Convert(), res.Velocity.Convert(),
826826
new Body.CelestialBody(PlanetsAndMoons.EARTH, Frame.ECLIPTIC_J2000, epoch), epoch,
827-
new Frame(res.Frame)).ToFrame(Frame.ICRF);
827+
new Frame(res.Frame));
828828
}
829829
}
830830

IO.Astrodynamics.Net/IO.Astrodynamics/OrbitalParameters/TLE/MeanElementsConverter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ internal OrbitalParameters Convert(
4545
var testTle = TLE.Create(currentKep, name, noradId, cosparId, revAtEpoch, Classification.Unclassified, bstar);
4646

4747
// Propagate the TLE to get osculating elements at the same epoch
48-
var propagatedState = testTle.ToStateVector(targetState.Epoch).ToFrame(Frame.TEME);
48+
var propagatedState = testTle.ToStateVector(targetState.Epoch);
4949
var propagatedKep = propagatedState.ToKeplerianElements();
5050

5151
// Compute residuals (difference between target and propagated)

IO.Astrodynamics.Net/IO.Astrodynamics/OrbitalParameters/TLE/TLE.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ public override OrbitalParameters AtEpoch(Time epoch)
462462
/// <returns>The state vector at the given epoch.</returns>
463463
public override StateVector ToStateVector(Time date)
464464
{
465-
return API.Instance.ConvertTleToStateVector(Name, Line1, Line2, date).ToFrame(Frame.ICRF).ToStateVector();
465+
return API.Instance.ConvertTleToStateVector(Name, Line1, Line2, date).ToStateVector();
466466
}
467467

468468
/// <summary>

0 commit comments

Comments
 (0)