private void button_drawPhaseChart_Click(object sender, EventArgs e)
        {
            Dictionary <string, List <TimePeriod> > timeperiods = new Dictionary <string, List <TimePeriod> >();
            var siteXYZ              = XYZ.Parse(namedStringControl_coord.GetValue());
            var angleCut             = namedFloatControl_angleCut.GetValue();
            var prns                 = dataSourse.Prns;
            var from                 = Time.Parse(TimeFrom);
            var to                   = Time.Parse(TimeTo);
            var interval             = (to - from) / 1000;
            ObjectTableStorage table = new ObjectTableStorage("时段图");

            for (var time = from; time <= to; time = time + interval)
            {
                table.NewRow();
                table.AddItem("Epoch", time);
                foreach (var prn in prns)
                {
                    //  angle
                    var eph   = dataSourse.Get(prn, time);
                    var polar = Geo.Coordinates.CoordTransformer.XyzToGeoPolar(eph.XYZ, siteXYZ);
                    if (polar.Elevation < angleCut)
                    {
                        continue;
                    }

                    table.AddItem(prn.ToString(), true);
                }
            }
            EpochChartForm chartForm = new EpochChartForm(table);

            chartForm.Show();
        }
        private void button_inter_Click(object sender, EventArgs e)
        {
            if (sortedRecordsA != null && sortedRecordsA.Count != 0 && sortedRecordsB != null && sortedRecordsB.Count != 0)
            {
                double           interval     = Double.Parse(this.textBox_interval.Text);
                SatelliteNumber  PRN          = SatelliteNumber.Parse(this.comboBox_prn.SelectedItem.ToString());
                List <Ephemeris> fitedResultA = new List <Ephemeris>();
                List <Ephemeris> fitedResultB = new List <Ephemeris>();
                Time             start        = new Time(this.dateTimePicker_from.Value);


                if (ephemerisA is Geo.Algorithm.IInterpolationCaller)
                {
                    Geo.Algorithm.IInterpolationCaller a = ephemerisA as Geo.Algorithm.IInterpolationCaller;
                    a.Order = int.Parse(this.textBox_A_count.Text);
                    if (this.radioButton_A_cheb.Checked)
                    {
                        a.InterpolationType = InterpolationType.ChebyshevPolyFit;
                    }
                    else
                    {
                        a.InterpolationType = InterpolationType.LagrangeInterplation;
                    }
                }
                if (ephemerisB is Geo.Algorithm.IInterpolationCaller)
                {
                    Geo.Algorithm.IInterpolationCaller b = ephemerisB as Geo.Algorithm.IInterpolationCaller;
                    b.Order = int.Parse(this.textBox_B_count.Text);
                    if (this.radioButton_B_cheb.Checked)
                    {
                        b.InterpolationType = InterpolationType.ChebyshevPolyFit;
                    }
                    else
                    {
                        b.InterpolationType = InterpolationType.LagrangeInterplation;
                    }
                }

                double cacuCount = (this.dateTimePicker_to.Value - this.dateTimePicker_from.Value).TotalSeconds / interval;
                for (int xi = 0; xi < cacuCount; xi++)
                {
                    Time      gpsTime = start + interval * xi;
                    Ephemeris eA      = ephemerisA.Get(PRN, gpsTime);
                    Ephemeris eB      = ephemerisB.Get(PRN, gpsTime);
                    fitedResultA.Add(eA);
                    fitedResultB.Add(eB);
                }
                this.bindingSource1.DataSource = fitedResultA;
                this.bindingSource2.DataSource = fitedResultB;
                this.bindingSource3.DataSource = GetDifferEphemeirs(fitedResultA, fitedResultB);
            }
        }
