Skip to content

Commit

Permalink
v1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
kingsznhone committed Mar 26, 2023
1 parent 44e6e38 commit d7bf308
Show file tree
Hide file tree
Showing 38 changed files with 623 additions and 382 deletions.
37 changes: 37 additions & 0 deletions DataConverter/DataConverter.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PlatformTarget>x64</PlatformTarget>
<Platforms>x64</Platforms>
</PropertyGroup>

<ItemGroup>
<EmbeddedResource Include="Resources\README.pdf" />
<EmbeddedResource Include="Resources\VSOP2013.ctl" />
<EmbeddedResource Include="Resources\VSOP2013.f" />
<EmbeddedResource Include="Resources\VSOP2013-secular.dat" />
<EmbeddedResource Include="Resources\VSOP2013p1.dat" />
<EmbeddedResource Include="Resources\VSOP2013p2.dat" />
<EmbeddedResource Include="Resources\VSOP2013p3.dat" />
<EmbeddedResource Include="Resources\VSOP2013p4.dat" />
<EmbeddedResource Include="Resources\VSOP2013p5.dat" />
<EmbeddedResource Include="Resources\VSOP2013p6.dat" />
<EmbeddedResource Include="Resources\VSOP2013p7.dat" />
<EmbeddedResource Include="Resources\VSOP2013p8.dat" />
<EmbeddedResource Include="Resources\VSOP2013p9.dat" />
</ItemGroup>

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

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


</Project>
23 changes: 6 additions & 17 deletions VSOP2013/DataReader.cs → DataConverter/DataReader.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
using System.Diagnostics;
using System.Reflection;
using System.Reflection;

