Skip to content

Commit

Permalink
v1.1.2
Browse files Browse the repository at this point in the history
v1.1.2

add some feature from VSOP87 add perf test add net6.0 runtime
Update README.md
  • Loading branch information
kingsznhone committed Jul 5, 2023
1 parent d7bf308 commit 410bcaa
Show file tree
Hide file tree
Showing 33 changed files with 1,625 additions and 648 deletions.
6 changes: 3 additions & 3 deletions DataConverter/DataConverter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PlatformTarget>x64</PlatformTarget>
Expand All @@ -26,11 +26,11 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="MessagePack" Version="2.5.108" />
<PackageReference Include="MessagePack" Version="2.5.124" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\VSOP2013\VSOP2013.csproj" />
<ProjectReference Include="..\VSOP2013\VSOP2013.NET.csproj" />
</ItemGroup>


Expand Down
18 changes: 9 additions & 9 deletions DataConverter/DataReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,14 @@ public static class DataReader

public static List<PlanetTable> ReadData()
{
List<PlanetTable> VSOP2013DATA = new List<PlanetTable>();
List<PlanetTable> VSOP2013DATA = new();
for (int ip = 0; ip < 9; ip++)
{
PlanetTable planet = new PlanetTable();
planet.body = (VSOPBody)ip;
planet.variables = new VariableTable[6];
PlanetTable planet = new()
{
body = (VSOPBody)ip,
variables = new VariableTable[6]
};

for (int iv = 0; iv < 6; iv++)
{
Expand Down Expand Up @@ -115,7 +117,6 @@ private static void ReadPlanet(PlanetTable Planet, int ip)
ReadTerm(line, ref buffer[i]);
}

Planet.variables[H.iv].PowerTables[H.it].header = H;
Planet.variables[H.iv].PowerTables[H.it].iv = H.iv;
Planet.variables[H.iv].PowerTables[H.it].it = H.it;
Planet.variables[H.iv].PowerTables[H.it].Body = (VSOPBody)H.ip;
Expand All @@ -127,7 +128,7 @@ private static void ReadPlanet(PlanetTable Planet, int ip)

private static Header ReadHeader(string line)
{
Header H = new Header();
Header H = new();
int lineptr = 9;
H.ip = Convert.ToInt32(line.Substring(lineptr, 3).Trim()) - 1;
lineptr += 3;
Expand All @@ -148,7 +149,7 @@ private static Term ReadTerm(string line, ref Term T)

//
lineptr = 5;
T.rank = Convert.ToInt32(line.Substring(0, lineptr));
T.rank = Convert.ToInt32(line[..lineptr]);
//
lineptr++;
//
Expand Down Expand Up @@ -204,7 +205,7 @@ private static Term ReadTerm(string line, ref Term T)
ci = Convert.ToDouble(line.Substring(lineptr, 20).Trim());
lineptr += 20;
lineptr++;
ci = ci * Math.Pow(10, Convert.ToDouble(line.Substring(lineptr, 3).Trim()));
ci *= Math.Pow(10, Convert.ToDouble(line.Substring(lineptr, 3).Trim()));

T.cc = ci;

Expand All @@ -216,7 +217,6 @@ private static Term ReadTerm(string line, ref Term T)
T.aa += Bufferiphi[j] * ci0[j];
T.bb += Bufferiphi[j] * ci1[j];
}

return T;
}

Expand Down
38 changes: 16 additions & 22 deletions DataConverter/Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using MessagePack;
using System.Diagnostics;
using System.Runtime.Serialization.Formatters.Binary;
using System.Diagnostics;
using System.IO.Compression;
using MessagePack;

namespace VSOP2013.DataConverter
{
Expand All @@ -12,18 +12,17 @@ private static void Main(string[] args)

#region Read Original Data

Stopwatch sw = new Stopwatch();
Stopwatch sw = new();
sw.Start();

List<PlanetTable> VSOP2013DATA = DataReader.ReadData();
VSOP2013DATA = VSOP2013DATA.OrderBy(x => x.body).ToList();

sw.Stop();
double ticks = sw.ElapsedTicks;
double Freq = Stopwatch.Frequency;
double milliseconds = (ticks / Freq) * 1000;
Console.WriteLine($"Data Read OK...Elapsed milliseconds: {milliseconds} ms");
Console.WriteLine("Press Enter to dump data...");
Console.ReadLine();
Console.WriteLine($"Data Read & Convert OK...Elapsed milliseconds: {milliseconds} ms");

#endregion Read Original Data

Expand All @@ -34,7 +33,7 @@ private static void Main(string[] args)
{
Directory.CreateDirectory(OutputDirPath);
}
DirectoryInfo OutputDir = new DirectoryInfo(Directory.GetCurrentDirectory() + @"\Data");
DirectoryInfo OutputDir = new(Directory.GetCurrentDirectory() + @"\Data");

sw.Restart();

Expand All @@ -45,40 +44,35 @@ private static void Main(string[] args)
{
File.Delete(filename);
}
using (FileStream fs = new FileStream(filename, FileMode.OpenOrCreate))
{
BinaryFormatter bf = new BinaryFormatter();
MessagePackSerializer.Serialize(fs, VSOP2013DATA[ip], lz4Options);
}
using FileStream fs = new(filename, FileMode.OpenOrCreate);
using BrotliStream bs = new(fs, CompressionLevel.SmallestSize);
MessagePackSerializer.Serialize(bs, VSOP2013DATA[ip]);
});

