Exemple #1
0
        static public ObjectTableStorage GetRangeErrorTable(RinexObsFile ObsFile, double k1, double k2, FileEphemerisService FileEphemerisService)
        {
            var    table     = new ObjectTableStorage("Range Error of " + ObsFile.SiteInfo.SiteName);
            double interval  = ObsFile.Header.Interval;
            var    lastTimes = new BaseDictionary <SatelliteNumber, Time>();

            var prns = ObsFile.GetPrns();

            foreach (var prn in prns)
            {
                int index = 1;
                foreach (var epoch in ObsFile)
                {
                    if (epoch.Contains(prn))
                    {
                        var sat     = epoch[prn];
                        var isError = sat.IsRangeGrossError(k1, k2);
                        if (isError)
                        {
                            if (index == 1)
                            {
                                table.NewRow();
                                table.AddItem("Prn", prn.ToString());
                            }
                            table.AddItem("Error" + (index++), epoch.ReceiverTime);
                        }
                    }
                }
            }
            return(table);
        }
        static public ObjectTableStorage GetLiTable(RinexObsFile ObsFile, FileEphemerisService FileEphemerisService)
        {
            var table = new ObjectTableStorage("LI values of " + ObsFile.SiteInfo.SiteName);

            foreach (var epoch in ObsFile)
            {
                table.NewRow();
                table.AddItem("Epoch", epoch.ReceiverTime);
                foreach (var sat in epoch)
                {
                    if (sat.PhaseA == null || sat.PhaseB == null)
                    {
                        continue;
                    }
                    table.AddItem(sat.Prn + "_Li", sat.GfValue);
                    if (FileEphemerisService != null)
                    {
                        var eph = FileEphemerisService.Get(sat.Prn, epoch.ReceiverTime);
                        if (eph != null)
                        {
                            var polar = CoordTransformer.XyzToGeoPolar(eph.XYZ, ObsFile.Header.ApproxXyz);
                            table.AddItem(sat.Prn + "_Ele", polar.Elevation);
                        }
                    }
                }
            }
            return(table);
        }
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="table"></param>
        /// <param name="savePath"></param>
        /// <param name="isTempPath">是否是临时路径,如果是,则不进行提示</param>
        /// <param name="enableDelete"></param>
        public ObsFileChartEditForm(RinexObsFile ObsFile, string savePath = null, bool isTempPath = false, bool isSort = false, bool isDrawAll = false, bool enableDelete = false)
        {
            InitializeComponent();
            this.isDrawAll = isDrawAll;
            this.Text      = ObsFile.Header.FileName;
            this.Table     = ObsFile.BuildObjectTable(isDrawAll);
            if (isSort)
            {
                Table.ParamNames.Sort();
            }
            this.ObsFilePath = savePath;
            this.chartControl1.EnableDelete = enableDelete;
            this.ObsFile = ObsFile;
            if (enableDelete)
            {
                if (!isTempPath)
                {
                    Geo.Utils.FormUtil.ShowWarningMessageBox("请注意,修改数据后将保存在" + savePath +
                                                             ",若是原始文件,请注意备份。");
                }
                this.chartControl1.DataDeleting += ChartControl1_DataDeleting;
            }

            Draw(Table);
        }
        /// <summary>
        /// 通过文件构建,按照文件坐标计算,按照其采样率输出。
        /// </summary>
        /// <param name="obsFile"></param>
        /// <param name="EphemerisService"></param>
        /// <param name="tableName"></param>
        /// <param name="AngleCut"></param>
        /// <returns></returns>
        public static ObjectTableStorage BuildTable(RinexObsFile obsFile, double AngleCut = 12, IEphemerisService EphemerisService = null, string tableName = null)
        {
            if (String.IsNullOrWhiteSpace(tableName))
            {
                tableName = obsFile.Header.MarkerName + "-卫星高度角";
            }
            if (EphemerisService == null)
            {
                EphemerisService = GlobalNavEphemerisService.Instance;
            }
            var siteXyz = obsFile.Header.ApproxXyz;

            var ephObj = EphemerisService.Get(SatelliteNumber.G01, obsFile.Header.StartTime);

            if (ephObj == null)
            {
                EphemerisService = GlobalIgsEphemerisService.Instance;
            }

            var table = new ObjectTableStorage(tableName);

            foreach (var sec in obsFile)
            {
                var time = sec.ReceiverTime;
                AddRow(AngleCut, EphemerisService, siteXyz, table, time);
            }
            return(table);
        }