Exemple #3
0
        private void calculate_Click(object sender, EventArgs e)
        {
            bool fillWithZero = checkBox1.Checked;
            var  intervalSec  = double.Parse(textBox_interval.Text) * 60;
            var  directory    = this.directorySelectionControl1.Path;

            Geo.Utils.FileUtil.CheckOrCreateDirectory(directory);
            string[] SSRsp3Pathes = this.textBox_SSRsp3Pathes.Lines;
            string[] NavPathes    = this.textBox_NavPathes.Lines;
            string[] ClockPathes  = this.textBox1.Lines;
            if (SSRsp3Pathes.Length != NavPathes.Length)
            {
                return;
            }
            int fileCount = SSRsp3Pathes.Length;

            if (!System.IO.Directory.Exists(@"D:\Temp\SSR1\"))
            {
                System.IO.Directory.CreateDirectory(@"D:\Temp\SSR1\");
            }
            EpochCountTableTextManager = new ObjectTableManager();


            EpochCountTableTextManager.OutputDirectory = "D:\\Temp\\SSR1\\";

            var SatEpochCountTable = EpochCountTableTextManager.GetOrCreate("BNCSatEpochCount");// + OriginalSSR.Header.Name);

            SatEpochCountTable.NewRow();

            for (int i = 0; i < fileCount; i++)
            {
                #region 读取SSR产品
                Time start0 = Time.MaxValue;
                Time end0   = Time.MinValue;
                OriginalSSR = new ClockFile();
                OriginalSSRMinusPreciseClockOutput = new ClockFile();
                OriginalSSRPlusNavOutput           = new ClockFile();
                using (StreamReader sr = new StreamReader(SSRsp3Pathes[i]))
                {
                    string line = sr.ReadLine();
                    if (line.Substring(0, 1) == "!")
                    {
                        ReadSSRofBNC(ref start0, ref end0, sr, line);
                    }
                    else if (line.Substring(0, 1) == ">")
                    {
                        bool IsNotEnd = true;
                        while (IsNotEnd)
                        {
                            if (line == null || line == "")
                            {
                                break;
                            }
                            if (line.Length > 10000)
                            {
                                throw new Exception("Line too long");
                            }
                            if (line.Length == 0)
                            {
                                IsNotEnd = false;
                            }
                            if (line.Substring(2, 5) == "CLOCK")
                            {
                                Time time     = Time.Parse(line.Substring(8, 21));
                                int  satCount = int.Parse(line.Substring(31, 3));
                                for (int index = 0; index < satCount; index++)
                                {
                                    line = sr.ReadLine();
                                    AtomicClock item = new AtomicClock();
                                    item.Prn       = SatelliteNumber.TryParse(line.Substring(0, 3));
                                    item.ClockBias = double.Parse(line.Substring(12, 5)) / GnssConst.LIGHT_SPEED;
                                    item.Time      = time;
                                    item.ClockType = Data.Rinex.ClockType.Satellite;
                                    item.Name      = item.Prn.ToString();
                                    OriginalSSR.GetClockItems(item.Prn).Add(item);
                                }

                                if (time < start0)
                                {
                                    start0 = time;
                                }
                                if (time > end0)
                                {
                                    end0 = time;
                                }
                            }
                            line = sr.ReadLine();
                        }
                    }
                    else
                    {
                        ReadSSRofRevisedBNC(ref start0, ref end0, sr, line);
                    }
                }
                OriginalSSR.TimePeriod = new BufferedTimePeriod(start0, end0);
                Dictionary <string, int> SatEpochCount = new Dictionary <string, int>();
                foreach (var item in OriginalSSR.Names)
                {
                    SatEpochCount.Add(item, OriginalSSR.GetClockItems(item).Count);
                }
                SatEpochCountTable.AddItem("Day", start0.GetGpsWeekAndDay());
                foreach (var item in SatEpochCount)
                {
                    SatEpochCountTable.AddItem(item.Key, item.Value);
                }
                SatEpochCountTable.EndRow();



                #endregion

                #region 读取广播星历
                ParamNavFileReader NavReader = new ParamNavFileReader(NavPathes[i]);
                ephemeris = new SingleParamNavFileEphService(NavReader.ReadGnssNavFlie());
                #endregion
                #region 读取钟差文件

                ClockFileReader reader = new ClockFileReader(ClockPathes[i], false);
                ClockFile = reader.ReadAll();
                if (ClockFile.ClockCount == 0)
                {
                    return;
                }
                #endregion

                this.bindingSource1.DataSource = OriginalSSR.AllItems;
                this.comboBox_name.DataSource  = OriginalSSR.Names;

                List <AtomicClock> OriginalSSRDataSource = new List <AtomicClock>();
                List <AtomicClock> ClockFileDataSource   = new List <AtomicClock>();

                foreach (var item in OriginalSSR.Names)
                {
                    //OriginalSSRDataSource = OriginalSSR.GetClockItems(key);
                    ClockFileDataSource = ClockFile.GetClockItems(item);
                    if (ClockFileDataSource == null)
                    {
                        continue;
                    }
                    List <AtomicClock> ErrorResult      = new List <AtomicClock>();
                    List <AtomicClock> SSRPlusNavResult = new List <AtomicClock>();

                    foreach (var item1 in ClockFileDataSource)
                    {
                        AtomicClock item2 = new AtomicClock();
                        var         clk   = OriginalSSR.GetClockItem(item1.Prn.ToString(), item1.Time);
                        if (item1.ClockBias == 9999999999.0 || clk == null)
                        {
                            item1.ClockBias = 9999999999.0;
                            item2.Time      = item1.Time;
                            item2.Prn       = item1.Prn;
                            item2.Name      = item1.Name;
                            item2.ClockType = item1.ClockType;
                            item2.ClockBias = 9999999999.0;
                        }
                        else
                        {
                            var NavItem = ephemeris.Get(item1.Prn, item1.Time);
                            item2.Time      = item1.Time;
                            item2.Prn       = item1.Prn;
                            item2.Name      = item1.Name;
                            item2.ClockType = item1.ClockType;
                            item2.ClockBias = NavItem.ClockBias - NavItem.RelativeCorrection + clk.ClockBias;
                            item1.ClockBias = item2.ClockBias - item1.ClockBias;
                        }
                        SSRPlusNavResult.Add(item2);
                        ErrorResult.Add(item1);
                    }
                    OriginalSSRMinusPreciseClockOutput.Add(item, ErrorResult);
                    OriginalSSRPlusNavOutput.Add(item, SSRPlusNavResult);
                }

                double interval = double.Parse(this.textBox_interval.Text);
                ClockEstimationFrom = this.dateTimePicker_from.Value;
                ClockEstimationTo   = this.dateTimePicker_to.Value;


                OriginalSSR.Header                 = ClockFile.Header;
                OriginalSSR.Header.SourceName      = "SSR" + OriginalSSR.Header.SourceName;
                OriginalSSR.Header.CreationDate    = DateTime.Now.ToString();
                OriginalSSR.Header.CreationAgence  = "Gnsser";
                OriginalSSR.Header.ANALYSIS_CENTER = "Gnsser";
                OriginalSSR.Header.CreationProgram = "Gnsser";
                OriginalSSR.Header.TYPES_OF_DATA.Clear();
                OriginalSSR.Header.TYPES_OF_DATA.Add("AS");
                OriginalSSR.Header.COUNT_OF_TYPES_OF_DATA = 1;
                OriginalSSR.Header.ClockSolnStations.Clear();
                OriginalSSRMinusPreciseClockOutput.Header = OriginalSSR.Header;
                OriginalSSRPlusNavOutput.Header           = OriginalSSR.Header;

                var resutlPath      = Path.Combine("D:\\Temp\\SSR1\\", OriginalSSR.Header.SourceName);
                var errorResutlPath = Path.Combine("D:\\Temp\\SSR1\\", "error" + OriginalSSR.Header.SourceName);

                ClockFileWriter ClockFileWriter = new ClockFileWriter(resutlPath, OriginalSSRPlusNavOutput);
                ClockFileWriter.SaveToFile();
                ClockFileWriter errorClockFileWriter = new ClockFileWriter(errorResutlPath, OriginalSSRMinusPreciseClockOutput);
                errorClockFileWriter.SaveToFile();
                TableTextManager = new ObjectTableManager();


                TableTextManager.OutputDirectory = "D:\\Temp\\SSR1\\";

                var             paramTable = TableTextManager.GetOrCreate(OriginalSSRMinusPreciseClockOutput.Name + "errorSSRSat");
                int             count      = 0;
                SatelliteNumber prnIndex   = new SatelliteNumber();
                foreach (var item in OriginalSSRMinusPreciseClockOutput)
                {
                    if (item.Count > count)
                    {
                        count = item.Count; prnIndex = item[0].Prn;
                    }
                }

                var    standard     = OriginalSSRMinusPreciseClockOutput.GetClockItems(prnIndex);
                double DoubleDiffer = 0;
                foreach (var item in standard)
                {
                    paramTable.NewRow();
                    paramTable.AddItem("Epoch", item.Time);
                    foreach (var item1 in OriginalSSRMinusPreciseClockOutput.Names)
                    {
                        if (item1 == item.Name.ToString())
                        {
                            continue;
                        }

                        var ss = OriginalSSRMinusPreciseClockOutput.GetClockItem(item1, item.Time);
                        if (ss == null)
                        {
                            continue;
                        }
                        if (item.ClockBias == 9999999999.0 || ss.ClockBias == 9999999999.0)
                        {
                            DoubleDiffer = 0;
                        }
                        else
                        {
                            DoubleDiffer = item.ClockBias - ss.ClockBias;
                        }
                        paramTable.AddItem(ss.Prn + "-" + item.Prn, DoubleDiffer * 1E9);
                    }
                    paramTable.EndRow();
                }
                TableTextManager.WriteAllToFileAndCloseStream();
            }
            EpochCountTableTextManager.WriteAllToFileAndCloseStream();
            Geo.Utils.FileUtil.OpenDirectory("D:\\Temp\\SSR1\\");
        }
        private void button_read_Click(object sender, EventArgs e)
        {
            bool fillWithZero = checkBox1.Checked;
            var  directory    = this.directorySelectionControl1.Path;

            Geo.Utils.FileUtil.CheckOrCreateDirectory(directory);

            string[] SSRsp3Pathes = this.textBox_SSRsp3Pathes.Lines;
            string[] NavPathes    = this.textBox_NavPathes.Lines;
            string[] ClockPathes  = this.textBox1.Lines;
            if (SSRsp3Pathes.Length != NavPathes.Length)
            {
                return;
            }
            int fileCount = SSRsp3Pathes.Length;

            #region  照时间顺序合并
            for (int i = 0; i < fileCount; i++)
            {
                ErrorSSRsp3 = new Sp3File();
                SSRMinusPreciseClockOutput = new ClockFile();
                SSRPlusNavOutput           = new ClockFile();
                Sp3Reader          SSRsp3Reader = new Sp3Reader(SSRsp3Pathes[i]);
                ParamNavFileReader reader       = new ParamNavFileReader(NavPathes[i]);
                SSRsp3    = SSRsp3Reader.ReadAll();
                ephemeris = new SingleParamNavFileEphService(reader.ReadGnssNavFlie());

                #region 读取钟差文件
                ClockFileReader ClockReader = new ClockFileReader(ClockPathes[i], false);
                ClockFile = ClockReader.ReadAll();
                if (ClockFile.ClockCount == 0)
                {
                    return;
                }
                #endregion
                #region 以sp3的格式进行比较,发现比较麻烦
                //foreach (Sp3Section sec in SSRsp3)
                //{
                //    Sp3Section ErrorResult = new Sp3Section();
                //    Time t = sec.Time;
                //    foreach (Sp3Record rec in sec)
                //    {
                //        Sp3Record error = new Sp3Record();
                //        if (!ephemeris.Prns.Contains(rec.Prn))
                //        {
                //            rec.ClockBias = 999999.999999 * 1e6;
                //            error.Time = rec.Time;
                //            error.Prn = rec.Prn;
                //            error.ClockBias = 999999.999999 * 1e6;
                //            ErrorResult.Add(error.Prn, error);
                //            continue;
                //        }
                //        var key = ephemeris.Get(rec.Prn, t);
                //        rec.ClockBias = key.ClockBias - key.RelativeTime + rec.ClockBias;
                //        var clock=ClockFile.GetClockItem(rec.Prn.ToString(), t);
                //        error.Time = rec.Time;
                //        error.Prn = rec.Prn;
                //        error.ClockBias = clock.ClockBias - rec.ClockBias;
                //        ErrorResult.Add(error.Prn,error);
                //    }
                //    ErrorSSRsp3.Add(ErrorResult);
                //}
                #endregion
                #region 以clock文件格式进行比较
                List <AtomicClock> ClockFileDataSource = new List <AtomicClock>();
                foreach (var item in SSRsp3.Prns)
                {
                    ClockFileDataSource = ClockFile.GetClockItems(item);
                    List <AtomicClock> ErrorResult      = new List <AtomicClock>();
                    List <AtomicClock> SSRPlusNavResult = new List <AtomicClock>();
                    foreach (var item1 in ClockFileDataSource)
                    {
                        AtomicClock item2 = new AtomicClock();
                        var         clk   = SSRsp3.Get(item1.Time);

                        if (item1.ClockBias == 9999999999.0 || clk == null || !clk.Contains(item1.Prn))
                        {
                            if (clk != null)
                            {
                            }
                            item1.ClockBias = 9999999999.0;
                            item2.Time      = item1.Time;
                            item2.Prn       = item1.Prn;
                            item2.Name      = item1.Name;
                            item2.ClockType = item1.ClockType;
                            item2.ClockBias = 9999999999.0;
                        }
                        //else if (!clk.Contains(item1.Prn))
                        //{
                        //    item1.ClockBias = 9999999999.0;
                        //    item2.Time = item1.Time;
                        //    item2.Prn = item1.Prn;
                        //    item2.Name = item1.Name;
                        //    item2.ClockType = item1.ClockType;
                        //    item2.ClockBias = 9999999999.0;
                        //}
                        else
                        {
                            var NavItem = ephemeris.Get(item1.Prn, item1.Time);
                            item2.Time      = item1.Time;
                            item2.Prn       = item1.Prn;
                            item2.Name      = item1.Name;
                            item2.ClockType = item1.ClockType;
                            item2.ClockBias = NavItem.ClockBias - NavItem.RelativeCorrection + clk.Data[item1.Prn].ClockBias;
                            item1.ClockBias = item2.ClockBias - item1.ClockBias;
                        }
                        SSRPlusNavResult.Add(item2);
                        ErrorResult.Add(item1);
                    }
                    SSRMinusPreciseClockOutput.Add(item.ToString(), ErrorResult);
                    SSRPlusNavOutput.Add(item.ToString(), SSRPlusNavResult);
                }
                #endregion
                SSRMinusPreciseClockOutput.Header                 = ClockFile.Header;
                SSRMinusPreciseClockOutput.Header.SourceName      = "errorSSR" + ClockFile.Header.SourceName;
                SSRMinusPreciseClockOutput.Header.CreationDate    = DateTime.Now.ToString();
                SSRMinusPreciseClockOutput.Header.CreationAgence  = "Gnsser";
                SSRMinusPreciseClockOutput.Header.ANALYSIS_CENTER = "Gnsser";
                SSRMinusPreciseClockOutput.Header.CreationProgram = "Gnsser";
                SSRMinusPreciseClockOutput.Header.TYPES_OF_DATA.Clear();
                SSRMinusPreciseClockOutput.Header.TYPES_OF_DATA.Add("AS");
                SSRMinusPreciseClockOutput.Header.COUNT_OF_TYPES_OF_DATA = 1;
                SSRMinusPreciseClockOutput.Header.ClockSolnStations.Clear();
                SSRPlusNavOutput.Header = SSRMinusPreciseClockOutput.Header;
                if (!System.IO.Directory.Exists(@"D:\Temp\errorSSR\"))
                {
                    System.IO.Directory.CreateDirectory(@"D:\Temp\errorSSR\");
                }
                var             errorResutlPath      = Path.Combine("D:\\Temp\\errorSSR\\", "errorSSR" + ClockFile.Header.SourceName);
                ClockFileWriter errorClockFileWriter = new ClockFileWriter(errorResutlPath, SSRMinusPreciseClockOutput);
                errorClockFileWriter.SaveToFile();

                var             SSRPlusNavResutlPath = Path.Combine("D:\\Temp\\errorSSR\\", "SSR+Nav" + ClockFile.Header.SourceName);
                ClockFileWriter SSRPlusNavWriter     = new ClockFileWriter(SSRPlusNavResutlPath, SSRPlusNavOutput);
                SSRPlusNavWriter.SaveToFile();

                TableTextManager = new ObjectTableManager();


                TableTextManager.OutputDirectory = "D:\\Temp\\errorSSR\\";

                var             paramTable = TableTextManager.GetOrCreate(SSRMinusPreciseClockOutput.Name + "errorSSRSat");
                int             count      = 1000000000;
                SatelliteNumber prnIndex   = new SatelliteNumber();
                foreach (var item in SSRMinusPreciseClockOutput)
                {
                    int countEx = 0;
                    foreach (var item1 in item)
                    {
                        if (item1.ClockBias == 9999999999.0)
                        {
                            countEx++;
                        }
                    }
                    if (countEx < count)
                    {
                        count = countEx; prnIndex = item[0].Prn;
                    }
                }

                var    standard     = SSRMinusPreciseClockOutput.GetClockItems(prnIndex);
                double DoubleDiffer = 0;
                foreach (var item in standard)
                {
                    paramTable.NewRow();
                    paramTable.AddItem("Epoch", item.Time);
                    foreach (var item1 in SSRMinusPreciseClockOutput.Names)
                    {
                        if (item1 == item.Name.ToString())
                        {
                            continue;
                        }

                        var ss = SSRMinusPreciseClockOutput.GetClockItem(item1, item.Time);
                        if (ss == null)
                        {
                            continue;
                        }
                        if (item.ClockBias == 9999999999.0 || ss.ClockBias == 9999999999.0)
                        {
                            DoubleDiffer = 0;
                        }
                        else
                        {
                            DoubleDiffer = item.ClockBias - ss.ClockBias;
                        }
                        paramTable.AddItem(ss.Prn + "-" + item.Prn, DoubleDiffer * 1E9);
                    }
                    paramTable.EndRow();
                }
                TableTextManager.WriteAllToFileAndCloseStream();

                int       dayOfWeek = SSRsp3.Header.StartTime.GetGpsWeekAndDay();
                var       path      = Path.Combine("D:\\Temp\\errorSSR\\", "RT" + SSRsp3.Name);//+ dayOfWeek.ToString() + ".sp3");
                Sp3Writer Sp3Writer = new Sp3Writer(path, SSRsp3);
                Sp3Writer.SaveToFile();
                SSRsp3.Clear();
                //var errorPath = Path.Combine("D:\\Temp\\errorSSR\\", "error" + SSRsp3Pathes[i].Substring(0, 5) + "RT" + dayOfWeek.ToString() + ".sp3");
                //Sp3Writer errorSp3Writer = new Sp3Writer(path, ErrorSSRsp3);
                //errorSp3Writer.SaveToFile();
                //ErrorSSRsp3.Clear();
            }

            #endregion
            Geo.Utils.FileUtil.OpenDirectory("D:\\Temp\\errorSSR\\");
        }
Exemple #5
0
        private void calculate_Click(object sender, EventArgs e)
        {
            bool fillWithZero = checkBox1.Checked;
            var  intervalSec  = double.Parse(textBox_interval.Text) * 60;
            var  directory    = this.directorySelectionControl1.Path;

            Geo.Utils.FileUtil.CheckOrCreateDirectory(directory);
            string[] SSRsp3Pathes = this.textBox_SSRsp3Pathes.Lines;
            string[] NavPathes    = this.textBox_NavPathes.Lines;
            string[] ClockPathes  = this.textBox1.Lines;
            if (SSRsp3Pathes.Length != NavPathes.Length)
            {
                return;
            }
            int fileCount = SSRsp3Pathes.Length;

            if (!System.IO.Directory.Exists(@"D:\Temp\SSR1\"))
            {
                System.IO.Directory.CreateDirectory(@"D:\Temp\SSR1\");
            }
            EpochCountTableTextManager = new ObjectTableManager();


            EpochCountTableTextManager.OutputDirectory = "D:\\Temp\\SSR1\\";

            var SatEpochCountTable = EpochCountTableTextManager.GetOrCreate("BNCSatEpochCount");// + OriginalSSR.Header.Name);

            SatEpochCountTable.NewRow();

            for (int i = 0; i < fileCount; i++)
            {
                #region 读取SSR产品
                Time start0 = Time.MaxValue;
                Time end0   = Time.MinValue;
                OriginalSSRSp3 = new Sp3File();
                OriginalSSRSp3MinusPreciseClockOutput = new Sp3File();
                OriginalSSRSp3PlusNavOutput           = new Sp3File();
                Sp3Reader r = new Sp3Reader(SSRsp3Pathes[i]);
                OriginalSSRSp3 = r.ReadAll();
                OriginalSSRSp3.CheckOrBuildIndexCollection();

                Dictionary <string, int> SatEpochCount = new Dictionary <string, int>();
                foreach (var item in OriginalSSRSp3.Prns)
                {
                    SatEpochCount.Add(item.ToString(), OriginalSSRSp3.SatEphemerisCollection[item].Count);
                }
                SatEpochCountTable.AddItem("Day", start0.GetGpsWeekAndDay());
                foreach (var item in SatEpochCount)
                {
                    SatEpochCountTable.AddItem(item.Key, item.Value);
                }
                SatEpochCountTable.EndRow();

                #endregion

                #region 读取广播星历
                ParamNavFileReader NavReader = new ParamNavFileReader(NavPathes[i]);
                ephemeris = new SingleParamNavFileEphService(NavReader.ReadGnssNavFlie());
                #endregion
                #region 读取钟差文件

                //ClockFileReader reader = new ClockFileReader(ClockPathes[i]);
                //ClockFile = reader.ReadAll();
                //if (ClockFile.ClockCount == 0) return;
                #endregion
                OriginalSSRSp3.CheckOrBuildIndexCollection();
                for (Time time = OriginalSSRSp3.TimePeriod.Start; time <= OriginalSSRSp3.TimePeriod.End; time += 1)
                {
                    Sp3Section Sp3Section = new Sp3Section();
                    Sp3Section.Time = time;
                    foreach (var prn in OriginalSSRSp3.Prns)
                    {
                        var ss1 = OriginalSSRSp3.SatEphemerisCollection[prn].Values.FindLast(b => b.Time <= time);

                        if (!ephemeris.Prns.Contains(prn))
                        {
                            continue;
                        }
                        var ss = ephemeris.Get(prn, time);
                        XYZ eA = ss.XyzDot / ss.XyzDot.Length;
                        XYZ eC = ss.XYZ.Cross(ss.XyzDot) / (ss.XYZ.Cross(ss.XyzDot)).Length;
                        XYZ eR = eA.Cross(eC) / (eA.Cross(eC)).Length;

                        XYZ    deltaO = ss1.XYZ + ss1.XyzDot * (time.Seconds - ss1.Time.Seconds);
                        double x      = eA.X * deltaO.X + eA.X * deltaO.Y + eC.X * deltaO.Z;
                        double y      = eA.Y * deltaO.X + eA.Y * deltaO.Y + eC.Y * deltaO.Z;
                        double z      = eA.Z * deltaO.X + eA.Z * deltaO.Y + eC.Z * deltaO.Z;


                        Ephemeris Sp3Record = new Ephemeris();
                        Sp3Record.Prn = prn;
                        Sp3Record.XYZ = ss.XYZ - new XYZ(x, y, z);
                        if (prn.SatelliteType == SatelliteType.R)
                        {
                            Sp3Record.ClockBias = ss.ClockBias + ss1.ClockBias;
                        }
                        else
                        {
                            Sp3Record.ClockBias = ss.ClockBias - ss.RelativeCorrection + ss1.ClockBias;
                        }
                        Sp3Section.Add(prn, Sp3Record);
                    }
                    OriginalSSRSp3PlusNavOutput.Add(Sp3Section);
                }
                var resultPath = Path.Combine("D:\\Temp\\SSR1\\", OriginalSSRSp3.Name);

                Sp3Writer ClockFileWriter = new Sp3Writer(resultPath, OriginalSSRSp3PlusNavOutput);
                ClockFileWriter.SaveToFile();
            }


            //    List<AtomicClock> OriginalSSRDataSource = new List<AtomicClock>();
            //    List<AtomicClock> ClockFileDataSource = new List<AtomicClock>();

            //    foreach (var key in OriginalSSRSp3.Prns)
            //    {
            //        //OriginalSSRDataSource = OriginalSSR.GetClockItems(key);
            //        ClockFileDataSource = ClockFile.GetClockItems(key);
            //        if (ClockFileDataSource == null) continue;
            //        List<AtomicClock> ErrorResult = new List<AtomicClock>();
            //        List<AtomicClock> SSRPlusNavResult = new List<AtomicClock>();

            //        foreach (var item1 in ClockFileDataSource)
            //        {
            //            AtomicClock item2 = new AtomicClock();
            //            var clk =  OriginalSSRSp3.GetClockItem(item1.Prn.ToString(),item1.Time);
            //            if (item1.ClockBias == 9999999999.0 || clk == null)
            //            {
            //                item1.ClockBias = 9999999999.0;
            //                item2.Time = item1.Time;
            //                item2.Prn = item1.Prn;
            //                item2.Name = item1.Name;
            //                item2.ClockType = item1.ClockType;
            //                item2.ClockBias = 9999999999.0;
            //            }
            //            else
            //            {
            //                var NavItem = ephemeris.Get(item1.Prn, item1.Time);
            //                item2.Time = item1.Time;
            //                item2.Prn = item1.Prn;
            //                item2.Name = item1.Name;
            //                item2.ClockType = item1.ClockType;
            //                item2.ClockBias = NavItem.ClockBias - NavItem.RelativeTime + clk.ClockBias;
            //                item1.ClockBias = item2.ClockBias - item1.ClockBias;
            //            }
            //            SSRPlusNavResult.Add(item2);
            //            ErrorResult.Add(item1);

            //        }
            //        OriginalSSRSp3MinusPreciseClockOutput.Add(key, ErrorResult);
            //        OriginalSSRSp3PlusNavOutput.Add(key, SSRPlusNavResult);

            //    }

            //    double interval = double.Parse(this.textBox_interval.Text);
            //    ClockEstimationFrom = this.dateTimePicker_from.Value;
            //    ClockEstimationTo = this.dateTimePicker_to.Value;


            //    OriginalSSRSp3.Header = new Sp3Header ();
            //    OriginalSSRSp3.Header.AgencyName="Gnsser";
            //    OriginalSSRSp3.Header.EndTime=
            //    .Name = "SSR" + OriginalSSRSp3.Header.Name;
            //    OriginalSSRSp3.Header.CreationDate = DateTime.Now.ToString();
            //    OriginalSSRSp3.Header.CreationAgence = "Gnsser";
            //    OriginalSSRSp3.Header.ANALYSIS_CENTER = "Gnsser";
            //    OriginalSSRSp3.Header.CreationProgram = "Gnsser";
            //    OriginalSSRSp3MinusPreciseClockOutput.Header = OriginalSSRSp3.Header;
            //    OriginalSSRSp3PlusNavOutput.Header = OriginalSSRSp3.Header;

            //    var resutlPath = Path.Combine("D:\\Temp\\SSR1\\", OriginalSSRSp3.Header.Name);
            //    var errorResutlPath = Path.Combine("D:\\Temp\\SSR1\\", "error" + OriginalSSRSp3.Header.Name);

            //    ClockFileWriter ClockFileWriter = new ClockFileWriter(resutlPath, OriginalSSRSp3PlusNavOutput);
            //    ClockFileWriter.SaveToFile();
            //    ClockFileWriter errorClockFileWriter = new ClockFileWriter(errorResutlPath, OriginalSSRSp3MinusPreciseClockOutput);
            //    errorClockFileWriter.SaveToFile();
            //    TableTextManager = new TableObjectManager();


            //    TableTextManager.OutputDirectory = "D:\\Temp\\SSR1\\";

            //    var paramTable = TableTextManager.GetOrCreate(OriginalSSRSp3MinusPreciseClockOutput.Name + "errorSSRSat");
            //    int count = 0;
            //    SatelliteNumber prnIndex = new SatelliteNumber();
            //    foreach (var key in OriginalSSRSp3MinusPreciseClockOutput)
            //    {
            //        if (key.Count > count) { count = key.Count; prnIndex = key[0].Prn; }
            //    }

            //    var standard = OriginalSSRSp3MinusPreciseClockOutput.GetClockItems(prnIndex);
            //    double DoubleDiffer = 0;
            //    foreach (var key in standard)
            //    {
            //        paramTable.NewRow();
            //        paramTable.AddItem("Epoch", key.Time);
            //        foreach (var item1 in OriginalSSRSp3MinusPreciseClockOutput.Names)
            //        {
            //            if (item1 == key.Name.ToString()) continue;

            //            var ss = OriginalSSRSp3MinusPreciseClockOutput.GetClockItem(item1, key.Time);
            //            if (ss == null)
            //                continue;
            //            if (key.ClockBias == 9999999999.0 || ss.ClockBias == 9999999999.0)
            //                DoubleDiffer = 0;
            //            else DoubleDiffer = key.ClockBias - ss.ClockBias;
            //            paramTable.AddItem(ss.Prn + "-" + key.Prn, DoubleDiffer * 1E9);
            //        }
            //        paramTable.EndRow();
            //    }
            //    TableTextManager.WriteAllToFileAndCloseStream();
            //}
            //EpochCountTableTextManager.WriteAllToFileAndCloseStream();
            Geo.Utils.FileUtil.OpenDirectory("D:\\Temp\\SSR1\\");
        }