Exemple #1
0
 private EarthOrientationParameters(
     JulianDayNumber beginDate, JulianDayNumber endDate,
     IReadOnlyList <double> dPsi, IReadOnlyList <double> dEps)
 {
     BeginDate         = beginDate;
     EndDate           = endDate;
     BeginDateHorizons = JulianDayNumber.FromRaw(2437684.5);
     this.dPsi         = dPsi;
     this.dEps         = dEps;
 }
Exemple #2
0
        /// <summary>
        /// Load from EOP files
        /// <parameter name="eopC04File">File from https://datacenter.iers.org/data/latestVersion/EOP_14_C04_IAU1980_one_file_1962-now.txt</parameter>
        /// <parameter name="eopFinalsFile">File from https://datacenter.iers.org/data/latestVersion/finals.all.iau1980.txt</parameter>
        /// </summary>
        public static EarthOrientationParameters LoadFrom(
            Stream eopC04File,
            Stream?eopFinalsFile)
        {
            const double    TJDOFS = 2400000.5;
            string          s;
            JulianDayNumber beginDate = default;
            var             dpsi      = new List <double>();
            var             deps      = new List <double>();
            int             mjdsv     = 0;

            using (var reader = new StreamReader(eopC04File))
            {
                while ((s = reader.ReadLine()) != null)
                {
                    if (!s.StartsWith("1962"))
                    {
                        continue;
                    }
                    var values = s.Split(' ', StringSplitOptions.RemoveEmptyEntries);
                    var mjd    = int.Parse(values[3]);
                    // is file in one-day steps?
                    if (mjdsv > 0 && mjd - mjdsv != 1)
                    {
                        throw new FormatException("File must be in one-day steps");
                    }
                    if (mjdsv == 0)
                    {
                        beginDate = JulianDayNumber.FromRaw(mjd + TJDOFS);
                    }
                    dpsi.Add(double.Parse(values[8], CultureInfo.InvariantCulture));
                    deps.Add(double.Parse(values[9], CultureInfo.InvariantCulture));
                    mjdsv = mjd;
                }
            }
            var endDate = JulianDayNumber.FromRaw(mjdsv + TJDOFS);

            // file finals.all may have some more data, and especially estimations for the near future
            if (eopFinalsFile != null)
            {
                mjdsv            = 0;
                using var reader = new StreamReader(eopFinalsFile);
                while ((s = reader.ReadLine()) != null)
                {
                    var mjd = int.Parse(GetDigits(s, 7));
                    var jd  = JulianDayNumber.FromRaw(mjd + TJDOFS);
                    if (jd <= endDate)
                    {
                        continue;
                    }
                    // are data in one-day steps?
                    if (mjdsv > 0 && mjd - mjdsv != 1)
                    {
                        throw new FormatException("File must be in one-day steps");
                    }

                    // dpsi, deps Bulletin B
                    var dPsi = GetDoubleFromStr(s, 168);
                    var dEps = GetDoubleFromStr(s, 178);
                    if (dPsi == 0.0)
                    {
                        // try dpsi, deps Bulletin A
                        dPsi = GetDoubleFromStr(s, 99);
                        dEps = GetDoubleFromStr(s, 118);
                    }
                    if (dPsi == 0.0)
                    {
                        break;
                    }
                    dpsi.Add(dPsi / 1000.0);
                    deps.Add(dEps / 1000.0);
                    mjdsv = mjd;
                }
            }

            return(new EarthOrientationParameters(beginDate, endDate, dpsi, deps));
        }