Exemple #5
0
        /// <summary>
        /// 直接转换
        /// </summary>
        /// <param name="file"></param>
        /// <returns></returns>
        public ObjectTableStorage Build(RinexObsFile file)
        {
            ObjectTableStorage table = new ObjectTableStorage();

            table.Name = file.SiteInfo.SiteName + file.StartTime.DayOfYear.ToString("000") + file.StartTime.Hour.ToString("0") + "." + file.StartTime.SubYear + "O" + FileNames.TextExcelFileExtension;
            foreach (var epochInfo in file)
            {
                ObsToRow(table, epochInfo);
            }
            return(table);
        }
Exemple #6
0
        private void button_run_Click(object sender, EventArgs e)
        {
            var           outDir     = directorySelectionControl_outputDir.Path;
            var           outVersion = namedFloatControl_outVersion.GetValue();
            List <string> files      = new List <string>(fileOpenControl_inputs.FilePathes);

            if (files.Count == 0)
            {
                Geo.Utils.FormUtil.ShowWarningMessageBox("巧妇难为无米之炊!");
                return;
            }
            progressBarComponent1.InitProcess(files.Count);
            string currentSiteName = null;

            RinexObsFile currentFile     = null;
            string       readiedFilePath = null;

            foreach (var path in files)
            {
                progressBarComponent1.PerformProcessStep();
                var siteName = Path.GetFileName(path).Substring(0, 4);
                if (currentSiteName == null)
                {
                    currentSiteName = siteName;
                }

                if (!String.Equals(currentSiteName, siteName, StringComparison.CurrentCultureIgnoreCase))
                {
                    OutputFile(outDir, outVersion, currentSiteName, currentFile, readiedFilePath);

                    currentSiteName = siteName;
                    currentFile     = null;
                }

                RinexObsFile file = new RinexObsFileReader(path, true).ReadObsFile();

                readiedFilePath = path;//存储刚刚读取的路径,用户获取后缀名
                if (currentFile == null)
                {
                    currentFile = file;
                }
                else//拼接
                {
                    currentFile.Add(file);
                }
            }
            OutputFile(outDir, outVersion, currentSiteName, currentFile, readiedFilePath);
            currentFile = null;

            progressBarComponent1.Full();

            Geo.Utils.FormUtil.ShowOkAndOpenDirectory(outDir);
        }
Exemple #7
0
        /// <summary>
        /// 输出
        /// </summary>
        /// <param name="outOPath"></param>
        /// <param name="oFile"></param>
        private void OutputRinexFile(string outOPath, RinexObsFile oFile)
        {
            if (!outOPath.Last().ToString().Equals("o", StringComparison.CurrentCultureIgnoreCase))
            {
                outOPath += "." + oFile.StartTime.SubYear + "o";
            }

            RinexObsFileWriter writer = new RinexObsFileWriter(outOPath);

            writer.Write(oFile);
            writer.Flush();
            writer.Dispose();
        }
        static public ObjectTableStorage GetLiCycleSlipTable(RinexObsFile ObsFile, double maxDiffer = 1)
        {
            var    table     = new ObjectTableStorage("Li Cycle Slips Of Sats of " + ObsFile.SiteInfo.SiteName);
            double interval  = ObsFile.Header.Interval;
            var    lastTimes = new BaseDictionary <SatelliteNumber, Time>();

            var prns = ObsFile.GetPrns();

            foreach (var prn in prns)
            {
                int    index   = 1;
                double lastVal = 0;
                foreach (var epoch in ObsFile)
                {
                    if (epoch.Contains(prn))
                    {
                        var sat = epoch[prn];

                        if (sat.PhaseA == null || sat.PhaseB == null)
                        {
                            lastVal = 0;
                            continue;
                        }

                        if (lastVal == 0)
                        {
                            lastVal = sat.GfValue;
                            continue;
                        }

                        var differ = Math.Abs(sat.GfValue - lastVal);
                        if (differ > maxDiffer)
                        {
                            if (index == 1)
                            {
                                table.NewRow();
                                table.AddItem("Prn", prn.ToString());
                            }
                            //record and reset
                            table.AddItem("Cycle" + (index++), epoch.ReceiverTime);
                        }

                        lastVal = sat.GfValue;
                    }
                }
            }

            return(table);
        }
