Skip to content

Commit

Permalink
Feature/frame teme (#198)
Browse files Browse the repository at this point in the history
* Include sofa

* Convert to TEME, Add matrix functions

* Reach accurate result

* Build6X6 TEME matrix

* Transform TEME to ICRF AND ITRF Tests OK

* Upgrade with latest ITRFmodel

* Fix tests

* Update version

* Update geophysical constants to wsg84
  • Loading branch information
sylvain-guillet authored Sep 11, 2024
1 parent 3e3770c commit f0811ef
Show file tree
Hide file tree
Showing 76 changed files with 4,234 additions and 1,072 deletions.
2 changes: 1 addition & 1 deletion IO.Astrodynamics.Net/IO.Astrodynamics.CLI/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ internal static OrbitalParameters.OrbitalParameters ConvertToOrbitalParameters(s
{
if (originalFrame.Equals("icrf", StringComparison.InvariantCultureIgnoreCase))
{
originalFrame = "j2000";
originalFrame = "J2000";
}

var inputFrame = new Frame(originalFrame);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<FileVersion>0.0.1</FileVersion>
<PackAsTool>true</PackAsTool>
<ToolCommandName>astro</ToolCommandName>
<Version>0.4.0</Version>
<Version>0.5.0-preview-1</Version>
<Title>Astrodynamics command line interface</Title>
<Authors>Sylvain Guillet</Authors>
<Description>This CLI allows end user to exploit IO.Astrodynamics framework </Description>
Expand Down
44 changes: 22 additions & 22 deletions IO.Astrodynamics.Net/IO.Astrodynamics.Tests/APITest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ public void ExecuteLaunchScenario()
new Vector3(-3708.6305608890916, 4266.2914313011433, 6736.8538488755494), TestHelpers.EarthAtJ2000,
start, Frames.Frame.ICRF);

var sunset_rise = launchSite.FindWindowsOnIlluminationConstraint(window, TestHelpers.Sun, IlluminationAngle.Incidence, RelationnalOperator.Lower,
Astrodynamics.Constants.PI2 - Astrodynamics.Constants.CivilTwilight, 0.0, Aberration.CNS, TimeSpan.FromHours(6.0), TestHelpers.Sun);
//Create launch object
Launch launch = new Launch(launchSite, launchSite, parkingOrbit, IO.Astrodynamics.Constants.CivilTwilight,
true);
Expand All @@ -66,20 +68,18 @@ public void ExecuteLaunchScenario()
var res = API.Instance.FindLaunchWindows(launch, window, Constants.OutputPath).ToArray();

//Read results
Assert.Equal(3, res.Count());
Assert.Equal(2, res.Count());
Assert.Equal(
new Window(new TimeSystem.Time("2021-03-02 23:12:54.4214382").ToTDB(),
new TimeSystem.Time("2021-03-02 23:12:54.4214382").ToTDB()), res.ElementAt(0).Window);
Assert.Equal(
new Window(new TimeSystem.Time("2021-03-03 23:08:58.2431654").ToTDB(),
new TimeSystem.Time("2021-03-03 23:08:58.2431654").ToTDB()), res.ElementAt(1).Window);
new Window(new TimeSystem.Time("2021-03-02 23:12:54.4214440").ToTDB(),
new TimeSystem.Time("2021-03-02 23:12:54.4214440").ToTDB()), res.ElementAt(0).Window);

Assert.Equal(
new Window(new TimeSystem.Time("2021-03-04 23:05:01.7235513").ToTDB(),
new TimeSystem.Time("2021-03-04 23:05:01.7235513").ToTDB()), res.ElementAt(2).Window);
Assert.Equal(47.00618445347153, res.ElementAt(0).InertialAzimuth * IO.Astrodynamics.Constants.Rad2Deg, 9);
Assert.Equal(45.125545665662884, res.ElementAt(0).NonInertialAzimuth * IO.Astrodynamics.Constants.Rad2Deg, 9);
new Window(new TimeSystem.Time("2021-03-04 23:05:01.7235643").ToTDB(),
new TimeSystem.Time("2021-03-04 23:05:01.7235643").ToTDB()), res.ElementAt(1).Window);
Assert.Equal(47.006184454395374, res.ElementAt(0).InertialAzimuth * IO.Astrodynamics.Constants.Rad2Deg, 9);
Assert.Equal(45.125545666622976, res.ElementAt(0).NonInertialAzimuth * IO.Astrodynamics.Constants.Rad2Deg, 9);
Assert.Equal(8794.33812148836, res.ElementAt(0).InertialInsertionVelocity, 9);
Assert.Equal(8499.725885450212, res.ElementAt(0).NonInertialInsertionVelocity, 9);
Assert.Equal(8499.7258854462671, res.ElementAt(0).NonInertialInsertionVelocity, 9);
}

