Beispiel #1
0
        private void button_Convert_Click(object sender, EventArgs e)
        {
            var path = System.IO.Path.Combine(Setting.GnsserConfig.TempDirectory, System.IO.Path.GetFileName(this.textBox_Path.Text));

            System.IO.File.WriteAllText(path, Sp3Writer.BuidSp3V3String(sp3));
            Geo.Utils.FormUtil.ShowOkAndOpenFile(path);
        }
Beispiel #2
0
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="startTime"></param>
        /// <param name="siteName"></param>
        /// <param name="OutpuDirectory"></param>
        public RealTimeGnssDataWriter(String OutpuDirectory, string siteName, Time startTime)
        {
            this.OutpuDirectory   = OutpuDirectory;
            this.SiteName         = siteName;
            this.OFileNameBuilder = new RinexFileNameBuilder().SetRinexFileType(RinexFileType.O).SetSationName(siteName).SetTimeResolution(TimeUnit.Second);
            var fileName = OFileNameBuilder.Build(startTime);
            var path     = Path.Combine(this.OutpuDirectory, fileName);

            this.RinexObsFileWriter = new RinexObsFileWriter(path, 3.02);// RtcmDataParser.ObsHeader.Version);

            //导航文件,一次观测只有一个
            this.NFileNameBuilder = new RinexFileNameBuilder();
            fileName = this.NFileNameBuilder.SetRinexFileType(RinexFileType.N).SetSationName(siteName).SetTimeResolution(TimeUnit.Minute).SetTime(startTime).Build();
            var path1 = Path.Combine(this.OutpuDirectory, fileName);

            fileName = this.NFileNameBuilder.SetRinexFileType(RinexFileType.R).SetSationName(siteName).SetTimeResolution(TimeUnit.Minute).SetTime(startTime).Build();

            var path2 = Path.Combine(this.OutpuDirectory, fileName);

            this.GpsNavFileWriter     = new ParamNavFileWriter(path1);
            this.GlonassNavFileWriter = new GlonassNavFileWriter(path2);

            //精密星历
            fileName  = Path.Combine(this.OutpuDirectory, siteName + startTime.GpsWeek + "" + (int)startTime.DayOfWeek + ".sp3");
            Sp3Writer = new Sp3Writer(fileName, null);

            fileName        = Path.Combine(this.OutpuDirectory, siteName + startTime.GpsWeek + "" + (int)startTime.DayOfWeek + ".clk");
            ClockFileWriter = new ClockFileWriter(fileName);
        }