Exemple #9
0
        /// <summary>
        /// 读取
        /// </summary>
        /// <returns></returns>
        public RinexObsFile Read()
        {
            ObjectTableReader reader = new ObjectTableReader(Path);

            Table = reader.Read();

            RinexObsFile obsFile = new RinexObsFile();

            obsFile.Header = TableToRinexObsFileBuilder.BuidHeader(Table);
            var indexColName = Table.GetIndexColName();

            foreach (var row in Table.BufferedValues)
            {
                obsFile.Add(TableToRinexObsFileBuilder.BuildObs(row, indexColName));
            }
            return(obsFile);
        }
Exemple #10
0
        public static ObjectTableStorage GetSatVisiblityTable(RinexObsFile ObsFile)
        {
            var    table     = new ObjectTableStorage("Visiblity Of Sats of " + ObsFile.SiteInfo.SiteName);
            double interval  = ObsFile.Header.Interval;
            var    lastTimes = new BaseDictionary <SatelliteNumber, Time>();

            var prns = ObsFile.GetPrns();

            foreach (var prn in prns)
            {
                Time lastTime    = null;
                Time firstTime   = null;
                int  periodIndex = 1;
                table.NewRow();
                table.AddItem("Prn", prn.ToString());
                foreach (var epoch in ObsFile)
                {
                    if (epoch.Contains(prn))
                    {
                        if (firstTime == null)
                        {
                            lastTime  = epoch.ReceiverTime;
                            firstTime = epoch.ReceiverTime;
                        }

                        if (epoch.ReceiverTime - lastTime > interval + 0.001)
                        {
                            TimePeriod timePeriod = new TimePeriod(firstTime, lastTime);
                            table.AddItem("Period" + (periodIndex++), timePeriod.ToString());

                            firstTime = null;
                        }

                        lastTime = epoch.ReceiverTime;
                    }
                }
                if (firstTime != null)
                {
                    TimePeriod timePeriod = new TimePeriod(firstTime, lastTime);
                    table.AddItem("Period" + (periodIndex++), timePeriod.ToString());
                    firstTime = null;
                }
            }

            return(table);
        }
Exemple #11
0
        /// <summary>
        /// 创建RINEX观测文件
        /// </summary>
        /// <returns></returns>
        private static RinexObsFile CreateRinexObsFile()
        {
            RinexObsFile oFile = new RinexObsFile();

            oFile.Header = new RinexObsFileHeader()
            {
                Version = 2.11
            };
            oFile.Header.ObsCodes = new Dictionary <SatelliteType, List <string> >();
            var codes = new List <String>()
            {
                "C1", "L1", "S1", "D1"
            };

            oFile.Header.ObsCodes[SatelliteType.M] = codes;
            oFile.Header.ObsCodes[SatelliteType.G] = codes;
            oFile.Header.ObsCodes[SatelliteType.R] = codes;
            oFile.Header.ObsCodes[SatelliteType.C] = codes;
            oFile.Header.MarkerName = "AndroidPhone";
            return(oFile);
        }
