Beispiel #1
0
        static PlanetTable ReadPlanet(string file)
        {
            string[] Extensions = { @"sun", @"mer", @"ven", @"ear", @"mar", @"jup", @"sat", @"ura", @"nep", @"emb" };

            //parse filepath

            VSOPVersion iver  = (VSOPVersion)Enum.Parse(typeof(VSOPVersion), file.Split(".")[2]);
            VSOPBody    ibody = (VSOPBody)Extensions.ToList().IndexOf(file.Split(".")[3]);

            //create an empty dataset
            PlanetTable planetdata = new PlanetTable();

            planetdata.version   = iver;
            planetdata.body      = ibody;
            planetdata.variables = new VariableTable[6];
            for (int ic = 0; ic < 6; ic++)
            {
                planetdata.variables[ic].PowerTables = new PowerTable[6];
            }


            Header H;
            string line;

            using (Stream s = Assembly.GetExecutingAssembly().GetManifestResourceStream(file))
            {
                using (StreamReader sr = new StreamReader(s))
                {
                    while ((line = sr.ReadLine()) != null)
                    {
                        H = ReadHeader(line);
                        planetdata.variables[H.ic].version = H.Version;
                        planetdata.variables[H.ic].body    = H.body;
                        planetdata.variables[H.ic].ic      = H.ic;

                        planetdata.variables[H.ic].PowerTables[H.it].version = H.Version;
                        planetdata.variables[H.ic].PowerTables[H.it].body    = H.body;
                        planetdata.variables[H.ic].PowerTables[H.it].ic      = H.ic;
                        planetdata.variables[H.ic].PowerTables[H.it].it      = H.it;
                        planetdata.variables[H.ic].PowerTables[H.it].header  = H;
                        planetdata.variables[H.ic].PowerTables[H.it].Terms   = new Term[H.nt];

                        for (int i = 0; i < H.nt; i++)
                        {
                            line = sr.ReadLine();
                            ReadTerm(line, ref planetdata.variables[H.ic].PowerTables[H.it].Terms[i]);
                        }
                    }
                }
            }
            Console.WriteLine("Load OK");
            Console.WriteLine();

            return(planetdata);
        }
Beispiel #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="Planet">Dataset of a planet</param>
        /// <param name="JD">Julian Date</param>
        /// <returns></returns>
        private double[] Calculate(PlanetTable Planet, double JD)
        {
            sw.Restart();
            double phi = (JD - 2451545.0d) / 365250d;

            double[] t = new double[6];
            for (int i = 0; i < 6; i++)
            {
                t[i] = Math.Pow(phi, i);
            }

            double[] Result = new double[6];
            double   u, cu, su;
            double   tit;//t[it]

            for (int iv = 0; iv < 6; iv++)
            {
                for (int it = 5; it >= 0; it--)
                {
                    tit = t[it];
                    if (Planet.variables[iv].PowerTables == null)
                    {
                        continue;
                    }
                    if (Planet.variables[iv].PowerTables[it].Terms == null)
                    {
                        continue;
                    }
                    foreach (Term term in Planet.variables[iv].PowerTables[it].Terms)
                    {
                        u           = term.B + term.C * phi;
                        (su, cu)    = Math.SinCos(u);
                        Result[iv] += term.A * cu * tit;

                        // Original resolution specification.
                        if (Planet.version == VSOPVersion.VSOP87)
                        {
                            continue;
                        }

                        // Derivative of 3 variables
                        if (it == 0)
                        {
                            Result[iv + 3] += (0 * it * term.A * cu) - (tit * term.A * term.C * su);
                        }
                        else
                        {
                            Result[iv + 3] += (t[it - 1] * it * term.A * cu) - (tit * term.A * term.C * su);
                        }
                    }
                }
            }

            // Original resolution specification.
            if (Planet.version == VSOPVersion.VSOP87)
            {
                return(Result);
            }
            for (int ic = 0; ic < 3; ic++)
            {
                Result[ic + 3] /= 365250d;
            }

            //Modulo Spherical longitude L into [0,2*pi)
            if (Utility.GetCoordinatesType(Planet.version) == CoordinatesType.Spherical)
            {
                Result[0] = ModuloCircle(Result[0]);
            }

            sw.Stop();
            TimeUsed = sw.Elapsed;
            return(Result);
        }