[Fact]
Expand Down Expand Up @@ -154,7 +154,7 @@ public void FindWindowsOnCoordinateConstraint()

var windows = res as Window[] ?? res.ToArray();
Assert.Single(windows);
Assert.Equal("2023-02-19T14:33:08.9180986 TDB", windows[0].StartDate.ToString());
Assert.Equal("2023-02-19T14:33:08.9179879 TDB", windows[0].StartDate.ToString());
Assert.Equal("2023-02-20T00:00:00.0000000 TDB", windows[0].EndDate.ToString());
Assert.Throws<ArgumentNullException>(() => API.Instance.FindWindowsOnCoordinateConstraint(
new Window(TimeSystem.Time.CreateTDB(730036800.0), TimeSystem.Time.CreateTDB(730123200)), null,
Expand Down Expand Up @@ -184,8 +184,8 @@ public void FindWindowsOnIlluminationConstraint()
var windows = res as Window[] ?? res.ToArray();
Assert.Equal(2, windows.Count());
Assert.Equal("2021-05-17T12:00:00.0000000 TDB", windows[0].StartDate.ToString());
Assert.Equal("2021-05-17T19:35:24.9088348 TDB", windows[0].EndDate.ToString());
Assert.Equal("2021-05-18T04:18:32.4437509 TDB", windows[1].StartDate.ToString());
Assert.Equal("2021-05-17T19:35:24.9088325 TDB", windows[0].EndDate.ToString());
Assert.Equal("2021-05-18T04:18:32.4437507 TDB", windows[1].StartDate.ToString());
Assert.Equal("2021-05-18T12:00:00.0000000 TDB", windows[1].EndDate.ToString());
Assert.Throws<ArgumentNullException>(() => API.Instance.FindWindowsOnIlluminationConstraint(
new Window(TimeSystem.Time.CreateTDB(674524800), TimeSystem.Time.CreateTDB(674611200)),
Expand Down Expand Up @@ -489,13 +489,13 @@ void TransformFrame()
//Get the quaternion to transform
var res = API.Instance.TransformFrame(Frames.Frame.ICRF, new Frames.Frame(PlanetsAndMoons.EARTH.Frame),
TimeSystem.Time.J2000TDB);
Assert.Equal(0.76713121189662548, res.Rotation.W);
Assert.Equal(-1.8618846012434252e-05, res.Rotation.VectorPart.X);
Assert.Equal(8.468919252183845e-07, res.Rotation.VectorPart.Y);
Assert.Equal(0.64149022080358797, res.Rotation.VectorPart.Z);
Assert.Equal(-1.9637714059853662e-09, res.AngularVelocity.X);
Assert.Equal(-2.0389340573814659e-09, res.AngularVelocity.Y);
Assert.Equal(7.2921150642488516e-05, res.AngularVelocity.Z);
Assert.Equal(0.76713121207787449, res.Rotation.W, 6);
Assert.Equal(-1.8618836714990174E-05, res.Rotation.VectorPart.X, 6);
Assert.Equal(8.4688405480964646E-07, res.Rotation.VectorPart.Y, 6);
Assert.Equal(0.64149022058684046, res.Rotation.VectorPart.Z, 6);
Assert.Equal(-1.9637713280171745E-09, res.AngularVelocity.X, 6);
Assert.Equal(-2.0389347198634933E-09, res.AngularVelocity.Y, 6);
Assert.Equal(7.2921150643333896E-05, res.AngularVelocity.Z, 6);
}

[Fact]
Expand Down Expand Up @@ -649,7 +649,7 @@ void ConvertConicToState()
Assert.Equal(ke.Frame, ke2.Frame);
Assert.Equal(ke.Observer, ke2.Observer);
}

[Fact]
void ConvertConicHyperbolicToState()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,9 @@ public void SubObserverPoint()
{
var moon = TestHelpers.MoonAtJ2000;
var res = moon.SubObserverPoint(TestHelpers.EarthAtJ2000, TimeSystem.Time.J2000TDB, Aberration.None);
Assert.Equal(-10.898058558227296, res.Latitude * Constants.RAD_DEG);
Assert.Equal(-57.74660136367262, res.Longitude * Constants.RAD_DEG);
Assert.Equal(402448639.8873273, res.Radius);
Assert.Equal(-10.898058559403337, res.Latitude * Constants.RAD_DEG);
Assert.Equal(-57.746601395904747, res.Longitude * Constants.RAD_DEG);
Assert.Equal(402448639.88732719, res.Radius);
}

[Fact]
Expand All @@ -217,8 +217,8 @@ public void RadiusFromLatitude()
public void GetOrientation()
{
var orientation = TestHelpers.EarthAtJ2000.GetOrientation(Frames.Frame.ICRF, TimeSystem.Time.J2000TDB);
Assert.Equal(new Vector3(-1.963771405985366E-09, -2.038934057381466E-09, 7.292115064248852E-05), orientation.AngularVelocity);
Assert.Equal(new Quaternion(0.7671312118966255, -1.8618846012434252E-05, 8.468919252183845E-07, 0.641490220803588), orientation.Rotation);
Assert.Equal(new Vector3(-1.9637713280171745E-09, -2.0389347198634933E-09, 7.29211506433339E-05), orientation.AngularVelocity);
Assert.Equal(new Quaternion(0.7671312120778745, -1.8618836714990174E-05, 8.468840548096465E-07, 0.6414902205868405), orientation.Rotation);
Assert.Equal(TimeSystem.Time.J2000TDB, orientation.Epoch);
Assert.Equal(Frames.Frame.ICRF, orientation.ReferenceFrame);
}
Expand All @@ -227,7 +227,7 @@ public void GetOrientation()
public void EarthSideralRotationPerdiod()
{
var duration = TestHelpers.EarthAtJ2000.SideralRotationPeriod(TimeSystem.Time.J2000TDB);
Assert.Equal(TimeSpan.FromTicks(861640998130), duration);
Assert.Equal(TimeSpan.FromTicks(861640998120), duration);
}

[Fact]
Expand All @@ -241,7 +241,7 @@ public void MoonSideralRotationPerdiod()
public void GeosynchronousOrbit()
{
var orbit = TestHelpers.EarthAtJ2000.GeosynchronousOrbit(0.0, 0.0, new TimeSystem.Time(new DateTime(2021, 1, 1, 0, 0, 0, DateTimeKind.Unspecified), TimeFrame.TDBFrame));
Assert.Equal(42164171.961220242, orbit.ToStateVector().Position.Magnitude(),6);
Assert.Equal(42164171.95991531, orbit.ToStateVector().Position.Magnitude(),6);
Assert.Equal(3074.6599900324436, orbit.ToStateVector().Velocity.Magnitude(),6);
Assert.Equal(Frames.Frame.ICRF, orbit.Frame);
}
Expand All @@ -250,16 +250,16 @@ public void GeosynchronousOrbit()
public void GeosynchronousOrbit2()
{
var orbit = TestHelpers.EarthAtJ2000.GeosynchronousOrbit(1.0, 1.0, new TimeSystem.Time(new DateTime(2021, 1, 1, 0, 0, 0, DateTimeKind.Unspecified), TimeFrame.TDBFrame));
Assert.Equal(42164171.961220242, orbit.ToStateVector().Position.Magnitude(), 3);
Assert.Equal(42164171.95991531, orbit.ToStateVector().Position.Magnitude(), 3);
Assert.Equal(3074.6599898500763, orbit.ToStateVector().Velocity.Magnitude(), 3);
Assert.Equal(Frames.Frame.ICRF, orbit.Frame);
Assert.Equal(42164171.961220235, orbit.SemiMajorAxis(), 6);
Assert.Equal(42164171.95991531, orbit.SemiMajorAxis(), 6);
Assert.Equal(0.0, orbit.Eccentricity());
Assert.Equal(1.0, orbit.Inclination(), 2);
Assert.Equal(1.1804318466570587, orbit.AscendingNode(), 2);
Assert.Equal(1.569, orbit.ArgumentOfPeriapsis(), 2);
Assert.Equal(0.0, orbit.MeanAnomaly(), 2);
Assert.Equal(new Vector3(-20992029.309525054, 8679264.319910558, 35522140.6098861), orbit.ToStateVector().Position, TestHelpers.VectorComparer);
Assert.Equal(new Vector3(-20992029.30603332, 8679264.322745558, 35522140.60970795), orbit.ToStateVector().Position, TestHelpers.VectorComparer);
Assert.Equal(new Vector3(-1171.3783810266016, -2842.7805399479103, 2.354430257176734), orbit.ToStateVector().Velocity, TestHelpers.VectorComparer);
}

Expand Down Expand Up @@ -312,7 +312,7 @@ public void PhaseHelioSynchronousOrbit()
{
var epoch = new TimeSystem.Time(new DateTime(2021, 11, 22, 0, 0, 0, DateTimeKind.Unspecified), TimeFrame.TDBFrame);
var res = TestHelpers.Earth.HelioSynchronousOrbit(0.0001724, epoch, 14);
Assert.Equal(7272221.876563848, res.A, 3);
Assert.Equal(7272221.8764740732, res.A, 3);
Assert.Equal(0.0001724, res.E, 6);
Assert.Equal(99.018, res.I * Astrodynamics.Constants.Rad2Deg, 3);
Assert.Equal(327.43000000000001, res.RAAN * Astrodynamics.Constants.Rad2Deg, 3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public void ComputeGeopotentialGravityAcceleration()
TimeSystem.Time.J2000TDB,
Frames.Frame.ICRF);
var res = gravity.ComputeGravitationalAcceleration(parkingOrbit);
Assert.Equal(new Vector3(-8.621408092022794, -1.7763568394002505E-15, 9.486769009248164E-20), res);
Assert.Equal(new Vector3(-8.621408092022785, 0.0, -4.0657581468206416E-20), res);
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,19 @@ public void ToCartesian()
var res = plan.ToCartesianCoordinates();
Assert.Equal(new Vector3(-55658443.24257991, -379226329.314363, -126505930.63558689), res);
}

[Fact]
public void ToCartesian2()
{
var geodetic = new Planetodetic(19.89367 * Constants.DEG_RAD, 47.91748 * Constants.DEG_RAD, 984);
var plan = geodetic.ToPlanetocentric(TestHelpers.EarthAtJ2000.Flattening, TestHelpers.EarthAtJ2000.EquatorialRadius);
var res = plan.ToCartesianCoordinates();

var centric = new Planetocentric(19.89367 * Constants.DEG_RAD, 47.91748 * Constants.DEG_RAD, 6367310.6587192528);
var plentodetic = centric.ToPlanetodetic(TestHelpers.EarthAtJ2000.Flattening, TestHelpers.EarthAtJ2000.EquatorialRadius);
var res2 = centric.ToCartesianCoordinates();

}

[Fact]
public void ToPlanetodetic()
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ public void ToNonInertialFrame()

Assert.Equal(epoch, q.Epoch);
Assert.Equal(moonFrame, q.ReferenceFrame);
Assert.Equal(new Quaternion(0.5044792582956342, 0.2009316556383325, 0.06427003637545137, 0.8372553434503859), q.Rotation);
Assert.Equal(new Vector3(1.980539178135755E-05, 2.2632012450014214E-05, 6.376864584829888E-05), q.AngularVelocity);
Assert.Equal(7.050462200789696E-05, q.AngularVelocity.Magnitude());
Assert.Equal(new Quaternion(0.5044792585297516, 0.20093165566257334, 0.06427003630843892, 0.8372553433086475), q.Rotation);
Assert.Equal(new Vector3(1.9805391781278776E-05, 2.263201244975088E-05, 6.376864584934005E-05), q.AngularVelocity);
Assert.Equal(7.0504622008731998E-05, q.AngularVelocity.Magnitude());
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@
<Content Include="Data\SolarSystem\earth_fixed.tf">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<None Remove="Data\SolarSystem\earth_latest_high_prec.bpc" />
<Content Include="Data\SolarSystem\earth_latest_high_prec.bpc">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<None Remove="Data\SolarSystem\earth_topo_201023.tf" />
<Content Include="Data\SolarSystem\earth_topo_201023.tf">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
Expand Down Expand Up @@ -120,6 +116,10 @@
<Content Include="Data\UserDataTest\scn100\Spacecrafts\DRAGONFLY32\Clocks\DRAGONFLY32.tsc">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<None Remove="Data\SolarSystem\earth_latest_high_prec.bpc" />
<Content Include="Data\SolarSystem\earth_latest_high_prec.bpc">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>

</Project>
Loading

0 comments on commit f0811ef

Please sign in to comment.