namespace VSOP2013
namespace VSOP2013.DataConverter
{
public static class DataReader
{

/// <summary>
/// Mean Longitude J2000 (radian)
/// </summary>
static readonly double[] ci0 =
private static readonly double[] ci0 =
{
0.4402608631669000e1d,
0.3176134461576000e1d,
Expand All @@ -33,7 +31,7 @@ public static class DataReader
/// <summary>
/// //Mean Motions in longitude (radian/cy)
/// </summary>
static readonly double[] ci1 =
private static readonly double[] ci1 =
{
0.2608790314068555e5d,
0.1021328554743445e5d,
Expand All @@ -56,8 +54,6 @@ public static class DataReader

public static List<PlanetTable> ReadData()
{
Stopwatch sw = new Stopwatch();
sw.Start();
List<PlanetTable> VSOP2013DATA = new List<PlanetTable>();
for (int ip = 0; ip < 9; ip++)
{
Expand Down Expand Up @@ -85,13 +81,8 @@ public static List<PlanetTable> ReadData()
}
}

sw.Stop();
GC.Collect();
GC.WaitForPendingFinalizers();
double ticks = sw.ElapsedTicks;
double Freq = Stopwatch.Frequency;
double milliseconds = (ticks / Freq) * 1000;
Console.WriteLine($"Data Analyze OK...Elapsed milliseconds: {milliseconds} ms");

return VSOP2013DATA;
}
Expand All @@ -105,8 +96,9 @@ private static void ReadPlanet(PlanetTable Planet, int ip)
//var debug = Assembly.GetExecutingAssembly().GetManifestResourceNames();

var assembly = Assembly.GetExecutingAssembly();
string datafilename = $"VSOP2013.Resources.VSOP2013p{ip + 1}.dat";
string datafilename = $"DataConverter.Resources.VSOP2013p{ip + 1}.dat";
Stream s = assembly.GetManifestResourceStream(datafilename);

sr = new StreamReader(s);
while ((line = sr.ReadLine()) != null)
{
Expand All @@ -123,7 +115,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;
Expand Down Expand Up @@ -203,7 +194,6 @@ private static Term ReadTerm(string line, ref Term T)

//T.iphi = Bufferiphi;


ci = Convert.ToDouble(line.Substring(lineptr, 20).Trim());
lineptr += 20;
lineptr++;
Expand Down Expand Up @@ -232,7 +222,6 @@ private static Term ReadTerm(string line, ref Term T)

private static PowerTable[] DataPruning(PowerTable[] tables)
{

for (int i = 0; i < tables.Length; i++)
{
if (tables[i].Terms is null)
Expand Down
87 changes: 87 additions & 0 deletions DataConverter/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
using MessagePack;
using System.Diagnostics;
using System.Runtime.Serialization.Formatters.Binary;

namespace VSOP2013.DataConverter
{
internal class Program
{
private static void Main(string[] args)
{
var lz4Options = MessagePackSerializerOptions.Standard.WithCompression(MessagePackCompression.Lz4Block);

#region Read Original Data

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

List<PlanetTable> VSOP2013DATA = DataReader.ReadData();

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();

#endregion Read Original Data

#region Dump Data

string OutputDirPath = Directory.GetCurrentDirectory() + @"\Data";
if (!Directory.Exists(OutputDirPath))
{
Directory.CreateDirectory(OutputDirPath);
}
DirectoryInfo OutputDir = new DirectoryInfo(Directory.GetCurrentDirectory() + @"\Data");

sw.Restart();

ParallelLoopResult result = Parallel.For(0, 9, ip =>
{
string filename = Path.Combine(OutputDir.FullName, string.Format("VSOP2013_{0}.BIN", VSOP2013DATA[ip].body.ToString()));
if (File.Exists(filename))
{
File.Delete(filename);
}
using (FileStream fs = new FileStream(filename, FileMode.OpenOrCreate))
{
BinaryFormatter bf = new BinaryFormatter();
MessagePackSerializer.Serialize(fs, VSOP2013DATA[ip], lz4Options);
}
});

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();

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));
}
});

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

#endregion Test
}
}
}
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@

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
3/ Equatorial Heliocentric Coordinates: X,Y,Z (au) X',Y',Z' (au/d) - ICRS Frame J2000
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
3/ Equatorial Heliocentric Coordinates: X, Y, Z(au) X',Y',Z' (au/d) - ICRS Frame J2000

Julian Date JD 2411545.0 (TDB)
Julian Date JD 2411545.0 (TDB)
0.3870979635 6.2605163414 0.0452614144 0.2005681842 0.0405434321 0.0457750937
0.3493879042 -0.1615770401 -0.0453430160 0.0063187162 0.0268317850 0.0016062487
0.3493878714 -0.1302077267 -0.1058730361 0.0063187222 0.0239787530 0.0121467712
Expand Down Expand Up @@ -52,11 +52,11 @@

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
3/ Equatorial Heliocentric Coordinates: X,Y,Z (au) X',Y',Z' (au/d) - ICRS Frame J2000
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
3/ Equatorial Heliocentric Coordinates: X, Y, Z(au) X',Y',Z' (au/d) - ICRS Frame J2000

Julian Date JD 2411545.0 (TDB)
Julian Date JD 2411545.0 (TDB)
0.7233268460 3.0850544129 -0.0045575903 0.0051297811 0.0066724242 0.0288666759
-0.7178452078 0.0333612116 0.0419440586 -0.0010551049 -0.0202953755 -0.0002102008
-0.7178452043 0.0139241146 0.0517532468 -0.0010551096 -0.0185370311 -0.0082658890
Expand Down Expand Up @@ -103,11 +103,11 @@

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
3/ Equatorial Heliocentric Coordinates: X,Y,Z (au) X',Y',Z' (au/d) - ICRS Frame J2000
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
3/ Equatorial Heliocentric Coordinates: X, Y, Z(au) X',Y',Z' (au/d) - ICRS Frame J2000

Julian Date JD 2411545.0 (TDB)
Julian Date JD 2411545.0 (TDB)
1.0000096358 4.8188777642 -0.0036242360 0.0163481300 0.0001248730 -0.0000110805
0.1117529336 -1.0104931629 -0.0002498901 0.0168189379 0.0018288000 0.0000008295
0.1117527004 -0.9270100498 -0.4021802015 0.0168189384 0.0016775571 0.0007282156
Expand Down Expand Up @@ -154,11 +154,11 @@

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
3/ Equatorial Heliocentric Coordinates: X,Y,Z (au) X',Y',Z' (au/d) - ICRS Frame J2000
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
3/ Equatorial Heliocentric Coordinates: X, Y, Z(au) X',Y',Z' (au/d) - ICRS Frame J2000

Julian Date JD 2411545.0 (TDB)
Julian Date JD 2411545.0 (TDB)
1.5236841626 4.7846953863 0.0850047012 -0.0386037157 0.0104503533 0.0124027403
-0.1474458094 -1.4589014057 -0.0268451993 0.0144622332 -0.0002104338 -0.0003632842
-0.1474461434 -1.3278375334 -0.6049474049 0.0144622332 -0.0000485668 -0.0004170125
Expand Down Expand Up @@ -205,11 +205,11 @@

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
3/ Equatorial Heliocentric Coordinates: X,Y,Z (au) X',Y',Z' (au/d) - ICRS Frame J2000
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
3/ Equatorial Heliocentric Coordinates: X, Y, Z(au) X',Y',Z' (au/d) - ICRS Frame J2000

Julian Date JD 2411545.0 (TDB)
Julian Date JD 2411545.0 (TDB)
5.2027787025 5.4273729856 0.0474307493 0.0119309207 -0.0020314597 0.0112167899
2.9837893541 -4.1334108921 -0.0501531373 0.0060327773 0.0047801335 -0.0001547883
2.9837884053 -3.7723816270 -1.6901903627 0.0060327784 0.0044472568 0.0017594117
Expand Down Expand Up @@ -256,11 +256,11 @@

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
3/ Equatorial Heliocentric Coordinates: X,Y,Z (au) X',Y',Z' (au/d) - ICRS Frame J2000
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
3/ Equatorial Heliocentric Coordinates: X, Y, Z(au) X',Y',Z' (au/d) - ICRS Frame J2000

Julian Date JD 2411545.0 (TDB)
Julian Date JD 2411545.0 (TDB)
9.5223420509 2.6372558976 -0.0013261890 0.0534078734 -0.0088168973 0.0198122559
-8.5151107303 3.6958970183 0.2724266220 -0.0025150365 -0.0051284514 0.0001902254
-8.5151099046 3.2825565780 1.7200893604 -0.0025150377 -0.0047809292 -0.0018654516
Expand Down Expand Up @@ -307,11 +307,11 @@

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
3/ Equatorial Heliocentric Coordinates: X,Y,Z (au) X',Y',Z' (au/d) - ICRS Frame J2000
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
3/ Equatorial Heliocentric Coordinates: X, Y, Z(au) X',Y',Z' (au/d) - ICRS Frame J2000

Julian Date JD 2411545.0 (TDB)
Julian Date JD 2411545.0 (TDB)
19.2176223319 3.5628257887 -0.0473181207 0.0060839286 0.0018734886 0.0065084828
-16.4159077405 -8.4156336905 0.1821646518 0.0017679079 -0.0036818680 -0.0000368112
-16.4159097008 -7.7936503250 -3.1804126500 0.0017679071 -0.0033634059 -0.0014983360
Expand Down Expand Up @@ -358,11 +358,11 @@

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
3/ Equatorial Heliocentric Coordinates: X,Y,Z (au) X',Y',Z' (au/d) - ICRS Frame J2000
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
3/ Equatorial Heliocentric Coordinates: X, Y, Z(au) X',Y',Z' (au/d) - ICRS Frame J2000

Julian Date JD 2411545.0 (TDB)
Julian Date JD 2411545.0 (TDB)
30.0385847963 1.1425611229 0.0069759741 0.0045558233 -0.0102865506 0.0115258164
12.1323737542 27.2358156923 -0.8402970634 -0.0028808365 0.0013000400 0.0000396763
12.1323801234 25.3226220555 10.0628233249 -0.0028808362 0.0011769819 0.0005535283
Expand Down Expand Up @@ -409,11 +409,11 @@

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
3/ Equatorial Heliocentric Coordinates: X,Y,Z (au) X',Y',Z' (au/d) - ICRS Frame J2000
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
3/ Equatorial Heliocentric Coordinates: X, Y, Z(au) X',Y',Z' (au/d) - ICRS Frame J2000

Julian Date JD 2411545.0 (TDB)
Julian Date JD 2411545.0 (TDB)
39.4227219159 1.3910260961 -0.1777508423 -0.1751661709 -0.0515906603 0.1400924565
17.6212944088 43.6567983387 -9.7715435955 -0.0020295942 0.0006425559 0.0005199070
17.6213054610 43.9412232438 8.4004533071 -0.0020295941 0.0003827270 0.0007325993
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions DataConverter/copy.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
copy bin\Debug\net6.0\Data ..\VSOP2013\Resources
2 changes: 1 addition & 1 deletion Demo/Demo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<Platforms>AnyCPU;x64</Platforms>
<Platforms>x64</Platforms>
</PropertyGroup>

<ItemGroup>
Expand Down
Loading

0 comments on commit d7bf308

Please sign in to comment.