Exemple #12
0
        private void CombineFilesInOneSite(int keyCount, string outDir, double outVersion, List <string> oneSiteFiles)
        {
            RinexObsFile currentFile     = null;
            string       readiedFilePath = null;
            string       currentSiteName = null;

            oneSiteFiles.Sort();
            foreach (var path in oneSiteFiles)
            {
                var siteName = Path.GetFileName(path).Substring(0, keyCount);
                if (currentSiteName == null)
                {
                    currentSiteName = siteName;
                }

                if (!String.Equals(currentSiteName, siteName, StringComparison.CurrentCultureIgnoreCase))
                {
                    OutputFile(outDir, outVersion, currentSiteName, currentFile, readiedFilePath);

                    currentSiteName = siteName;
                    currentFile     = null;
                }

                RinexObsFile file = new RinexObsFileReader(path, true).ReadObsFile();

                readiedFilePath = path;//存储刚刚读取的路径,用户获取后缀名
                if (currentFile == null)
                {
                    currentFile = file;
                }
                else//拼接
                {
                    currentFile.Add(file);
                }
            }
            OutputFile(outDir, outVersion, currentSiteName, currentFile, readiedFilePath);
            currentFile = null;
        }
Exemple #13
0
        private static void OutputFile(string outDir, double outVersion, string currentSiteName, RinexObsFile currentFile, string readiedFilePath)
        {
            var extension = Path.GetExtension(readiedFilePath);
            RinexFileNameBuilder builder = new RinexFileNameBuilder(outVersion);
            var fileName = builder.Build(currentFile);

            string outputPath = Path.Combine(outDir, fileName);

            using (RinexObsFileWriter writer = new RinexObsFileWriter(outputPath, outVersion))
            {
                writer.Write(currentFile);
            }
        }