Beispiel #3
0
        /// <summary>
        /// GNSS 结果构造器
        /// </summary>
        /// <param name="context"></param>
        /// <param name="Option"></param>
        public GnssResultBuilder(GnssProcessOption Option, DataSourceContext context)
        {
            this.Context                   = context;
            this.TableTextManager          = new ObjectTableManager(Option.OutputDirectory);
            this.AioAdjustFileBuilder      = new AioAdjustFileBuilder(Option.OutputDirectory);
            this.AdjustEquationFileBuilder = new AdjustEquationFileBuilder(Option.OutputDirectory);
            this.Option            = Option;
            this.OutputMinInterval = this.Option.OutputMinInterval;
            var fileName = Path.Combine(Setting.TempDirectory, Geo.Utils.DateTimeUtil.GetDateTimePathStringNow() + ".sp3");

            Sp3Writer             = new Sp3Writer(fileName, null);
            ResultFileNameBuilder = new ResultFileNameBuilder(Option.OutputDirectory);
        }
        /// <summary>
        /// 输出sp3文件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button_export_Click(object sender, EventArgs e)
        {
            bool fillWithZero = checkBox1.Checked;
            var  directory    = this.directorySelectionControl1.Path;

            Geo.Utils.FileUtil.CheckOrCreateDirectory(directory);

            string[] pathes = this.textBox_Pathes.Lines;

            foreach (var sp3item in pathes)
            {
                Sp3Reader r = new Sp3Reader(sp3item);
                sp3 = r.ReadAll();
                string PredictedClockBiasPath = this.textBox_predictedresultPath.ToString();

                ClockBias = new Dictionary <Time, Clockbias>();

                GetPredictedClockBias(PredictedClockBiasPath);
                sp3ofPredicted        = new Sp3File();
                sp3ofPredicted.Header = sp3.Header;

                foreach (Sp3Section sec in sp3)
                {
                    Sp3Section s       = new Sp3Section();
                    Clockbias  section = ClockBias[sec.Time];
                    foreach (Ephemeris rec in sec)
                    {
                        s.Time = rec.Time;
                        if (section.sat.ContainsKey(rec.Prn) && section.sat[rec.Prn] != null)
                        {
                            rec.ClockBias = section.sat[rec.Prn];
                        }
                        else
                        {
                            rec.ClockBias = 999999.999999;
                        }

                        s.Add(rec.Prn, rec);
                    }
                    sp3ofPredicted.Add(s);
                }
                sp3ofPredicted.Header.Comments.Add("Processd by Gnsser");
                sp3ofPredicted.Header.Comments.Add("Predicted clock bias replace original precise data");
                var       path      = Path.Combine(directory, "P" + r.Name + ".sp3");
                Sp3Writer Sp3Writer = new Sp3Writer(path, sp3ofPredicted);
                sp3.Clear();
            }
            Geo.Utils.FileUtil.OpenDirectory(directory);
        }
Beispiel #5
0
        /// <summary>
        /// 完毕
        /// </summary>
        public override void Complete()
        {
            base.Complete();

            Sp3Writer.Flush();

            var keys = this.TableTextManager.Keys.FindAll(m => m.Contains(Setting.EpochParamFileExtension));

            if (keys.Count == 0)
            {
                return;
            }
            foreach (var item in keys)
            {
                var table = TableTextManager.Get(item);
                EpochParamAnalyzer.Add(table);
            }
            EpochParamAnalyzer.GetTotalFileParamConvergenceTable();
        }
Beispiel #6
0
        /// <summary>
        ///  GNSS 结果构造器
        /// </summary>
        /// <param name="TableTextManager"></param>
        /// <param name="AioAdjustFileBuilder"></param>
        /// <param name="Option"></param>
        /// <param name="context"></param>
        /// <param name="AdjustEquationFileBuilder"></param>
        public GnssResultBuilder(
            ObjectTableManager TableTextManager,
            AioAdjustFileBuilder AioAdjustFileBuilder,
            AdjustEquationFileBuilder AdjustEquationFileBuilder,
            GnssProcessOption Option,
            DataSourceContext context)
        {
            this.Context = context;
            this.AdjustEquationFileBuilder = AdjustEquationFileBuilder;
            this.TableTextManager          = TableTextManager;
            this.AioAdjustFileBuilder      = AioAdjustFileBuilder;
            this.Option            = Option;
            this.OutputMinInterval = this.Option.OutputMinInterval;
            var fileName = Path.Combine(Setting.TempDirectory, Geo.Utils.DateTimeUtil.GetDateTimePathStringNow() + ".sp3");

            Sp3Writer = new Sp3Writer(fileName, null);
            PrevEpoch = Time.MinValue;

            this.EpochParamAnalyzer = new EpochParamAnalyzer(new List <string>(this.Option.AnalysisParamNames),
                                                             this.Option.SequentialEpochCountOfAccuEval,
                                                             this.Option.MaxDifferOfAccuEval, this.Option.MaxAllowedConvergenceTime,
                                                             this.Option.KeyLabelCharCount, this.Option.MaxAllowedDifferAfterConvergence, this.Option.MaxAllowedRmsOfAccuEval);
            ResultFileNameBuilder = new ResultFileNameBuilder(Option.OutputDirectory);
        }
        private void OutputOfPredictedClock(string directory, string approach, int number)
        {
            sp3ofPredicted.Header                = new Sp3Header();
            sp3ofPredicted.Header.StartTime      = sp3ofPredicted.First.Time;
            sp3ofPredicted.Header.NumberOfEpochs = sp3ofPredicted.Count;
            sp3ofPredicted.Header.PRNs           = sp3ofPredicted.Prns;
            var       path      = Path.Combine(directory, "PredictedBasedon" + approach + number + ".sp3");
            Sp3Writer Sp3Writer = new Sp3Writer(path, sp3ofPredicted);

            Sp3Writer.SaveToFile();
            var          pathOfXls        = Path.Combine(directory, "PredictedBasedon" + approach + number + ".xls");
            FileInfo     aFileOfPredicted = new FileInfo(pathOfXls);
            StreamWriter SWOfPredicted    = aFileOfPredicted.CreateText();

            SWOfPredicted.Write("Time");
            SWOfPredicted.Write("\t");
            foreach (var item in sp3ofPredicted.Prns)
            {
                SWOfPredicted.Write(item.ToString());
                SWOfPredicted.Write("\t");
            }
            SWOfPredicted.Write("\n");
            foreach (var item in sp3ofPredicted)
            {
                var qq = item.Time.ToDateAndHourMinitePathString();
                SWOfPredicted.Write(item.Time.ToDateAndHourMinitePathString());
                SWOfPredicted.Write("\t");
                foreach (var sat in item)
                {
                    var aa = sat.ClockBias.ToString();
                    SWOfPredicted.Write(sat.ClockBias.ToString());
                    SWOfPredicted.Write("\t");
                }
                SWOfPredicted.Write("\n");
            }
        }
