Beispiel #1
0
 public SweData(SEFLG iflag, DateTime dateTimeInUTC, EarthOrientationParameters eop, bool interpolateNutation = false)
 {
     Iflag                      = iflag;
     CalculationDate            = dateTimeInUTC;
     Eop                        = eop;
     InterpolateNutation        = interpolateNutation;
     CalculationJulianDayNumber = JulianDayNumber.FromDate(dateTimeInUTC);
     TidalAcc                   = TidalAcceleration.Get(TidalAccelerationMode.Default);
     IsManualTidalAcc           = false;
     LongtermPrecessionMode     = PrecessionModel.Default;
     ShorttermPrecessionMode    = PrecessionModel.Default;
     JplHorizonsMode            = JplHorizonsMode.Default;
     NutationModel              = NutationModel.Default;
     oec                        = Epsilon.Calc(CalculationJulianDayNumber, iflag, this);
     oec2000                    = Epsilon.Calc(JulianDayNumber.J2000, iflag, this);
 }
Beispiel #2
0
        /// <see cref="sweph"/>
        private (PlanetPosition position, PlanetPosition speed) CalcBodyPositionAndSpeedInternal(int bodyNumber, DateTime dateTimeInUTC, bool calcSpeed)
        {
            var tjd    = JulianDayNumber.FromDate(dateTimeInUTC);
            var file   = _storage.GetFile(bodyNumber, tjd);
            var planet = bodyNumber > SEConsts.AseroidOffset
                                ? InternalPlanets.AnyBody
                                : (InternalPlanets)bodyNumber;
            var planetData = file.PlanetsData[planet];
            var segment    = file.ReadSegment(planetData, tjd, _sweData.oec2000);

            var(position, speed) = CalcBySegment(tjd, segment, calcSpeed);

            /* if planet wanted is barycentric sun:
             * current sepl* files have do not have barycentric sun,
             * but have heliocentric earth and barycentric earth.
             * So barycentric sun and must be computed
             * from heliocentric earth and barycentric earth: the
             * computation above gives heliocentric earth, therefore we
             * have to compute barycentric earth and subtract heliocentric
             * earth from it. this may be necessary with calls from
             * sweplan() and from app_pos_etc_sun() (light-time). */
            if (bodyNumber == (int)InternalPlanets.BarycentricSun && planetData.Flags.HasFlag(PlanetFlags.EmbHeliocentric))
            {
                // sweph() calls sweph() !!! for EMB.
                // because we always call new calculation, warning about EARTH and EMB equality was omitted
                var(embPos, embSpeed) = CalcBodyPositionAndSpeedInternal((int)InternalPlanets.EMB, dateTimeInUTC, calcSpeed);
                position = new PlanetPosition(
                    embPos.Longitude - position.Longitude,
                    embPos.Latitude - position.Latitude,
                    embPos.Distance - position.Distance);
                if (calcSpeed)
                {
                    speed = new PlanetPosition(
                        embSpeed.Longitude - speed.Longitude,
                        embSpeed.Latitude - speed.Latitude,
                        embSpeed.Distance - speed.Distance);
                }
            }
            // asteroids are heliocentric.
            // if JPL or SWISSEPH, convert to barycentric - currently always
            if (planet >= InternalPlanets.AnyBody)
            {
                (position, speed) = ConvertToBarycentric(position, speed, dateTimeInUTC, calcSpeed);
            }
            return(position, speed);
        }
Beispiel #3
0
 public bool IsPlanetHeliocentric(int bodyNumber, DateTime dateTimeInUTC) =>
 _storage
 .GetFile(bodyNumber, JulianDayNumber.FromDate(dateTimeInUTC))
 .PlanetsData[(InternalPlanets)bodyNumber]
 .Flags
 .HasFlag(PlanetFlags.Heliocentric);