Exemple #14
0
        public void DrawVisibility(RinexObsFile ObsFile, float fontSize = 10)
        {
            this.Text = "Visibility of " + ObsFile.Header.SiteName;
            chart1.Series.Clear();
            double interval = ObsFile.Header.Interval;
            var    prns     = ObsFile.GetPrns();
            int    prnIndex = 1;

            foreach (var prn in prns)
            {
                List <DateTime> txData = new List <DateTime>();
                List <int>      tyData = new List <int>();
                foreach (var epoch in ObsFile)
                {
                    if (epoch.Contains(prn))
                    {
                        txData.Add(epoch.ReceiverTime.DateTime);
                        tyData.Add(prnIndex);
                    }
                }

                var series = chart1.Series.Add(prn.ToString());
                //    series.Font = new Font("Times New Roman", 12);
                var color = Color.DarkBlue;

                switch (prn.SatelliteType)
                {
                case SatelliteType.U:
                    break;

                case SatelliteType.G:
                    color = Color.Blue;
                    break;

                case SatelliteType.R:
                    color = Color.DimGray;
                    break;

                case SatelliteType.S:
                    break;

                case SatelliteType.E:
                    color = Color.DarkSeaGreen;
                    break;

                case SatelliteType.C:
                    color = Color.OrangeRed;
                    break;

                case SatelliteType.M:
                    break;

                case SatelliteType.J:
                    break;

                case SatelliteType.D:
                    break;

                case SatelliteType.I:
                    break;

                default:
                    break;
                }
                series.Color = color;
                //    series.IsValueShownAsLabel = true;
                series.IsVisibleInLegend = false;
                series.ChartType         = SeriesChartType.Point;
                series.Points.DataBindXY(txData, tyData);
                series.BorderWidth = 1;

                prnIndex++;
            }

            ChartArea chartArea = chart1.ChartAreas[0];

            //    chartArea.AxisX.Minimum = 0;
            ////      chartArea.AxisX.Maximum = 24 * 60 * 60;
            chartArea.AxisY.Minimum = 0;
            chartArea.AxisY.Maximum = prns.Count + 1;

            //chartArea.AxisX.ScrollBar.IsPositionedInside = true; //滚动条
            //chartArea.AxisX.ScrollBar.Enabled = true;

            chartArea.CursorX.IsUserEnabled          = true; //设置坐标轴可以用鼠标点击放大
            chartArea.CursorX.IsUserSelectionEnabled = true; //用户可以选择从那里放大
                                                             //chartArea.AxisX.Title = "Time/s";  //设置下方横坐标名称,当然AxisX2为上方的横坐标。

            //string Ytitle = null;
            //for (int i = prns.Count - 1; i >= 0; i--)
            //{
            //    Ytitle += prns[i].ToString() + "\r\n";
            //}
            //   chartArea.AxisY.Title = "PRN";// Ytitle; //Y轴的标题名字是对应的卫星编号
            //    chartArea.AxisY.TextOrientation = TextOrientation.Horizontal;
            chartArea.AxisX.IsLabelAutoFit = true;
            //   chartArea.AxisX.LabelStyle.Angle = 90;
            chartArea.AxisX.LabelStyle.Format = "HH:mm";
            chartArea.AxisX.LabelStyle.Font   = new Font("Times New Roman", fontSize);
            //此处无用
            chartArea.AxisY.LabelStyle.Font = new Font("Times New Roman", fontSize);
            chartArea.AxisX.Minimum         = ObsFile.Header.StartTime.DateTime.ToOADate();
            chartArea.AxisX.Maximum         = ObsFile.Header.EndTime.DateTime.ToOADate();

            var    totalHours = (int)(Math.Round(ObsFile.Header.TimePeriod.Span / 3600)); //hour
            double xInterval  = 4 / 24.0;                                                 // 0.0416666667;

            if (totalHours < 1)                                                           //10m
            {
                xInterval = 4 / 24.0 / 6;
            }
            if (totalHours < 10)//30m
            {
                xInterval = 4 / 24.0 / 2;
            }
            chartArea.AxisX.Interval       = xInterval;
            chartArea.AxisY.IsLabelAutoFit = true;
            chartArea.AxisY.Interval       = 1;
            for (int i = 0; i < prns.Count; i++)
            {
                var p = prns[i];

                chartArea.AxisY.CustomLabels.Add(i + 0.5, i + 1.5, p.ToString());//
            }

            chartArea.CursorY.IsUserEnabled          = true; //设置坐标轴可以用鼠标点击放大
            chartArea.CursorY.IsUserSelectionEnabled = true; //用户可以选择从那里放大
        }
        static public ObjectTableStorage GetMp3Table(RinexObsFile ObsFile, FileEphemerisService FileEphemerisService, double maxGfDiffer = 0.15, double maxMwDiffer = 2)
        {
            var           table     = new ObjectTableStorage("Mp2 values of " + ObsFile.SiteInfo.SiteName);
            var           prns      = ObsFile.GetPrns();
            double        interval  = ObsFile.Header.Interval;
            List <double> validData = new List <double>();

            foreach (var prn in prns)
            {
                //if (prn.SatelliteType != SatelliteType.C)
                //{
                //    continue;
                //}
                double                    lastGfVal = 0;
                double                    lastMwVal = 0;
                Time                      lastTime  = null;
                Time                      firstTime = null;
                List <Time>               Times     = new List <Time>();
                List <double>             DataMp3   = new List <double>();
                Dictionary <Time, double> dicMp3    = new Dictionary <Time, double>();

                foreach (var epoch in ObsFile)
                {
                    dicMp3.Add(epoch.ReceiverTime, 0);
                    if (epoch.Contains(prn))
                    {
                        var sat = epoch[prn];
                        if (FileEphemerisService != null)
                        {
                            var eph = FileEphemerisService.Get(sat.Prn, epoch.ReceiverTime);
                            if (eph != null)
                            {
                                var    polar     = CoordTransformer.XyzToGeoPolar(eph.XYZ, ObsFile.Header.ApproxXyz);
                                double elevation = polar.Elevation;
                                if (elevation < 5)
                                {
                                    continue;
                                }
                            }
                        }

                        if (sat.PhaseA == null || sat.RangeA == null || sat.PhaseC == null || sat.RangeC == null)
                        {
                            if (Times.Count > 30)
                            {
                                double averageMp2 = DataMp3.Average();

                                for (int i = 0; i < Times.Count - 1; i++)
                                {
                                    if (dicMp3.ContainsKey(Times[i]))
                                    {
                                        dicMp3[Times[i]] = DataMp3[i] - averageMp2;
                                    }
                                }
                            }
                            lastGfVal = 0;
                            lastMwVal = 0;
                            Times     = new List <Time>();
                            DataMp3   = new List <double>();

                            firstTime = null;
                            // table.AddItem(strEpoch, " ");
                            continue;
                        }

                        if (firstTime == null)
                        {
                            lastTime  = epoch.ReceiverTime;
                            firstTime = epoch.ReceiverTime;
                        }
                        if (lastGfVal == 0 || lastMwVal == 0)
                        {
                            lastGfVal = sat.GfValue;
                            lastMwVal = sat.MwCycle;
                        }
                        var differGf = Math.Abs(sat.GfValue - lastGfVal);
                        var differMw = Math.Abs(sat.MwCycle - lastMwVal);

                        if (epoch.ReceiverTime - lastTime > interval + 0.05 || differGf > maxGfDiffer || differMw > maxMwDiffer || epoch == ObsFile.Last())
                        {
                            double averageMp2 = DataMp3.Average();

                            if (Times.Count > 30) //arc
                            {
                                for (int i = 0; i < Times.Count - 1; i++)
                                {
                                    if (dicMp3.ContainsKey(Times[i]))
                                    {
                                        dicMp3[Times[i]] = DataMp3[i] - averageMp2;
                                    }
                                }
                            }
                            Times     = new List <Time>();
                            DataMp3   = new List <double>();
                            lastGfVal = 0;
                            lastMwVal = 0;
                            firstTime = epoch.ReceiverTime;
                        }
                        Times.Add(epoch.ReceiverTime);
                        DataMp3.Add(sat.Mp3Value);
                        lastTime  = epoch.ReceiverTime;
                        lastGfVal = sat.GfValue;
                        lastMwVal = sat.MwCycle;
                    }
                }
                if (Times.Count > 30) //last arc
                {
                    double averageMp3 = DataMp3.Average();
                    for (int i = 0; i < Times.Count - 1; i++)
                    {
                        if (dicMp3.ContainsKey(Times[i]))
                        {
                            dicMp3[Times[i]] = DataMp3[i] - averageMp3;
                        }
                    }
                }

                table.NewRow();
                table.AddItem("Prn", prn.ToString());

                foreach (var item in dicMp3)
                {
                    string strEpoch = item.Key.Hour.ToString() + ":" + item.Key.Minute.ToString() + ":" + item.Key.Seconds.ToString();
                    if (item.Value != 0)
                    {
                        table.AddItem(strEpoch, item.Value);
                        validData.Add(item.Value);
                    }
                    else
                    {
                        table.AddItem(strEpoch, "");
                    }
                }
            }

            //RMS to evaluate the MP
            //double average = validData.Average();
            //double countData = 0;
            //double countData1 = 0;
            //for (int i = 0; i < validData.Count - 1; i++)
            //{
            //    countData += (validData[i] - average) * (validData[i] - average);
            //    countData1 += validData[i] * validData[i];
            //}

            //double rmsMp = Math.Sqrt(countData / validData.Count);
            //double rmsMp3 = Math.Sqrt(countData1 / validData.Count);

            //table.NewRow();
            //table.AddItem("rmsMp", rmsMp);
            //table.AddItem("rmsMp3", rmsMp3);

            return(table);
        }
Exemple #16
0
        /// <summary>
        /// 转换输出为RINEX文件。
        /// </summary>
        /// <param name="outOPath"></param>
        public override void Run(string outOPath)
        {
            RinexObsFile oFile = Convert();

            OutputRinexFile(outOPath, oFile);
        }