sw.Stop();
ticks = sw.ElapsedTicks;
milliseconds = (ticks / Freq) * 1000;
Console.WriteLine($"Data Dumped OK. Elapsed: {milliseconds}ms");
Console.WriteLine("Press Enter to test dumped data...");
Console.ReadLine();

#endregion Dump Data

#region Test

sw.Restart();

VSOP2013DATA.Clear();
result = Parallel.For(0, 9, ip =>
{
string filename = Path.Combine(OutputDir.FullName, string.Format("VSOP2013_{0}.BIN", ((VSOPBody)ip).ToString()));
using (FileStream fs = new FileStream(filename, FileMode.OpenOrCreate))
{

VSOP2013DATA.Add(MessagePackSerializer.Deserialize<PlanetTable>(fs, lz4Options));
}
using FileStream fs = new(filename, FileMode.OpenOrCreate);
using BrotliStream bs = new(fs, CompressionMode.Decompress);
VSOP2013DATA.Add(MessagePackSerializer.Deserialize<PlanetTable>(bs));
});

sw.Stop();
ticks = sw.ElapsedTicks;
milliseconds = (ticks / Freq) * 1000;
Console.WriteLine($"Data Reload Test OK. Elapsed: {milliseconds}ms");
Console.WriteLine($"Dump Data Reload Test OK. Elapsed: {milliseconds}ms");
Console.WriteLine("Press Enter to exit...");
Console.ReadLine();

#endregion Test
Expand Down
21 changes: 10 additions & 11 deletions DataConverter/Resources/VSOP2013.ctl
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

PLANETARY EPHEMERIS VSOP2013 MERCURY
PLANETARY EPHEMERIS VSOP2013 MERCURY

1/ Elliptic Elements: a(au), lambda (radian), k, h, q, p - Dynamical Frame J2000
2/ Ecliptic Heliocentric Coordinates: X, Y, Z(au) X',Y',Z' (au/d) - Dynamical Frame J2000
Expand Down Expand Up @@ -50,7 +49,7 @@ Julian Date JD 2411545.0 (TDB)
-0.1300935038 -0.4472876448 -0.0245983783 0.0213663969 -0.0064479843 -0.0024878666
-0.1300936046 -0.4005937206 -0.2004893069 0.0213663956 -0.0049262997 -0.0048474330

PLANETARY EPHEMERIS VSOP2013 VENUS
PLANETARY EPHEMERIS VSOP2013 VENUS

1/ Elliptic Elements: a(au), lambda (radian), k, h, q, p - Dynamical Frame J2000
2/ Ecliptic Heliocentric Coordinates: X, Y, Z(au) X',Y',Z' (au/d) - Dynamical Frame J2000
Expand Down Expand Up @@ -101,7 +100,7 @@ Julian Date JD 2411545.0 (TDB)
-0.7183022848 -0.0326544811 0.0410142477 0.0007981222 -0.0202952185 -0.0003234552
-0.7183022964 -0.0462742464 0.0246406381 0.0007981175 -0.0184918375 -0.0083697353

PLANETARY EPHEMERIS VSOP2013 EMB
PLANETARY EPHEMERIS VSOP2013 EMB

1/ Elliptic Elements: a(au), lambda (radian), k, h, q, p - Dynamical Frame J2000
2/ Ecliptic Heliocentric Coordinates: X, Y, Z(au) X',Y',Z' (au/d) - Dynamical Frame J2000
Expand Down Expand Up @@ -152,7 +151,7 @@ Julian Date JD 2411545.0 (TDB)
-0.1771590071 0.9672193117 -0.0000009492 -0.0172031083 -0.0031639158 0.0000000254
-0.1771587839 0.8874068590 0.3847367185 -0.0172031091 -0.0029028420 -0.0012585096

PLANETARY EPHEMERIS VSOP2013 MARS
PLANETARY EPHEMERIS VSOP2013 MARS

1/ Elliptic Elements: a(au), lambda (radian), k, h, q, p - Dynamical Frame J2000
2/ Ecliptic Heliocentric Coordinates: X, Y, Z(au) X',Y',Z' (au/d) - Dynamical Frame J2000
Expand Down Expand Up @@ -203,7 +202,7 @@ Julian Date JD 2411545.0 (TDB)
1.3907159210 -0.0134159938 -0.0344678037 0.0006714961 0.0151872482 0.0003016544
1.3907159214 0.0014012149 -0.0369601677 0.0006714996 0.0138140375 0.0063179004

