Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ibody">VSOP87 Planet</param>
        /// <param name="iver">VSOP87 Version</param>
        /// <param name="TDB">Barycentric Dynamical Time</param>
        /// <returns></returns>
        /// <exception cref="ArgumentException"></exception>
        public VSOPResult GetPlanet(VSOPBody ibody, VSOPVersion iver, VSOPTime time)
        {
            if (Utility.CheckAvailability(iver, ibody))
            {
                int tableIndex = VSOP87DATA.FindIndex(x => x.version == iver && x.body == ibody);

                double[] result = Calculate(VSOP87DATA[tableIndex], VSOPTime.ToJulianDate(time.TDB));

                switch (iver)
                {
                case VSOPVersion.VSOP87:
                    return(new VSOPResultELL(iver, ibody, time, result));

                case VSOPVersion.VSOP87A or VSOPVersion.VSOP87C or VSOPVersion.VSOP87E:
                    return(new VSOPResultXYZ(iver, ibody, time, result));

                case VSOPVersion.VSOP87B or VSOPVersion.VSOP87D:
                    return(new VSOPResultLBR(iver, ibody, time, result));

                default: throw new ArgumentException();
                }
            }
            else
            {
                throw new ArgumentException("No body in this version.");
            }
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
0
        public VSOPResultELL(VSOPVersion version, VSOPBody body, VSOPTime time, double[] variables)
        {
            Version = version;
            Body    = body;

            CoordinatesRefrence = Utility.GetCoordinatesRefrence(version);

            CoordinatesType = Utility.GetCoordinatesType(version);

            ReferenceFrame = Utility.GetFrameRefrence(version);

            Time = time;

            Variables = variables;
        }
Ejemplo n.º 4
0
 public static bool CheckAvailability(VSOPVersion ver, VSOPBody body)
 {
     return(AvailableBody(ver).Exists(x => x == body));
 }