Beispiel #8
0
        /// <summary>
        /// 输出结果
        /// </summary>
        /// <param name="epoch"></param>
        /// <param name="result"></param>
        public void AddEpochResult(ISiteSatObsInfo epoch, SimpleGnssResult result)
        {
            //结果采样率过滤
            var interval = Math.Abs(epoch.ReceiverTime - PrevEpoch);

            if (interval < this.OutputMinInterval)
            {
                return;
            }
            PrevEpoch = epoch.ReceiverTime;

            //总开关
            if (!Option.IsOutputResult && !Option.IsOutputEpochResult)
            {
                return;
            }

            var Adjustment = result.ResultMatrix;
            var ParamNames = result.ParamNames;

            //各历元信息
            #region  默认逐历元输出

            //参数值
            if (Option.IsOutputEpochParam)
            {
                AddEpochParam(epoch, result);
            }

            // RMS
            if (Option.IsOutputEpochParamRms)
            {
                AddParamRms(epoch, result);
            }

            //钟跳
            if (Option.IsOutputJumpClockFile)
            {
                CheckOrAddClockJump(epoch, result);
            }

            //第二参数
            if (result.ResultMatrix.SecondEstimated != null)
            {
                AddSecondParam(epoch, result);
                AddSecondParamRms(epoch, result);
            }

            //DOP
            if (this.Option.IsOutputEpochDop)
            {
                AddDop(epoch, result);
            }

            //两路滤波,模糊度固定解
            AddAmbFixed(epoch, result);

            //动态定位,且坐标未固定,则添加
            if (this.Option.IsOutputEpochCoord || (this.Option.PositionType == PositionType.动态定位 && !this.Option.IsFixingCoord))
            {
                AddEpochCoord(epoch, result);
            }
            #endregion

            #region  择性历元输出
            #region 平差文件
            if (this.Option.IsOutputAdjust)
            {
                AioAdjustFileBuilder.AddAdjustment(Adjustment);
            }
            if (this.Option.IsOutputObsEquation)
            {
                AdjustEquationFileBuilder.AddAdjustment(Adjustment);
            }
            if (this.Option.IsOutputAdjustMatrix)
            {
                if (results == null)
                {
                    results = new List <SimpleGnssResult>();
                }
                results.Add(result);
            }

            #endregion

            #region 电离层产品
            if (this.Option.IsOutputIono)
            {
                BuildIonoResult(epoch, Adjustment, ParamNames);
            }

            #endregion

            #region 对流层产品
            if (this.Option.IsOutputWetTrop && Geo.Utils.StringUtil.Contanis(ParamNames, Gnsser.ParamNames.WetTropZpd, true) && epoch.ReceiverTime.SecondsOfDay % 300 == 0)
            {
                var table = TableTextManager.GetOrCreate(epoch.Name + "_" + Gnsser.ParamNames.WetTropZpd);
                table.NewRow();
                table.AddItem("Epoch", epoch.ReceiverTime);

                EpochInformation epochInfo = epoch as EpochInformation;
                //var ionoResult = Adjustment.Estimated.GetAll(Gnsser.ParamNames.WetTrop);
                //天顶对流层总延迟,epochInfo[0].WetMap_ZTD=1
                table.AddItem("Trop1", epochInfo[0].AppriorTropDelay + epochInfo[0].WetMap_ZTD * result.ResultMatrix.Estimated[4, 0]);
                table.AddItem("Trop2", epochInfo[1].WetMap_ZTD * result.ResultMatrix.Estimated[4, 0]);
                table.AddItem("Trop3", result.ResultMatrix.Estimated[4, 0]);
                //epoch[0].AppriorTropDelay + epoch[0].WetMap_ZTD *
                //foreach (var item in ionoResult)
                //{
                //    table.AddItem(item.Key, item.Value.Value);
                //}
            }
            #endregion

            #region  历元卫星观测信息
            if (Option.IsOutputEpochSatInfo)
            {
                AddSiteEpochSatInfo(epoch);
            }
            #endregion
            #endregion

            if (Option.IsOutputObservation)
            {
                AddObservation(epoch, result);
            }
            if (Option.IsOutputResidual)
            {
                this.AddResidual(epoch, result);
            }

            //轨道产品输出
            if (result is IOrbitResult)
            {
                var ephs = ((IOrbitResult)result).EphemerisResults;

                Sp3Section sp3Records = new Sp3Section(ephs.First.Original.Time);
                foreach (var eph in ephs)
                {
                    sp3Records.Add(eph.Original.Prn, eph.Corrected);
                }
                Sp3Writer.Write(sp3Records);
            }


            this.PrevResult = result;
        }
        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\\");
        }
        private void button_read_Click(object sender, EventArgs e)
        {
            bool fillWithZero = checkBox1.Checked;
            var  directory    = this.directorySelectionControl1.Path;

            Geo.Utils.FileUtil.CheckOrCreateDirectory(directory);

            string[] pathes     = this.textBox_Pathes.Lines;
            int      dayOfweekO = 0;

            //sp3Observation = new Sp3File();
            TableTextManager = new ObjectTableManager();


            TableTextManager.OutputDirectory = directory;

            var SatEpochCountTable = TableTextManager.GetOrCreate("GNSSerSatEpochCount" + Path.GetFileNameWithoutExtension(pathes[0]).Substring(0, 12));

            #region  照时间顺序合并
            Time start = Time.MinValue;
            foreach (var pathItem in pathes)
            {
                Sp3Reader r = new Sp3Reader(pathItem);
                sp3 = r.ReadAll();
                var intervalSec = sp3.Header.EpochInterval;

                foreach (Sp3Section sec in sp3)
                {
                    Sp3Section s = new Sp3Section();
                    foreach (var rec in sec)
                    {
                        if (rec.Prn.SatelliteType == SatelliteType.R)
                        {
                            rec.Time = rec.Time + 1;
                        }
                        s.Time = rec.Time; s.Add(rec.Prn, rec);
                    }
                    if (sp3Observation == null || sp3Observation.Count == 0)
                    {
                        sp3Observation                  = new Sp3File();
                        sp3Observation.Header           = sp3.Header;
                        sp3Observation.Header.StartTime = s.Time;
                        sp3Observation.Header.Comments.Add("Processd by Gnsser");
                        sp3Observation.Header.Comments.Add("Collected from real time SSR clock correction");
                        dayOfweekO = sp3Observation.Header.StartTime.GetGpsWeekAndDay();
                    }
                    if (((s.Time.Hour == 0 && s.Time.Minute == 0 && s.Time.Second == 0) || start.GetGpsWeekAndDay() != s.Time.GetGpsWeekAndDay()) && sp3Observation.Count != 0)
                    {
                        var pathObservation = Path.Combine(directory, "Gnsser" + sp3.Name.Substring(0, 12) + dayOfweekO.ToString() + ".sp3");
                        sp3Observation.Header.NumberOfEpochs = sp3Observation.Count;
                        Sp3Writer Sp3WriterObservation = new Sp3Writer(pathObservation, sp3Observation);
                        Sp3WriterObservation.SaveToFile();
                        SatEpochCountTable.NewRow();
                        SatEpochCountTable.AddItem("Day", dayOfweekO);
                        sp3Observation.CheckOrBuildIndexCollection();
                        foreach (var item in sp3Observation.SatEphemerisCollection.Keys)
                        {
                            int a = sp3Observation.SatEphemerisCollection[item].Count;

                            SatEpochCountTable.AddItem(item, a);
                        }
                        SatEpochCountTable.EndRow();

                        sp3Observation.Clear();
                        sp3Observation.SatEphemerisCollection.Clear();
                        sp3Observation.Header.StartTime = s.Time;
                        //sp3Observation.Header.Comments.Add("Processd by Gnsser");
                        //sp3Observation.Header.Comments.Add("Collected from real time SSR clock correction");
                        dayOfweekO = sp3Observation.Header.StartTime.GetGpsWeekAndDay();
                        start      = s.Time;
                    }
                    if (!sp3Observation.Contains(s.Time))
                    {
                        sp3Observation.Add(s);
                    }
                }
            }

            TableTextManager.WriteAllToFileAndCloseStream();

            if (sp3Observation.Count != 0)
            {
                var pathObservation = Path.Combine(directory, "Gnsser" + sp3.Name.Substring(0, 12) + dayOfweekO.ToString() + ".sp3");
                sp3Observation.Header.NumberOfEpochs = sp3Observation.Count;
                Sp3Writer Sp3WriterObservation = new Sp3Writer(pathObservation, sp3Observation);
                Sp3WriterObservation.SaveToFile();
                sp3Observation.Clear();
            }

            #endregion

            Geo.Utils.FileUtil.OpenDirectory(directory);
        }