PLANETARY EPHEMERIS VSOP2013 JUPITER
PLANETARY EPHEMERIS VSOP2013 JUPITER

1/ Elliptic Elements: a(au), lambda (radian), k, h, q, p - Dynamical Frame J2000
2/ Ecliptic Heliocentric Coordinates: X, Y, Z(au) X',Y',Z' (au/d) - Dynamical Frame J2000
Expand Down Expand Up @@ -254,7 +253,7 @@ Julian Date JD 2411545.0 (TDB)
4.0011764936 2.9385770224 -0.1017848771 -0.0045683150 0.0064432050 0.0000755810
4.0011771819 2.7365785897 1.0755125254 -0.0045683135 0.0058814622 0.0026323029

PLANETARY EPHEMERIS VSOP2013 SATURN
PLANETARY EPHEMERIS VSOP2013 SATURN

1/ Elliptic Elements: a(au), lambda (radian), k, h, q, p - Dynamical Frame J2000
2/ Ecliptic Heliocentric Coordinates: X, Y, Z(au) X',Y',Z' (au/d) - Dynamical Frame J2000
Expand Down Expand Up @@ -305,7 +304,7 @@ Julian Date JD 2411545.0 (TDB)
6.4064073173 6.5699911538 -0.3690759502 -0.0042923528 0.0038903147 0.0001029490
6.4064088704 6.1746578061 2.2747707349 -0.0042923519 0.0035283446 0.0016419315

PLANETARY EPHEMERIS VSOP2013 URANUS
PLANETARY EPHEMERIS VSOP2013 URANUS

1/ Elliptic Elements: a(au), lambda (radian), k, h, q, p - Dynamical Frame J2000
2/ Ecliptic Heliocentric Coordinates: X, Y, Z(au) X',Y',Z' (au/d) - Dynamical Frame J2000
Expand Down Expand Up @@ -356,7 +355,7 @@ Julian Date JD 2411545.0 (TDB)
14.4318597263 -13.7343125162 -0.2381402777 0.0026781039 0.0026726980 -0.0000247713
14.4318565807 -12.5062632452 -5.6816829828 0.0026781045 0.0024620054 0.0010404106

PLANETARY EPHEMERIS VSOP2013 NEPTUNE
PLANETARY EPHEMERIS VSOP2013 NEPTUNE

1/ Elliptic Elements: a(au), lambda (radian), k, h, q, p - Dynamical Frame J2000
2/ Ecliptic Heliocentric Coordinates: X, Y, Z(au) X',Y',Z' (au/d) - Dynamical Frame J2000
Expand Down Expand Up @@ -407,7 +406,7 @@ Julian Date JD 2411545.0 (TDB)
16.8120537367 -24.9917592776 0.1272247241 0.0025792738 0.0017769013 -0.0000959080
16.8120479567 -22.9801038994 -9.8244204429 0.0025792742 0.0016684245 0.0006188166

PLANETARY EPHEMERIS VSOP2013 PLUTO
PLANETARY EPHEMERIS VSOP2013 PLUTO

1/ Elliptic Elements: a(au), lambda (radian), k, h, q, p - Dynamical Frame J2000
2/ Ecliptic Heliocentric Coordinates: X, Y, Z(au) X',Y',Z' (au/d) - Dynamical Frame J2000
Expand Down Expand Up @@ -456,4 +455,4 @@ Julian Date JD 2411545.0 (TDB)
Julian Date JD 2451545.0 (TDB)
39.2648542648 4.1726045776 -0.1758641167 -0.1701234143 -0.0517015914 0.1398654514
-9.8753625435 -27.9588613710 5.8504463318 0.0030287536 -0.0015378008 -0.0007122001
-9.8753695808 -27.9789262247 -5.7537118247 0.0030287533 -0.0011276087 -0.0012651327
-9.8753695808 -27.9789262247 -5.7537118247 0.0030287533 -0.0011276087 -0.0012651327
8 changes: 6 additions & 2 deletions Demo/Demo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<Platforms>x64</Platforms>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\VSOP2013\VSOP2013.csproj" />
<PackageReference Include="BenchmarkDotNet" Version="0.13.5" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\VSOP2013\VSOP2013.NET.csproj" />
</ItemGroup>

</Project>
39 changes: 39 additions & 0 deletions Demo/PerfTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;
using VSOP2013;

namespace Demo
{
[SimpleJob(RuntimeMoniker.Net70)]
[MemoryDiagnoser]
public class PerfTest
{
private Calculator vsop;

private DateTime dt;
VSOPTime vTime;
public PerfTest() { vsop = new Calculator(); }

[GlobalSetup]
public void init()
{
dt = DateTime.Now.ToUniversalTime();
dt.ToUniversalTime();
dt = dt.AddSeconds(-69.184);
vTime =new VSOPTime(dt);
}

[Benchmark]
public VSOPResult Go()
{
var ell = vsop.GetPlanetPosition(VSOPBody.JUPITER, vTime);
return ell;
}

}
}
Loading

0 comments on commit 410bcaa

Please sign in to comment.