-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b410311
commit fe95030
Showing
23 changed files
with
2,247 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<Platforms>AnyCPU;x64</Platforms> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\VSOP2013\VSOP2013.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
using System; | ||
using System.Diagnostics; | ||
using System.Globalization; | ||
using System.IO; | ||
using System.Threading.Tasks; | ||
using VSOP2013; | ||
namespace Demo | ||
{ | ||
class Program | ||
{ | ||
static Calculator vsop; | ||
static VSOPTime vTime; | ||
static void Main(string[] args) | ||
{ | ||
DateTime Tinput; | ||
|
||
vsop = new Calculator(); | ||
|
||
Tinput = DateTime.Now.ToUniversalTime(); | ||
|
||
//Console.WriteLine("Parse UTC string that conforms to ISO 8601: 2018-08-18T07:22:16.0000000Z"); | ||
|
||
//Parse Time | ||
//while (true) | ||
//{ | ||
// Console.Write("Input Time As UTC:"); | ||
// //string inputT = Console.ReadLine(); | ||
// string inputT = "2000-01-01T12:00:00.0000000Z"; | ||
// CultureInfo culture = CultureInfo.CreateSpecificCulture("en-US"); | ||
// DateTimeStyles style = DateTimeStyles.AdjustToUniversal; | ||
// if (DateTime.TryParse(inputT, culture, style, out Tinput)) break; | ||
// else Console.WriteLine("Invalid Entry..."); | ||
//} | ||
//Tinput = VSOPTime.TDBtoTT(Tinput); | ||
//Tinput = VSOPTime.TTtoTAI(Tinput); | ||
//Tinput = VSOPTime.TAItoUTC(Tinput); | ||
|
||
Console.WriteLine(Tinput.ToString()); | ||
|
||
//Convert UTC to TDB (Barycentric Dynamical Time) | ||
vTime = new VSOPTime(Tinput); | ||
|
||
Console.WriteLine(); | ||
|
||
Console.WriteLine("Press Enter To Start Substitution..."); | ||
Console.ReadLine(); | ||
|
||
VSOPResult[] ResultAll = vsop.CalcAllPlanet(vTime); | ||
|
||
foreach(VSOPResult result in ResultAll) | ||
{ | ||
FormattedPrint(result, vTime); | ||
} | ||
|
||
Console.WriteLine("Press Enter to Start PerformanceTest."); | ||
Console.ReadLine(); | ||
|
||
|
||
PerformanceTestSync(1000); | ||
Console.ReadLine(); | ||
} | ||
|
||
public static void FormattedPrint(VSOPResult Result, VSOPTime vtime) | ||
{ | ||
Console.WriteLine("==============================================================="); | ||
Console.WriteLine("PLANETARY EPHEMERIS VSOP2013"); | ||
Console.WriteLine("==============================================================="); | ||
|
||
Console.WriteLine(Enum.GetName(typeof(VSOPBody), Result.Body) + " at UTC:" + vtime.UTC.ToString()); | ||
Console.WriteLine(); | ||
Console.WriteLine(" Elliptic Elements - Dynamical Frame J2000"); | ||
Console.WriteLine(String.Format("{0,-30} : {1,-30}", "semi-major axis (au)", Result.DynamicalELL[0])); | ||
Console.WriteLine(String.Format("{0,-30} : {1,-30}", "mean longitude (rd)", Result.DynamicalELL[1])); | ||
Console.WriteLine(String.Format("{0,-30} : {1,-30}", "k = e*cos(pi) (rd)", Result.DynamicalELL[2])); | ||
Console.WriteLine(String.Format("{0,-30} : {1,-30}", "h = e*sin(pi) (rd)", Result.DynamicalELL[3])); | ||
Console.WriteLine(String.Format("{0,-30} : {1,-30}", "q = sin(i/2)*cos(omega) (rd)", Result.DynamicalELL[4])); | ||
Console.WriteLine(String.Format("{0,-30} : {1,-30}", "p = sin(i/2)*sin(omega) (rd)", Result.DynamicalELL[5])); | ||
Console.WriteLine(); | ||
Console.WriteLine(" Ecliptic Heliocentric Coordinates - Dynamical Frame J2000"); | ||
Console.WriteLine(String.Format("{0,-30} : {1,-30}", "Positions X (au)", Result.DynamicalXYZ[0])); | ||
Console.WriteLine(String.Format("{0,-30} : {1,-30}", "Positions Y (au)", Result.DynamicalXYZ[1])); | ||
Console.WriteLine(String.Format("{0,-30} : {1,-30}", "Positions Z (au)", Result.DynamicalXYZ[2])); | ||
Console.WriteLine(String.Format("{0,-30} : {1,-30}", "Velocities X'(au/d)", Result.DynamicalXYZ[3])); | ||
Console.WriteLine(String.Format("{0,-30} : {1,-30}", "Velocities Y'(au/d)", Result.DynamicalXYZ[4])); | ||
Console.WriteLine(String.Format("{0,-30} : {1,-30}", "Velocities Z'(au/d)", Result.DynamicalXYZ[5])); | ||
Console.WriteLine(); | ||
Console.WriteLine(" Equatorial Heliocentric Coordinates - ICRS Frame J2000"); | ||
Console.WriteLine(String.Format("{0,-30} : {1,-30}", "Positions X (au)", Result.ICRSXYZ[0])); | ||
Console.WriteLine(String.Format("{0,-30} : {1,-30}", "Positions Y (au)", Result.ICRSXYZ[1])); | ||
Console.WriteLine(String.Format("{0,-30} : {1,-30}", "Positions Z (au)", Result.ICRSXYZ[2])); | ||
Console.WriteLine(String.Format("{0,-30} : {1,-30}", "Velocities X'(au/d)", Result.ICRSXYZ[3])); | ||
Console.WriteLine(String.Format("{0,-30} : {1,-30}", "Velocities Y'(au/d)", Result.ICRSXYZ[4])); | ||
Console.WriteLine(String.Format("{0,-30} : {1,-30}", "Velocities Z'(au/d)", Result.ICRSXYZ[5])); | ||
Console.WriteLine(); | ||
} | ||
|
||
|
||
public static void PerformanceTest(int cycle) | ||
{ | ||
Console.WriteLine(); | ||
Console.WriteLine("=====================Start Performance Test====================="); | ||
Stopwatch sw = new Stopwatch(); | ||
sw.Start(); | ||
int completedCycle = 0; | ||
var result = Parallel.For(0, cycle, (i) => | ||
{ | ||
{ | ||
VSOPResult[] ResultAll = vsop.CalcAllPlanet(vTime); | ||
completedCycle++; | ||
if (completedCycle % 1000 == 0) | ||
{ | ||
Console.WriteLine($"Cycle: {completedCycle,-10} {sw.Elapsed.TotalMilliseconds,10} ms"); | ||
} | ||
} | ||
}); | ||
|
||
sw.Stop(); | ||
Console.WriteLine($"Cycle: {cycle,-10} {sw.Elapsed.TotalMilliseconds,10} ms"); | ||
} | ||
|
||
|
||
public static void PerformanceTestSync(int cycle) | ||
{ | ||
Console.WriteLine(); | ||
Console.WriteLine("=====================Start Performance Test====================="); | ||
Stopwatch sw = new Stopwatch(); | ||
sw.Start(); | ||
int completedCycle = 0; | ||
|
||
|
||
for(int i = 0; i < cycle; i++) | ||
{ | ||
double Result = vsop.CalcIV(VSOPBody.EMB,1,vTime); | ||
completedCycle++; | ||
if (completedCycle % 1000 == 0) | ||
{ | ||
Console.WriteLine($"Cycle: {completedCycle,-10} {sw.Elapsed.TotalMilliseconds,10} ms"); | ||
} | ||
} | ||
|
||
sw.Stop(); | ||
Console.WriteLine($"Cycle: {cycle,-10} {sw.Elapsed.TotalMilliseconds,10} ms"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,190 @@ | ||
# VSOP2013 .NET Remastered | ||
|
||
## What's This? | ||
|
||
VSOP was developed and is maintained (updated with the latest data) by the scientists at the Bureau des Longitudes in Paris. | ||
|
||
VSOP2013,another version of VSOP, computed the positions of the planets directly at any moment, as well as their orbital elements with improved accuracy. | ||
|
||
Original VSOP2013 Solution was write by FORTRAN 77 . It's too old to use. | ||
|
||
This repo is not just programming language translation, it's refactoring of VSOP2013. | ||
|
||
This thing is totally useless for myself. But I think someone might need this algorithm in the future. | ||
|
||
VSOP2013 is much much slower than VSOP87. But I guess it's more accurate than 87? | ||
|
||
## Introduction | ||
|
||
The VSOP2013 files contain the series of the elliptic elements for the 8 planets Mercury, Venus, Earth-Moon barycenter, Mars, Jupiter, Saturn, Uranus, and Neptune and for the dwarf planet Pluto of the solution VSOP2013. The planetary solution VSOP2013 is fitted to the numerical integration INPOP10a built at IMCCE, Paris Observatory over the time interval +1890...+2000. | ||
|
||
The precision is of a few 0.1″ for the telluric planets (1.6″ for Mars) over the time interval −4000...+8000. | ||
|
||
G. FRANCOU & J.-L. SIMON (MAY 2013) | ||
|
||
Ref: Simon J.-L., Francou G., Fienga A., Manche H., A&A 557, A49 (2013) | ||
|
||
List of the data files: | ||
|
||
VSOP2013p1.dat : Mercury | ||
|
||
VSOP2013p2.dat : Venus | ||
|
||
VSOP2013p3.dat : Earth-Moon Barycenter | ||
|
||
VSOP2013p4.dat : Mars | ||
|
||
VSOP2013p5.dat : Jupiter | ||
|
||
VSOP2013p6.dat : Saturn | ||
|
||
VSOP2013p7.dat : Uranus | ||
|
||
VSOP2013p8.dat : Neptune | ||
|
||
VSOP2013p9.dat : Pluto | ||
|
||
The planetary solution VSOP2013 is fitted to the numerical integration INPOP10a built at IMCCE, Paris Observatory (https://ftp.imcce.fr/pub/ephem/planets/vsop2013/). | ||
|
||
|
||
## FILES DESCRIPTION | ||
|
||
Each VSOP2013 file corresponds to a planet and contains trigonometric series, functions of time (Periodic series and Poisson series), that represent the 6 elliptic elements of the planet: | ||
|
||
Variable 1 : a = semi-major axis (ua) | ||
|
||
Variable 2 : λ = mean longitude (radian) | ||
|
||
Variable 3 : k = e cos ω | ||
|
||
Variable 4 : h = e sin ω | ||
|
||
Variable 5 : q = sin(i/2) cos Ω | ||
|
||
Variable 6 : p = sin(i/2) sin Ω | ||
|
||
### with: | ||
|
||
e : eccentricity | ||
|
||
ω : perihelion longitude | ||
|
||
i : inclination | ||
|
||
Ω : ascending node longitude | ||
|
||
### VSOP2013 series are characterized by 3 parameters: | ||
|
||
- the planet index 1-9 from Mercury to Pluto, | ||
|
||
- the variable index 1-6 for a, λ, k, h, q, p, | ||
|
||
- the time power α. | ||
|
||
## Feature | ||
|
||
1. Use VSOPResult class to manage calculate results. | ||
2. Use VSOPTime class to manage time. Easy to convert time by calling VSOPTime.UTC VSOPTime.TAI VSOPTime.TDB | ||
3. Extremely optimized. About 6ms per full result on 5900HX. | ||
|
||
![Performance Test](https://github.com/kingsznhone/VSOP2013/blob/master/Performance.png) | ||
|
||
|
||
I found calculation of iphi it's not related with time. So calculations of aa&bb were done during data reading. | ||
|
||
I'm not sure should I Dump the preprocessed data to BIN file or not. | ||
|
||
### Pros | ||
- Smaller Data size | ||
|
||
### Cons | ||
- Slower on load | ||
- more memory use. | ||
|
||
If program using original data file. Loading time is much less than using binary data file. About 1->4s. It's hard to choose which is better. | ||
|
||
Finally I decide to use original data file. | ||
|
||
## API | ||
|
||
### public double CalcIV(VSOPBody body,int iv, VSOPTime time) | ||
|
||
Calculate a specific variable of a planet. | ||
|
||
#### Parameters | ||
|
||
```body``` VSOPBody | ||
|
||
Planet enum. | ||
|
||
```iv``` Variable index | ||
|
||
0-5 : a l k h q p | ||
|
||
```time``` VSOPTime | ||
|
||
Exclusive time class in VSOP2013. | ||
|
||
#### Return | ||
|
||
```double``` variable result. | ||
|
||
### public VSOPResult CalcPlanet(VSOPBody body, VSOPTime time) | ||
|
||
Calculate all variable of a planet. | ||
|
||
#### Parameters | ||
|
||
```body``` VSOPBody | ||
|
||
Planet enum. | ||
|
||
```time``` VSOPTime | ||
|
||
Exclusive time class in VSOP2013. | ||
|
||
#### Return | ||
|
||
```VSOPResult``` Full Result with 6 variable in 3 type of Coordinates. | ||
|
||
- Elliptic Elements Dynamical Frame J2000 | ||
|
||
- Ecliptic Heliocentric Coordinates Dynamical Frame J2000 | ||
|
||
- Equatorial Heliocentric Coordinates ICRS Frame J2000 | ||
|
||
### public VSOPResult[] CalcAllPlanet(VSOPTime time) | ||
|
||
Calculate all variable of a planet. | ||
|
||
#### Parameters | ||
|
||
```time``` VSOPTime | ||
|
||
Exclusive time class in VSOP2013. | ||
|
||
#### Return | ||
|
||
```VSOPResult[]``` Full result with 6 variable in 3 type of Coordinates of all 9 planet. | ||
|
||
## Change Log | ||
|
||
## 2022.06.02 | ||
|
||
New features. | ||
|
||
Performance Optimization. | ||
|
||
Upgrade to .NET 6 | ||
|
||
## 2020.11.14 | ||
|
||
Upgrade to .NET 5 | ||
|
||
## 2020.07.06 | ||
|
||
Initial PR. | ||
|
||
## Enviroment Require | ||
|
||
.NET6 Runtime |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.2.32526.322 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VSOP2013", "VSOP2013\VSOP2013.csproj", "{A36BC2BE-D01A-497C-B17A-3B15DA455D9F}" | ||
EndProject | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Demo", "Demo\Demo.csproj", "{9CC39AF5-6179-4903-8F3C-ED8ACEFE2399}" | ||
EndProject | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{036438D2-DD9F-4EC0-BB13-237C0C13501F}" | ||
ProjectSection(SolutionItems) = preProject | ||
.editorconfig = .editorconfig | ||
EndProjectSection | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Debug|x64 = Debug|x64 | ||
Release|Any CPU = Release|Any CPU | ||
Release|x64 = Release|x64 | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{A36BC2BE-D01A-497C-B17A-3B15DA455D9F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{A36BC2BE-D01A-497C-B17A-3B15DA455D9F}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{A36BC2BE-D01A-497C-B17A-3B15DA455D9F}.Debug|x64.ActiveCfg = Debug|x64 | ||
{A36BC2BE-D01A-497C-B17A-3B15DA455D9F}.Debug|x64.Build.0 = Debug|x64 | ||
{A36BC2BE-D01A-497C-B17A-3B15DA455D9F}.Release|Any CPU.ActiveCfg = Release|x64 | ||
{A36BC2BE-D01A-497C-B17A-3B15DA455D9F}.Release|Any CPU.Build.0 = Release|x64 | ||
{A36BC2BE-D01A-497C-B17A-3B15DA455D9F}.Release|x64.ActiveCfg = Release|x64 | ||
{A36BC2BE-D01A-497C-B17A-3B15DA455D9F}.Release|x64.Build.0 = Release|x64 | ||
{9CC39AF5-6179-4903-8F3C-ED8ACEFE2399}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{9CC39AF5-6179-4903-8F3C-ED8ACEFE2399}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{9CC39AF5-6179-4903-8F3C-ED8ACEFE2399}.Debug|x64.ActiveCfg = Debug|x64 | ||
{9CC39AF5-6179-4903-8F3C-ED8ACEFE2399}.Debug|x64.Build.0 = Debug|x64 | ||
{9CC39AF5-6179-4903-8F3C-ED8ACEFE2399}.Release|Any CPU.ActiveCfg = Release|x64 | ||
{9CC39AF5-6179-4903-8F3C-ED8ACEFE2399}.Release|Any CPU.Build.0 = Release|x64 | ||
{9CC39AF5-6179-4903-8F3C-ED8ACEFE2399}.Release|x64.ActiveCfg = Release|x64 | ||
{9CC39AF5-6179-4903-8F3C-ED8ACEFE2399}.Release|x64.Build.0 = Release|x64 | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {82ED7620-3D5A-42AA-A0A3-B2D546E5DCE6} | ||
EndGlobalSection | ||
EndGlobal |
Oops, something went wrong.