Skip to content

Commit

Permalink
features/removespicedependencies (#218)
Browse files Browse the repository at this point in the history
* Add bodies factory

* Fixes

* Upgrade sgp4
  • Loading branch information
sylvain-guillet authored Oct 2, 2024
1 parent 2c56a55 commit b73bca1
Show file tree
Hide file tree
Showing 33 changed files with 347 additions and 105 deletions.
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.5.0-preview-9</Version>
<Version>0.5.0-preview-10</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
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public BarycenterTests()
[Fact]
public void Create()
{
var earthbc = new Barycenter(Barycenters.EARTH_BARYCENTER.NaifId);
var earthbc = Barycenters.EARTH_BARYCENTER;
Assert.Equal("EARTH BARYCENTER", earthbc.Name);
Assert.Equal(3, earthbc.NaifId);
Assert.Equal(6.0456262922775433E+24, earthbc.Mass);
Expand All @@ -25,7 +25,7 @@ public void Create()
[Fact]
public void Mass()
{
var earthbc = new Barycenter(Barycenters.EARTH_BARYCENTER.NaifId);
var earthbc = Barycenters.EARTH_BARYCENTER;
Assert.Equal(6.0456262922775433E+24, earthbc.Mass);
}
}
107 changes: 103 additions & 4 deletions IO.Astrodynamics.Net/IO.Astrodynamics.Tests/Body/CelestialBodyTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public CelestialBodyTests()
[Fact]
public void Create()
{
CelestialBody earth = new CelestialBody(PlanetsAndMoons.EARTH);
CelestialBody earth = PlanetsAndMoons.EARTH_BODY;

Assert.Equal(399, earth.NaifId);
Assert.Equal("EARTH", earth.Name);
Expand Down Expand Up @@ -154,8 +154,8 @@ public void CelestialBodyToString()
[Fact]
public void Equality()
{
var earth1 = new CelestialBody(PlanetsAndMoons.EARTH);
var earth2 = new CelestialBody(PlanetsAndMoons.EARTH);
var earth1 = PlanetsAndMoons.EARTH_BODY;
var earth2 = PlanetsAndMoons.EARTH_BODY;
var moon = new CelestialBody(PlanetsAndMoons.MOON);
Assert.Equal(earth1, earth2);
Assert.NotEqual(earth1, moon);
Expand All @@ -172,7 +172,7 @@ public void Equality()
[Fact]
public void GetEphemeris()
{
var earth = new CelestialBody(PlanetsAndMoons.EARTH);
var earth = PlanetsAndMoons.EARTH_BODY;
var res = earth.GetEphemeris(new Window(TimeSystem.Time.J2000TDB, TimeSpan.FromDays(1.0)), TestHelpers.Sun, Frames.Frame.ICRF, Aberration.None,
TimeSpan.FromDays(1.0)).ToArray();
Assert.Equal(2, res.Length);
Expand Down Expand Up @@ -416,4 +416,103 @@ public void MarsAirDensity()
Assert.Equal(0.015026759563140498, model.GetDensity(0.0));
Assert.Equal(0.0013352044980975983, model.GetDensity(30000.0));
}

[Fact]
public void FindBarycenterOfMotionId_ReturnsZero_ForSun()
{
var celestialItem = TestHelpers.Sun;
Assert.Equal(0, celestialItem.BarycenterOfMotionId);
}

[Fact]
public void FindBarycenterOfMotionId_ReturnsZero_ForBarycenter()
{
var celestialItem = new Barycenter(0);
Assert.Equal(0, celestialItem.BarycenterOfMotionId);
}

[Fact]
public void FindBarycenterOfMotionId_ReturnsZero_ForAsteroid()
{
var celestialItem = new CelestialBody(2000001);
Assert.Equal(0, celestialItem.BarycenterOfMotionId);
}

[Fact]
public void FindBarycenterOfMotionId_ReturnsCorrectValue_ForPlanet()
{
var celestialItem = TestHelpers.EarthAtJ2000;
Assert.Equal(3, celestialItem.BarycenterOfMotionId);
}

[Fact]
public void FindBarycenterOfMotionId_ReturnsCorrectValue_ForMoon()
{
var celestialItem = TestHelpers.MoonAtJ2000;
Assert.Equal(3, celestialItem.BarycenterOfMotionId);
}

[Fact]
public void FindBarycenterOfMotionId_ReturnsCorrectValue_ForLagrangePoint391()
{
var celestialItem = new LagrangePoint(LagrangePoints.L1);
Assert.Equal(3, celestialItem.BarycenterOfMotionId);
}

[Fact]
public void FindBarycenterOfMotionId_ReturnsZero_ForLagrangePoint394()
{
var celestialItem = new LagrangePoint(LagrangePoints.L4);
Assert.Equal(3, celestialItem.BarycenterOfMotionId);
}


[Fact]
public void FindCenterOfMotionId_ReturnsZero_ForBarycenter()
{
var celestialItem = new Barycenter(0);
Assert.Equal(0, celestialItem.CenterOfMotionId);
}

[Fact]
public void FindCenterOfMotionId_ReturnsTen_ForSun()
{
var celestialItem = TestHelpers.Sun;
Assert.Equal(10, celestialItem.CenterOfMotionId);
}

[Fact]
public void FindCenterOfMotionId_ReturnsTen_ForPlanet()
{
var celestialItem = TestHelpers.EarthAtJ2000;
Assert.Equal(10, celestialItem.CenterOfMotionId);
}

[Fact]
public void FindCenterOfMotionId_ReturnsTen_ForAsteroid()
{
var celestialItem = new CelestialBody(2000001);
Assert.Equal(10, celestialItem.CenterOfMotionId);
}

[Fact]
public void FindCenterOfMotionId_ReturnsCorrectValue_ForMoon()
{
var celestialItem = TestHelpers.MoonAtJ2000;
Assert.Equal(399, celestialItem.CenterOfMotionId);
}

[Fact]
public void FindCenterOfMotionId_ReturnsCorrectValue_ForLagrangePoint391()
{
var celestialItem = new LagrangePoint(LagrangePoints.L1);
Assert.Equal(10, celestialItem.CenterOfMotionId);
}

[Fact]
public void FindCenterOfMotionId_ReturnsTen_ForLagrangePoint394()
{
var celestialItem = new LagrangePoint(LagrangePoints.L4);
Assert.Equal(10, celestialItem.CenterOfMotionId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Threading.Tasks;
using IO.Astrodynamics.Body;
using IO.Astrodynamics.Coordinates;
using IO.Astrodynamics.SolarSystemObjects;
using IO.Astrodynamics.TimeSystem;
using Xunit;

Expand Down Expand Up @@ -78,7 +79,7 @@ public void GetRightAscensionSigma()
public async Task Propagate()
{
var epoch = new TimeSystem.Time(new DateTime(2001, 1, 1), TimeFrame.TDBFrame);
var observer = new Barycenter(0);
var observer = Barycenters.SOLAR_SYSTEM_BARYCENTER;
var star = new Star(1, "star1", 1E+30, "spec", 2, 0.3792, new Equatorial(1, 1, epoch), 0.1, 0.1, 0, 0, 0, 0, epoch);
await star.PropagateAsync(new Window(epoch, epoch + TimeSpan.FromDays(365 * 4)), TimeSpan.FromDays(365));
var eph0 = star.GetEphemeris(epoch, observer, Frames.Frame.ICRF, Aberration.None);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void CreateFromStateVector()
Astrodynamics.Mission.Mission mission = new Astrodynamics.Mission.Mission("mission1");
new Scenario("scn1", mission, new Window(new TimeSystem.Time(new DateTime(2001, 1, 1), TimeFrame.TDBFrame), new TimeSystem.Time(new DateTime(2001, 2, 1), TimeFrame.TDBFrame)));
var epoch = new TimeSystem.Time(DateTime.MinValue, TimeFrame.TDBFrame);
CelestialBody earth = new CelestialBody(PlanetsAndMoons.EARTH);
CelestialBody earth = PlanetsAndMoons.EARTH_BODY;
Equatorial eq = new Equatorial(new StateVector(
new Vector3(-291608.38463344, -266716.83339423, -76102.48709990), new Vector3(), earth, epoch,
Frames.Frame.ICRF));
Expand Down
2 changes: 1 addition & 1 deletion IO.Astrodynamics.Net/IO.Astrodynamics.Tests/Example.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public void ReadEphemeris()
{
//In this example we want the ephemeris of the moon at epoch (2000-01-01T12:00Z) in ICRF frame with earth at center
API.Instance.LoadKernels(new DirectoryInfo("Data/SolarSystem"));//replace Data/SolarSytem by your kernel path
var earth = new CelestialBody(PlanetsAndMoons.EARTH);
var earth = PlanetsAndMoons.EARTH_BODY;
var moon = new CelestialBody(PlanetsAndMoons.MOON);
var ephemerid = moon.GetEphemeris(new TimeSystem.Time(new DateTime(2000, 1, 1, 12, 0, 0), TimeFrame.UTCFrame), earth, Frames.Frame.ICRF, Aberration.None);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void FindLaunchWindows()
new StateVector(new Vector3(-1.144243683349977E+06, 4.905086030671815E+06, 4.553416875193589E+06),
new Vector3(-5.588288926819989E+03, -4.213222250603758E+03, 3.126518392859475E+03), earth, epoch, Frames.Frame.ICRF), IO.Astrodynamics.Constants.CivilTwilight,
null);
var res = launch.FindLaunchWindows(new Window(epoch, TimeSpan.FromDays(1.0)), Constants.OutputPath);
var res = launch.FindLaunchWindows(new Window(epoch, TimeSpan.FromDays(1.0)));
var launchWindows = res as LaunchWindow[] ?? res.ToArray();
Assert.Equal(2, launchWindows.Count());
var firstWindow = launchWindows.ElementAt(0);
Expand Down Expand Up @@ -78,7 +78,7 @@ public void FindLaunchWindowsByDay()
new StateVector(new Vector3(-1.144243683349977E+06, 4.905086030671815E+06, 4.553416875193589E+06),
new Vector3(-5.588288926819989E+03, -4.213222250603758E+03, 3.126518392859475E+03), earth, epoch, Frames.Frame.ICRF), IO.Astrodynamics.Constants.CivilTwilight,
true);
var res = launch.FindLaunchWindows(new Window(epoch, TimeSpan.FromDays(1.0)), Constants.OutputPath);
var res = launch.FindLaunchWindows(new Window(epoch, TimeSpan.FromDays(1.0)));
Assert.Single(res);
var firstWindow = res.ElementAt(0);
Assert.Equal(new TimeSystem.Time("2021-06-02T18:11:31.0119753Z"), firstWindow.Window.StartDate.ToUTC(), TestHelpers.TimeComparer);
Expand All @@ -104,7 +104,7 @@ public void FindSouthLaunchWindowsByDay()
new StateVector(new Vector3(-1.144243683349977E+06, 4.905086030671815E+06, 4.553416875193589E+06),
new Vector3(-5.588288926819989E+03, -4.213222250603758E+03, 3.126518392859475E+03), earth, epoch, Frames.Frame.ICRF), IO.Astrodynamics.Constants.CivilTwilight,
true);
var res = launch.FindLaunchWindows(new Window(epoch, TimeSpan.FromDays(1.0)), Constants.OutputPath);
var res = launch.FindLaunchWindows(new Window(epoch, TimeSpan.FromDays(1.0)));
Assert.Single(res);
var firstWindow = res.ElementAt(0);
Assert.Equal(new TimeSystem.Time("2021-06-02T15:08:24.4541548Z"), firstWindow.Window.StartDate.ToUTC(), TestHelpers.TimeComparer);
Expand All @@ -129,7 +129,7 @@ public void FindSouthLaunchWindows()
new StateVector(new Vector3(-1.144243683349977E+06, 4.905086030671815E+06, 4.553416875193589E+06),
new Vector3(-5.588288926819989E+03, -4.213222250603758E+03, 3.126518392859475E+03), earth, epoch, Frames.Frame.ICRF), IO.Astrodynamics.Constants.CivilTwilight,
null);
var res = launch.FindLaunchWindows(new Window(epoch, TimeSpan.FromDays(1.0)), Constants.OutputPath);
var res = launch.FindLaunchWindows(new Window(epoch, TimeSpan.FromDays(1.0)));
Assert.Equal(2, res.Count());
var firstWindow = res.ElementAt(0);
Assert.Equal(new TimeSystem.Time("2021-06-02T08:55:43.6080970z"), firstWindow.Window.StartDate.ToUTC(), TestHelpers.TimeComparer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void InterpolateCubic()
public void InterpolateStateVectorSquare()
{
//Interpolate square function
CelestialBody earth = new CelestialBody(PlanetsAndMoons.EARTH);
CelestialBody earth = PlanetsAndMoons.EARTH_BODY;
StateVector[] data = new StateVector[10];
var start = new TimeSystem.Time(2021, 01, 01, 0, 0, 0);
for (int i = 0; i < 10; i++)
Expand Down Expand Up @@ -86,7 +86,7 @@ public void InterpolateStateVectorSquare()
public void InterpolateStateVectorCubic()
{
//Interpolate square function
CelestialBody earth = new CelestialBody(PlanetsAndMoons.EARTH);
CelestialBody earth = PlanetsAndMoons.EARTH_BODY;
StateVector[] data = new StateVector[10];
var start = new TimeSystem.Time(2021, 01, 01, 0, 0, 0);
for (int i = 0; i < 10; i++)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void AddSite()
Scenario scenario = new Scenario("Scenario", mission, new Window(new TimeSystem.Time(2021, 1, 1), new TimeSystem.Time(2021, 1, 2)));
Assert.Equal("Scenario", scenario.Name);
Assert.Equal(mission, scenario.Mission);
var site = new Site(13, "DSS-13", new CelestialBody(PlanetsAndMoons.EARTH));
var site = new Site(13, "DSS-13", PlanetsAndMoons.EARTH_BODY);
scenario.AddSite(site);
Assert.Single(scenario.Sites);
Assert.Equal(site, scenario.Sites.First());
Expand Down Expand Up @@ -496,7 +496,7 @@ public async Task PropagateStar()
{
var start = new TimeSystem.Time(2001, 1, 1);
var end = start.AddDays(365 * 4);
var observer = new Barycenter(0);
var observer = Barycenters.SOLAR_SYSTEM_BARYCENTER;
var star = new Star(2, "star2", 1E+30, "spec", 2, 0.3792, new Equatorial(1, 1, start), 0.1, 0.1, 0, 0, 0, 0, start);

Astrodynamics.Mission.Mission mission = new Astrodynamics.Mission.Mission("mission102");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public EquinoctialElementsTests()
[Fact]
public void Create()
{
CelestialBody earth = new CelestialBody(PlanetsAndMoons.EARTH);
CelestialBody earth = PlanetsAndMoons.EARTH_BODY;
var epoch = new TimeSystem.Time(DateTime.UtcNow, TimeFrame.UTCFrame);
EquinoctialElements equ = new EquinoctialElements(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, earth, epoch, Frames.Frame.ICRF);
Assert.Equal(1.0, equ.P);
Expand All @@ -34,7 +34,7 @@ public void Create()
[Fact]
public void ToEquinoctial()
{
CelestialBody earth = new CelestialBody(PlanetsAndMoons.EARTH);
CelestialBody earth = PlanetsAndMoons.EARTH_BODY;
KeplerianElements ke = new KeplerianElements(6800.81178582, 0.00134, 51.71 * IO.Astrodynamics.Constants.Deg2Rad, 32.57 * IO.Astrodynamics.Constants.Deg2Rad,
105.64 * IO.Astrodynamics.Constants.Deg2Rad, 46.029 * IO.Astrodynamics.Constants.Deg2Rad, earth, new TimeSystem.Time(DateTime.UtcNow, TimeFrame.UTCFrame),
Frames.Frame.ICRF);
Expand All @@ -50,7 +50,7 @@ public void ToEquinoctial()
[Fact]
public void Equality()
{
CelestialBody earth = new CelestialBody(PlanetsAndMoons.EARTH);
CelestialBody earth = PlanetsAndMoons.EARTH_BODY;
KeplerianElements ke = new KeplerianElements(6800.81178582, 0.00134, 51.71 * IO.Astrodynamics.Constants.Deg2Rad, 32.57 * IO.Astrodynamics.Constants.Deg2Rad,
105.64 * IO.Astrodynamics.Constants.Deg2Rad, 46.029 * IO.Astrodynamics.Constants.Deg2Rad, earth, new TimeSystem.Time(DateTime.UtcNow, TimeFrame.UTCFrame),
Frames.Frame.ICRF);
Expand Down
Loading

0 comments on commit b73bca1

Please sign in to comment.