Beispiel #11
0
 public void WriteSp3Record(Sp3Section obj)
 {
     Sp3Writer.Write(obj);
     Sp3Writer.Flush();
 }
Beispiel #12
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\\");
        }
Beispiel #13
0
        private void button_read_Click(object sender, EventArgs e)
        {
            bool   fillWithZero    = checkBox1.Checked;
            var    directory       = this.directorySelectionControl1.Path;
            string resultDirectory = Path.Combine(directory, "replace clock result");

            Geo.Utils.FileUtil.CheckOrCreateDirectory(resultDirectory);

            string[] pathes     = this.textBox_Pathes.Lines;
            string   igsSp3Path = this.textBox_IgsSp3Path.Text;
            var      st1        = int.Parse(pathes[0].Substring(pathes[0].Length - 6, 2));
            var      st2        = int.Parse(pathes[1].Substring(pathes[0].Length - 6, 2));

            #region  照单个文件进行输出,不合并

            foreach (var pathItem in pathes)
            {
                string dayOfWeek         = Path.GetFileNameWithoutExtension(pathItem).Substring(5, 5);
                string dayOfWeekfileName = Path.GetFileNameWithoutExtension(igsSp3Path).Substring(3, 5);
                string path = igsSp3Path.Replace(dayOfWeekfileName, dayOfWeek);
                if (!File.Exists(path))
                {
                    //FormUtil.ShowFileNotExistBox(path);
                    continue;
                }

                Sp3AllReader iguRead = new Sp3AllReader(pathItem);
                iguSp3 = iguRead.ReadAll();
                Sp3AllReader igsRead = new Sp3AllReader(path);
                igsSp3 = igsRead.ReadAll();

                var intervalSec = iguSp3.Header.EpochInterval;
                sp3Observation        = new Sp3File();
                sp3Observation.Header = igsSp3.Header;
                foreach (Sp3Section sec in igsSp3)
                {
                    var        item = iguSp3.Get(sec.Time);
                    Sp3Section s    = new Sp3Section();
                    foreach (var rec in sec)
                    {
                        s.Time = rec.Time;
                        if (item != null && item.Contains(rec.Prn))
                        {
                            rec.ClockBias = item[rec.Prn].ClockBias;
                        }
                        else
                        {
                            rec.ClockBias = 0.999999999999;
                        }
                        s.Add(rec.Prn, rec);
                    }
                    sp3Observation.Add(s);
                }

                sp3Observation.Header.Comments.Add("Processd by Gnsser");
                sp3Observation.Header.Comments.Add("Choose clock of IGU-P for igs");
                var pathObservation = Path.Combine(resultDirectory, iguSp3.Name);
                if (File.Exists(pathObservation))
                {
                    File.Delete(pathObservation);
                }
                Sp3Writer Sp3WriterObservation = new Sp3Writer(pathObservation, sp3Observation);
                Sp3WriterObservation.SaveToFile();
                iguSp3.Clear();
            }

            #endregion

            Geo.Utils.FileUtil.OpenDirectory(resultDirectory);
        }
        private void button_read_Click(object sender, EventArgs e)
        {
            bool fillWithZero = checkBox1.Checked;
            var  directory    = this.directorySelectionControl1.Path;

            Geo.Utils.FileUtil.CheckOrCreateDirectory(directory);

            string[] pathes = this.textBox_Pathes.Lines;

            var st1 = int.Parse(pathes[0].Substring(pathes[0].Length - 6, 2));
            var st2 = int.Parse(pathes[1].Substring(pathes[0].Length - 6, 2));

            #region  照多个文件进行合并输出
            if (st2 - st1 != 0)
            {
                sp3ofPredicted = new Sp3File(); sp3Observation = new Sp3File(); int indexOfFile = 1; int dayOfweekO = 0; int dayOfweekP = 0;
                foreach (var pathItem in pathes)
                {
                    Sp3AllReader r  = new Sp3AllReader(pathItem);
                    Sp3AllReader rP = new Sp3AllReader(pathItem);
                    sp3  = r.ReadAll();
                    sp3P = rP.ReadAll();
                    var intervalSec = sp3.Header.EpochInterval;

                    Time end1             = sp3.TimePeriod.Start + (st2 - st1) * 3600 - intervalSec;
                    Time end              = sp3.TimePeriod.Start + (st2 - st1 + 24) * 3600 - intervalSec;
                    Time startOfPredicted = sp3.TimePeriod.Start + 24 * 3600 - intervalSec;
                    foreach (Sp3Section sec in sp3)
                    {
                        Sp3Section s = new Sp3Section();
                        foreach (var rec in sec)
                        {
                            s.Time = rec.Time;
                            s.Add(rec.Prn, rec);
                        }
                        if (sec.Time <= end1)
                        {
                            sp3Observation.Add(s);
                        }
                        else if (sec.Time <= end && sec.Time > startOfPredicted)
                        {
                            sp3ofPredicted.Add(s);
                        }
                    }
                    if (indexOfFile % (24 / (st2 - st1)) == 1)
                    {
                        sp3Observation.Header           = sp3.Header;
                        sp3ofPredicted.Header           = sp3P.Header;
                        sp3ofPredicted.Header.StartTime = sp3P.Header.StartTime + 24 * 3600;
                        dayOfweekO = sp3Observation.Header.StartTime.GetGpsWeekAndDay();
                        if (dayOfweekO % 10 == 6)
                        {
                            dayOfweekP = dayOfweekO + 4;
                            sp3ofPredicted.Header.GPSWeek += 1;
                        }
                        else
                        {
                            dayOfweekP = dayOfweekO + 1;
                        }
                    }
                    if (indexOfFile % (24 / (st2 - st1)) == 0)
                    {
                        sp3Observation.Header.Comments.Add("Processd by Gnsser");
                        sp3Observation.Header.Comments.Add("Choose IGU-O from igu");
                        sp3ofPredicted.Header.Comments.Add("Processd by Gnsser");
                        sp3ofPredicted.Header.Comments.Add("Choose IGU-P from igu");
                        var pathObservation = Path.Combine(directory, "IGU-O" + dayOfweekO.ToString() + ".sp3");
                        var pathPredicted   = Path.Combine(directory, "IGU-P" + dayOfweekP.ToString() + ".sp3");
                        sp3Observation.Header.NumberOfEpochs = sp3Observation.Count;
                        sp3ofPredicted.Header.NumberOfEpochs = sp3ofPredicted.Count;
                        Sp3Writer Sp3WriterObservation = new Sp3Writer(pathObservation, sp3Observation);
                        Sp3Writer Sp3WriterPredicted   = new Sp3Writer(pathPredicted, sp3ofPredicted);
                        Sp3WriterObservation.SaveToFile();
                        Sp3WriterPredicted.SaveToFile();
                        sp3Observation.Clear();
                        sp3ofPredicted.Clear();
                    }
                    sp3.Clear();
                    indexOfFile++;
                }
            }


            #endregion
            #region  照单个文件进行输出,不合并
            else
            {
                foreach (var pathItem in pathes)
                {
                    Sp3Reader r = new Sp3Reader(pathItem);
                    sp3 = r.ReadAll();
                    var intervalSec = sp3.Header.EpochInterval;
                    sp3Observation        = new Sp3File();
                    sp3Observation.Header = sp3.Header;
                    sp3ofPredicted        = new Sp3File();
                    sp3ofPredicted.Header = sp3.Header;
                    Time end1 = sp3.TimePeriod.Start + 24 * 3600 - intervalSec;
                    Time end  = sp3.TimePeriod.End;
                    foreach (Sp3Section sec in sp3)
                    {
                        Sp3Section s = new Sp3Section();

                        foreach (var rec in sec)
                        {
                            s.Time = rec.Time;
                            s.Add(rec.Prn, rec);
                        }
                        if (sec.Time < end1)
                        {
                            sp3Observation.Add(s);
                        }
                        else
                        {
                            sp3ofPredicted.Add(s);
                        }
                    }
                    sp3Observation.Header.Comments.Add("Processd by Gnsser");
                    sp3Observation.Header.Comments.Add("Choose IGU-O from igu");
                    sp3ofPredicted.Header.Comments.Add("Processd by Gnsser");
                    sp3ofPredicted.Header.Comments.Add("Choose IGU-P from igu");
                    var       pathObservation      = Path.Combine(directory, "IGU-O-Basedon" + r.Name);
                    var       pathPredicted        = Path.Combine(directory, "IGU-P-Basedon" + r.Name);
                    Sp3Writer Sp3WriterObservation = new Sp3Writer(pathObservation, sp3Observation);
                    Sp3Writer Sp3WriterPredicted   = new Sp3Writer(pathPredicted, sp3ofPredicted);
                    Sp3WriterObservation.SaveToFile();
                    Sp3WriterPredicted.SaveToFile();
                    sp3.Clear();
                }
            }
            #endregion

            Geo.Utils.FileUtil.OpenDirectory(directory);
        }