예제 #1
0
        /// <summary>
        /// <see cref="swi_check_nutation"/>
        /// </summary>
        internal static Nutation Calculate(JulianDayNumber tjd, SweData swed)
        {
            var(longitude, obliquity) = swi_nutation(tjd, swed);
            var matrix = nut_matrix(longitude, obliquity, swed.oec);

            return(new Nutation(tjd, longitude, obliquity, matrix));
        }
예제 #2
0
        private static (double longitude, double obliquity) swi_nutation(JulianDayNumber tjd, SweData swed)
        {
            // from interpolation, with three data points in 1-day steps;
            // maximum error is about 3 mas
            if (swed.InterpolateNutation)
            {
                // precalculated data points available
                if (swed.InterpolatedNutation != null && tjd < swed.InterpolatedNutation.Time2 && tjd > swed.InterpolatedNutation.Time0)
                {
                    var dx        = (tjd - swed.InterpolatedNutation.Time0).Raw - 1.0;
                    var longitude = quadratic_intp(swed.InterpolatedNutation.DPsi0, swed.InterpolatedNutation.DPsi1, swed.InterpolatedNutation.DPsi2, dx);
                    var obliquity = quadratic_intp(swed.InterpolatedNutation.DEps0, swed.InterpolatedNutation.DEps1, swed.InterpolatedNutation.DEps2, dx);
                    return(longitude, obliquity);
                }
                else
                {
                    var interpol = new InterpolatedNutation
                    {
                        Time0 = tjd.AddDays(-1.0),                       // one day earlier
                        Time2 = tjd.AddDays(1.0)                         // one day later
                    };

                    (interpol.DPsi0, interpol.DEps0) = calc_nutation(interpol.Time0, swed);
                    (interpol.DPsi2, interpol.DEps2) = calc_nutation(interpol.Time2, swed);
                    (interpol.DPsi1, interpol.DEps1) = calc_nutation(tjd, swed);

                    swed.InterpolatedNutation = interpol;
                    return(interpol.DPsi1, interpol.DEps1);
                }
            }
            return(calc_nutation(tjd, swed));
        }
예제 #3
0
 internal static Nutation CalculateForSpeed(JulianDayNumber tjd, SweData swed) =>
 Calculate(tjd.AddDays(-NUT_SPEED_INTV), swed);
예제 #4
0
        private static (double longitude, double obliquity) calc_nutation(JulianDayNumber J, SweData swed)
        {
            int    n;
            double dpsi, deps;
            double longitude = 0.0, obliquity = 0.0;
            var    jplhora_model = swed.JplHorizonsMode;
            var    nut_model     = swed.NutationModel;
            bool   is_jplhor     = false;

            if (swed.Iflag.HasFlag(SEFLG.JPLHOR))
            {
                is_jplhor = true;
            }
            if (swed.Iflag.HasFlag(SEFLG.JPLHOR_APPROX) &&
                jplhora_model == JplHorizonsMode.Three &&
                J <= HORIZONS_TJD0_DPSI_DEPS_IAU1980)
            {
                is_jplhor = true;
            }

            if (is_jplhor)
            {
                (longitude, obliquity) = calc_nutation_iau1980(J, nut_model);
                if (swed.Iflag.HasFlag(SEFLG.JPLHOR))
                {
                    n = (int)(swed.Eop.EndDate.Raw - swed.Eop.BeginDate.Raw + 0.000001);
                    var J2 = J;
                    if (J < DPSI_DEPS_IAU1980_TJD0_HORIZONS)
                    {
                        J2 = DPSI_DEPS_IAU1980_TJD0_HORIZONS;
                    }
                    var t = (J2 - swed.Eop.BeginDate).Raw;
                    dpsi       = bessel(swed.Eop.dPsi, n + 1, t);
                    deps       = bessel(swed.Eop.dEps, n + 1, t);
                    longitude += dpsi / 3600.0 * DEGTORAD;
                    obliquity += deps / 3600.0 * DEGTORAD;
                }
                else
                {
                    longitude += DPSI_IAU1980_TJD0 / 3600.0 * DEGTORAD;
                    obliquity += DEPS_IAU1980_TJD0 / 3600.0 * DEGTORAD;
                }
            }
            else if (nut_model == NutationModel.IAU_1980 || nut_model == NutationModel.IAU_CORR_1987)
            {
                (longitude, obliquity) = calc_nutation_iau1980(J, nut_model);
            }
            else if (nut_model == NutationModel.IAU_2000A || nut_model == NutationModel.IAU_2000B)
            {
                (longitude, obliquity) = calc_nutation_iau2000ab(J, nut_model);
                if (swed.Iflag.HasFlag(SEFLG.JPLHOR_APPROX) && jplhora_model == JplHorizonsMode.Two)
                {
                    longitude += -41.7750 / 3600.0 / 1000.0 * DEGTORAD;
                    obliquity += -6.8192 / 3600.0 / 1000.0 * DEGTORAD;
                }
            }
            return(longitude, obliquity);
        }
 public PositionCalculatorInternal(SweData sweData, SwephFilesStorage storage)
 {
     _sweData    = sweData;
     _swephFiles = storage;
 }
예제 #6
0
 public SwePositionCalculator(SweData sweData, SwephFilesStorage storage)
 {
     _sweData = sweData;
     _storage = storage;
 }