Beispiel #1
0
        /// <summary>
        /// 插值器
        /// </summary>
        /// <param name="prnStr"></param>
        /// <returns></returns>
        private ClockInterpolator GetClockInterpolator(string prnStr)
        {
            if (clockInterpolators.ContainsKey(prnStr))
            {
                return(clockInterpolators[prnStr]);
            }
            lock (locker2)
            {
                if (clockInterpolators.ContainsKey(prnStr))
                {
                    return(clockInterpolators[prnStr]);
                }
                if (SatelliteNumber.IsPrn(prnStr))
                {
                    var prn   = SatelliteNumber.Parse(prnStr);
                    var items = ClockFile.Get(prn);
                    if (items == null || items.Count == 0)
                    {
                        return(null);
                    }

                    var inter = new ClockInterpolator(items.Values);
                    clockInterpolators.TryAdd(prnStr, inter);
                    return(inter);
                }
            }

            return(null);
        }
Beispiel #2
0
        private void button_read_Click(object sender, EventArgs e)
        {
            string clkPath = this.textBox_Path.Text;
            string sp3Path = this.textBox_sp3Path.Text;

            if (!File.Exists(clkPath) || !File.Exists(sp3Path))
            {
                MessageBox.Show("指定文件不存在!"); return;
            }

            ClockFileReader reader = new ClockFileReader(clkPath, false);

            _clockFile = reader.ReadAll();
            if (_clockFile.ClockCount == 0)
            {
                return;
            }


            sp3File = new SingleSp3FileEphService(sp3Path);

            this.dateTimePicker_from.Value = _clockFile.First.First().Time.DateTime;
            this.dateTimePicker_to.Value   = this.dateTimePicker_from.Value + TimeSpan.FromHours(6);

            List <String> prns = new List <string>();

            foreach (SatelliteNumber prn in _clockFile.Header.PrnList)
            {
                prns.Add(prn.ToString());
            }
            this.comboBox_name.DataSource = prns;

            this.bindingSource_clk.DataSource = _clockFile.AllItems;
            this.bindingSource_sp3.DataSource = sp3File.Gets();
        }
Beispiel #3
0
        private void button_filter_Click(object sender, EventArgs e)
        {
            if (this.comboBox_name.SelectedItem == null)
            {
                MessageBox.Show("请先读取数据。"); return;;
            }
            string name = this.comboBox_name.SelectedItem.ToString();

            ClockEstimationFrom            = this.dateTimePicker_from.Value;
            ClockEstimationTo              = this.dateTimePicker_to.Value;
            this.bindingSource1.DataSource = ClockFile.GetClockItems(name, new Time(ClockEstimationFrom), new Time(ClockEstimationTo));
        }
        private void button_export_Click(object sender, EventArgs e)
        {
            bool fillWithZero = checkBox1.Checked;
            var  directory    = this.directorySelectionControl1.Path;

            Geo.Utils.FileUtil.CheckOrCreateDirectory(directory);
            var prns = SatelliteNumber.ParsePRNsBySplliter(textBox_satPrns.Text, new char[] { ',' });

            string[] pathes = this.textBox_Pathes.Lines;
            foreach (var sp3item in pathes)
            {
                ClockFileReader r = new ClockFileReader(sp3item, false);
                ClockFile = r.ReadAll();
                string PredictedClockBiasPath = this.textBox_predictedresultPath.ToString();

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

                GetPredictedClockBias(PredictedClockBiasPath);
                ClockFileofPredicted        = new ClockFile();
                ClockFileofPredicted.Header = ClockFile.Header;

                foreach (var item in ClockFile.Data.Values)
                {
                    foreach (var clock in item)
                    {
                        if (clock.ClockType == Data.Rinex.ClockType.Satellite)
                        {
                            clockbias section = ClockBias[clock.Time];
                            clock.ClockBias = section.sat[clock.Prn];
                            ClockFileofPredicted.GetClockItems(clock.Name).Add(clock);
                        }
                        else
                        {
                            ClockFileofPredicted.GetClockItems(clock.Name).Add(clock);
                        }
                    }
                }

                ClockFileofPredicted.Header.Comments.Add("Processd by Gnsser");
                ClockFileofPredicted.Header.Comments.Add("Predicted clock bias replace original precise data");
                var             path            = Path.Combine(directory, "P" + r.Name + ".clk");
                ClockFileWriter ClockFileWriter = new ClockFileWriter(sp3item, ClockFileofPredicted);
                ClockFileWriter.SaveToFile();
                ClockFile.Clear();
            }
            Geo.Utils.FileUtil.OpenDirectory(directory);
        }
Beispiel #5
0
        private void button_read_Click(object sender, EventArgs e)
        {
            string path = this.textBox_Path.Text;

            if (!File.Exists(path))
            {
                MessageBox.Show("指定文件不存在!"); return;
            }
            ClockFileReader reader = new ClockFileReader(path, false);

            _clockFile = reader.ReadAll();
            if (_clockFile.ClockCount == 0)
            {
                return;
            }

            this.dateTimePicker_from.Value = _clockFile.First.First().Time.DateTime;
            this.dateTimePicker_to.Value   = this.dateTimePicker_from.Value + TimeSpan.FromHours(6);

            this.comboBox_name.DataSource = _clockFile.Names;

            this.bindingSource1.DataSource = _clockFile.AllItems; //.ClockDics.Values;
        }
Beispiel #6
0
        /// <summary>
        /// 插值器
        /// </summary>
        /// <param name="prnStr"></param>
        /// <returns></returns>
        private ClockInterpolator GetClockInterpolator(string prnStr)
        {
            if (clockInterpolators.ContainsKey(prnStr))
            {
                return(clockInterpolators[prnStr]);
            }
            lock (locker2)
            {
                if (clockInterpolators.ContainsKey(prnStr))
                {
                    return(clockInterpolators[prnStr]);
                }

                var items = ClockFile.GetClockItems(prnStr);
                if (items == null || items.Count == 0)
                {
                    return(null);
                }

                var inter = new ClockInterpolator(items);
                clockInterpolators.TryAdd(prnStr, inter);
                return(inter);
            }
        }
Beispiel #7
0
        /// <summary>
        /// 指定卫星的所有钟差序列
        /// </summary>
        /// <param name="prn"></param>
        /// <returns></returns>
        public List <AtomicClock> GetClocks(SatelliteNumber prn)
        {
            string prnStr = prn.ToString();

            return(ClockFile.GetClockItems(prnStr));
        }
Beispiel #8
0
 /// <summary>
 /// 获取指定卫星在时段内的序列
 /// </summary>
 /// <param name="prn"></param>
 /// <param name="timeStart"></param>
 /// <param name="timeEnd"></param>
 /// <returns></returns>
 public override List <AtomicClock> Gets(SatelliteNumber prn, Time timeStart, Time timeEnd)
 {
     return(ClockFile.GetClockItems(prn, timeStart, timeEnd));
 }
Beispiel #9
0
        /// <summary>
        /// 指定卫星的所有钟差序列
        /// </summary>
        /// <param name="prn"></param>
        /// <returns></returns>
        public List <SimpleClockBias> GetClocks(SatelliteNumber prn)
        {
            string prnStr = prn.ToString();

            return(ClockFile.GetClockItems(prnStr));
        }
Beispiel #10
0
 /// <summary>
 /// 获取指定卫星在时段内的序列
 /// </summary>
 /// <param name="prn"></param>
 /// <param name="timeStart"></param>
 /// <param name="timeEnd"></param>
 /// <returns></returns>
 public override List <SimpleClockBias> Gets(SatelliteNumber prn, Time timeStart, Time timeEnd)
 {
     return(ClockFile.GetClockItems(prn, timeStart, timeEnd));
 }
Beispiel #11
0
 /// <summary>
 /// 指定卫星的所有钟差序列
 /// </summary>
 /// <param name="prn"></param>
 /// <returns></returns>
 public List <SimpleClockBias> GetClocks(SatelliteNumber prn)
 {
     return(ClockFile.Get(prn).Values);
 }
Beispiel #12
0
 /// <summary>
 /// 获取指定卫星在时段内的序列
 /// </summary>
 /// <param name="prn"></param>
 /// <param name="timeStart"></param>
 /// <param name="timeEnd"></param>
 /// <returns></returns>
 public override List <SimpleClockBias> Gets(SatelliteNumber prn, Time timeStart, Time timeEnd)
 {
     return(ClockFile.Get(prn).Values.FindAll(m => m.Time > timeStart && m.Time < timeEnd));
 }
Beispiel #13
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);

            #region 读取钟差估计结果
            Time start0   = Time.MaxValue;
            Time end0     = Time.MinValue;
            bool IsNotEnd = true;
            ClockFileOfClockEstimation       = new ClockFile();
            ClockFileOfClockEstimationResult = new ClockFile();
            string[] tmp0 = null;
            using (StreamReader sr = new StreamReader(this.textBox_Pathes.Text))
            {
                string line = sr.ReadLine();
                tmp0 = SplitByBlank(line);
                while (IsNotEnd)
                {
                    line = sr.ReadLine();
                    if (line == null || line == "")
                    {
                        break;
                    }
                    if (line.Length > 10000)
                    {
                        throw new Exception("Line too long");
                    }
                    if (line.Length == 0)
                    {
                        IsNotEnd = false;
                    }
                    //string[] tmp = StringUtil.SplitByBlank(line);
                    string[] tmp = SplitByBlank(line);
                    for (int i = 0; i < tmp.Length / 2; i++)
                    {
                        AtomicClock item = new AtomicClock();
                        if (tmp[2 * i + 2] == " ")
                        {
                            item.ClockBias = 9999999999;
                            item.Time      = Time.Parse(tmp[0]);
                            item.Prn       = SatelliteNumber.TryParse(tmp0[2 * i + 1]);
                            item.ClockType = Data.Rinex.ClockType.Satellite;
                            item.Name      = item.Prn.ToString();
                            ClockFileOfClockEstimation.GetClockItems(item.Prn).Add(item);
                            continue;
                        }

                        item.ClockBias = double.Parse(tmp[2 * i + 2]) / 1E9;
                        item.Time      = Time.Parse(tmp[0]);
                        //key.Time.Seconds += 1;
                        item.Prn       = SatelliteNumber.TryParse(tmp0[2 * i + 1]);
                        item.ClockType = Data.Rinex.ClockType.Satellite;
                        item.Name      = item.Prn.ToString();
                        ClockFileOfClockEstimation.GetClockItems(item.Prn).Add(item);
                        if (item.Time < start0)
                        {
                            start0 = item.Time;
                        }
                        if (item.Time > end0)
                        {
                            end0 = item.Time;
                        }
                    }
                }
            }

            ClockFileOfClockEstimation.TimePeriod = new BufferedTimePeriod(start0, end0);
            #endregion
            this.bindingSource1.DataSource = ClockFileOfClockEstimation.AllItems;
            this.comboBox_name.DataSource  = ClockFileOfClockEstimation.Names;
            #region 读取钟差文件
            string          path   = this.textBox1.Text;
            ClockFileReader reader = new ClockFileReader(path, false);
            ClockFile = reader.ReadAll();
            if (ClockFile.ClockCount == 0)
            {
                return;
            }
            #endregion
            #region 两个文件结果做差
            //int allSec = (int)ClockFile.TimePeriod.Span;
            //Time end = ClockFile.TimePeriod.End + intervalSec;
            //Dictionary<string, clock> V1 = new Dictionary<string, clock>();

            //double[] V = new double[32];
            //double[] x = new double[32];
            //clock q = new clock();

            //for (int j = 1; j < tmp0.Length; j++)
            //{
            //    int count = 0;
            //    var a1 = ClockFileOfClockEstimation.GetClockItems(tmp0[j], ClockFileOfClockEstimation.TimePeriod.Start, ClockFileOfClockEstimation.TimePeriod.End);
            //    var a2 = ClockFile.GetClockItems(tmp0[j], ClockFile.TimePeriod.Start, ClockFile.TimePeriod.End);
            //    for (int k = 0, k1 = 0; k < a1.Count; k++)
            //    {
            //        if (a1[k].Time == a2[k1].Time)
            //        {
            //            V[j] = a1[k].ClockBias - a2[k1].ClockBias;
            //            x[j] += V[j] * V[j];
            //            count++;
            //            k++;
            //            k1++;
            //            q.Time.Add(a1[k].Time.ToString());
            //            q.clk.Add(V[j]);
            //        }
            //        else if (a1[k].Time < a2[k1].Time)
            //            k++;
            //        else if (a1[k].Time > a2[k1].Time)
            //            k1++;
            //    }
            //    q.Time.Add("rms");
            //    q.clk.Add(Math.Sqrt(x[j] / count));

            //    V1.Add(tmp0[j], q);
            //}
            #endregion
            double interval = double.Parse(this.textBox_interval.Text);
            ClockEstimationFrom = this.dateTimePicker_from.Value;
            ClockEstimationTo   = this.dateTimePicker_to.Value;
            List <AtomicClock> ClockEstimationDataSource = new List <AtomicClock>();
            List <AtomicClock> ClockFileDataSource       = new List <AtomicClock>();
            List <AtomicClock> FitedResult = new List <AtomicClock>();
            //foreach (var key in ClockFileOfClockEstimation.Names)
            //{
            //    ClockEstimationDataSource = ClockFileOfClockEstimation.GetClockItems(key, new Time(ClockEstimationFrom), new Time(ClockEstimationTo));
            //    ClockFileDataSource = ClockFile.GetClockItems(key, new Time(ClockFileFrom), new Time(ClockFileTo));
            //    //ClockInterpolator interp = new ClockInterpolator(ClockEstimationDataSource);

            //    ClockEstimationDataSource = ClockFileOfClockEstimation.GetClockItems(key);
            //    ClockFileDataSource = ClockFile.GetClockItems(key);
            //    ClockInterpolator interp = new ClockInterpolator(ClockEstimationDataSource,11);
            //    List<AtomicClock> fitedResult = new List<AtomicClock>();
            //    interval = interval * 60;
            //    double cacuCount = (end0.TickTime - start0.TickTime).TotalSeconds / interval;
            //    for (int xi = 0; xi <= cacuCount-1; xi++)
            //    {
            //        Time gpsTime = ClockFileDataSource[0].Time + interval * xi;
            //        if (gpsTime > interp.MaxAvailableTime) break;
            //        fitedResult.Add(interp.GetAtomicClock(gpsTime));
            //    }
            //    for (int i = 0; i < fitedResult.Count; i++)
            //    {
            //        fitedResult[i].ClockBias -= ClockFileDataSource[i].ClockBias;
            //        FitedResult.Add(fitedResult[i]);
            //    }

            //}

            foreach (var item in ClockFileOfClockEstimation.Names)
            {
                ClockEstimationDataSource = ClockFileOfClockEstimation.GetClockItems(item);
                ClockFileDataSource       = ClockFile.GetClockItems(item);
                List <AtomicClock> fitedResult = new List <AtomicClock>();
                foreach (var item1 in ClockEstimationDataSource)
                {
                    var ss = ClockFile.GetClockItem(item, item1.Time);
                    if (ss == null || item1.ClockBias == 9999999999.0)
                    {
                        continue;
                    }
                    item1.ClockBias -= ss.ClockBias;
                    FitedResult.Add(item1);
                    fitedResult.Add(item1);
                }
                ClockFileOfClockEstimationResult.Add(item, fitedResult);
            }
            ClockFileOfClockEstimation.Header                 = ClockFile.Header;
            ClockFileOfClockEstimation.Header.SourceName      = "CE" + ClockFileOfClockEstimation.Header.SourceName;
            ClockFileOfClockEstimation.Header.CreationDate    = DateTime.Now.ToString();
            ClockFileOfClockEstimation.Header.CreationAgence  = "Gnsser";
            ClockFileOfClockEstimation.Header.ANALYSIS_CENTER = "Gnsser";
            ClockFileOfClockEstimation.Header.CreationProgram = "Gnsser";
            ClockFileOfClockEstimation.Header.TYPES_OF_DATA.Clear();
            ClockFileOfClockEstimation.Header.TYPES_OF_DATA.Add("AS");
            ClockFileOfClockEstimation.Header.COUNT_OF_TYPES_OF_DATA = 1;
            ClockFileOfClockEstimation.Header.ClockSolnStations.Clear();
            ClockFileOfClockEstimationResult.Header = ClockFileOfClockEstimation.Header;
            var             resutlPath      = Path.Combine("D:\\Temp\\ClockEstimation1\\", ClockFileOfClockEstimation.Header.SourceName);
            var             errorResutlPath = Path.Combine("D:\\Temp\\ClockEstimation1\\", "error" + ClockFileOfClockEstimation.Header.SourceName);
            ClockFileWriter ClockFileWriter = new ClockFileWriter(resutlPath, ClockFileOfClockEstimation);
            ClockFileWriter.SaveToFile();
            ClockFileWriter errorClockFileWriter = new ClockFileWriter(errorResutlPath, ClockFileOfClockEstimationResult);
            errorClockFileWriter.SaveToFile();
            this.bindingSource1.DataSource = FitedResult;
            TableTextManager = new ObjectTableManager();


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

            var             paramTable = TableTextManager.GetOrCreate(ClockFileOfClockEstimationResult.Name + "Params" + Time.UtcNow.DateTime.ToString("yyyy-MM-dd_HH_mm_ss"));
            int             count      = 0;
            SatelliteNumber prnIndex   = new SatelliteNumber();
            foreach (var item in ClockFileOfClockEstimationResult)
            {
                if (item.Count > count)
                {
                    count = item.Count; prnIndex = item[0].Prn;
                }
            }

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

                    var ss = ClockFileOfClockEstimationResult.GetClockItem(item1, item.Time);
                    if (ss == null)
                    {
                        continue;
                    }
                    DoubleDiffer = item.ClockBias - ss.ClockBias;
                    paramTable.AddItem(ss.Prn + "-" + item.Prn, DoubleDiffer * 1E9);
                }
                paramTable.EndRow();
            }
            TableTextManager.WriteAllToFileAndCloseStream();
            Geo.Utils.FileUtil.OpenDirectory("D:\\Temp\\ClockEstimation1\\");
        }
Beispiel #14
0
 /// <summary>
 /// 指定卫星的所有钟差序列
 /// </summary>
 /// <param name="prn"></param>
 /// <returns></returns>
 public List <AtomicClock> GetClocks(SatelliteNumber prn)
 {
     return(ClockFile.Get(prn).Values);
 }
Beispiel #15
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\\");
        }
Beispiel #17
0
        private void button_export_Click(object sender, EventArgs e)
        {
            bool fillWithZero = checkBox1.Checked;
            var  intervalSec  = int.Parse(textBox_interval.Text) * 60;
            var  directory    = this.directorySelectionControl1.Path;

            Geo.Utils.FileUtil.CheckOrCreateDirectory(directory);
            var ModelLength     = (int)(24 * double.Parse(textBox_ModelLength.Text)) * 3600 / intervalSec;
            var PredictedLength = (int)(24 * double.Parse(textBox_PredictedLength.Text)) * 3600 / intervalSec;
            var PredictedNumber = int.Parse(textBox_PredictedNumber.Text);

            var prns = SatelliteNumber.ParsePRNsBySplliter(textBox_satPrns.Text, new char[] { ',' });
            Dictionary <SatelliteNumber, StreamWriter> prnWriters = new Dictionary <SatelliteNumber, StreamWriter>();

            foreach (var item in prns)
            {
                var path = Path.Combine(directory, item.ToString() + ".xls");
                prnWriters[item] = new StreamWriter(new FileStream(path, FileMode.Create));
            }

            string[] pathes = this.textBox_Pathes.Lines;
            coll = new MultiFileClockService(pathes);

            int                      allSec    = (int)coll.TimePeriod.Span;
            Time                     end       = coll.TimePeriod.End + intervalSec;
            List <double>            list      = new List <double>();
            Dictionary <string, SSE> ListOfSSE = new Dictionary <string, SSE>();
            string                   approach  = null;

            #region 逐个卫星进行钟差预报
            clkofPredicted                = new ClockFile();
            clkofPredicted.Header         = new ClockFileHeader();
            clkofPredicted.Header.PrnList = new List <SatelliteNumber>();
            for (int number = 0; number < PredictedNumber; number++)
            {
                foreach (var prn in prns)
                {
                    var writer = prnWriters[prn];
                    //List<double> colName = new List<double>();
                    var         all          = coll.Gets(prn, coll.TimePeriod.Start, end);
                    ArrayMatrix OringalClock = new ArrayMatrix(ModelLength, 1);
                    ArrayMatrix CompareClock = new ArrayMatrix(PredictedLength, 1);

                    Time StartOfModel     = coll.TimePeriod.Start;
                    Time EndOfModel       = StartOfModel + (ModelLength - 1) * intervalSec;
                    Time StartOfPredicted = EndOfModel + intervalSec;
                    Time EndOfPredicted   = StartOfPredicted + (PredictedLength - 1) * intervalSec;

                    int DataNumberIndex          = 0;
                    int ModelDataNumberIndex     = 0;
                    int PredictedDataNumberIndex = 0;
                    GetClockData(fillWithZero, intervalSec, ModelLength, PredictedLength, end, prn, all, OringalClock, CompareClock, number, DataNumberIndex, ModelDataNumberIndex, PredictedDataNumberIndex);
                    if (IsNeedFilling)
                    {
                        QuadraticPolynomialModel Filling = new QuadraticPolynomialModel();
                        Filling.FillingCalculate(OringalClock, intervalSec);
                    }


                    ArrayMatrix Data = null;
                    if (radioButton_QP.Checked)
                    {
                        approach = "QP"; QuadraticPolynomialModel QuadraticPolynomialModel = new QuadraticPolynomialModel(); QuadraticPolynomialModel.Calculate(OringalClock, CompareClock, intervalSec); Data = QuadraticPolynomialModel.PredictedData;
                    }
                    if (radioButton_QPT1.Checked)
                    {
                        approach = "QPT1"; QuadraticPolynomialT1 QuadraticPolynomialT1 = new QuadraticPolynomialT1(); QuadraticPolynomialT1.Calculate(OringalClock, CompareClock, intervalSec); list.Add(QuadraticPolynomialT1.PredictedRms); Data = QuadraticPolynomialT1.PredictedData;
                    }
                    if (radioButton_QPT2.Checked)
                    {
                        approach = "QPT2"; QuadraticPolynomialT2 QuadraticPolynomialT2 = new QuadraticPolynomialT2(); QuadraticPolynomialT2.Calculate(OringalClock, CompareClock, intervalSec, prn); list.Add(QuadraticPolynomialT2.PredictedRms); Data = QuadraticPolynomialT2.PredictedData;
                    }
                    if (radioButton_QPT3.Checked)
                    {
                        approach = "QPT3"; QuadraticPolynomialT3 QuadraticPolynomialT3 = new QuadraticPolynomialT3(); QuadraticPolynomialT3.Calculate(OringalClock, CompareClock, intervalSec); list.Add(QuadraticPolynomialT3.PredictedRms); Data = QuadraticPolynomialT3.PredictedData;
                    }
                    if (radioButton_QPT4.Checked)
                    {
                        approach = "QPT4"; QuadraticPolynomialT4 QuadraticPolynomialT4 = new QuadraticPolynomialT4(); QuadraticPolynomialT4.Calculate(OringalClock, CompareClock, intervalSec); list.Add(QuadraticPolynomialT4.PredictedRms); Data = QuadraticPolynomialT4.PredictedData;
                    }
                    if (radioButton_QPGM.Checked)
                    {
                        approach = "QPGM"; QuadraticPolynomialGM QuadraticPolynomialGM = new QuadraticPolynomialGM(); QuadraticPolynomialGM.Calculate(OringalClock, CompareClock, intervalSec); list.Add(QuadraticPolynomialGM.PredictedRms); Data = QuadraticPolynomialGM.PredictedData;
                    }
                    if (radioButton_QPT2GM.Checked)
                    {
                        approach = "QPT2GM"; QuadraticPolynomialT2GM QuadraticPolynomialT2GM = new QuadraticPolynomialT2GM(); QuadraticPolynomialT2GM.Calculate(OringalClock, CompareClock, intervalSec, prn); list.Add(QuadraticPolynomialT2GM.PredictedRms); Data = QuadraticPolynomialT2GM.PredictedData;
                    }
                    if (radioButton_QPT4GM.Checked)
                    {
                        approach = "QPT4GM"; QuadraticPolynomialT4GM QuadraticPolynomialT4GM = new QuadraticPolynomialT4GM(); QuadraticPolynomialT4GM.Calculate(OringalClock, CompareClock, intervalSec); list.Add(QuadraticPolynomialT4GM.PredictedRms); Data = QuadraticPolynomialT4GM.PredictedData;
                    }

                    if (radioButton_LP.Checked)
                    {
                        approach = "LP"; LinearPolynomialModel LinearPolynomialModel = new LinearPolynomialModel(); LinearPolynomialModel.Calculate(OringalClock, CompareClock, intervalSec); list.Add(LinearPolynomialModel.PredictedRms); Data = LinearPolynomialModel.PredictedData;
                    }
                    if (radioButton_DLP.Checked)
                    {
                        approach = "DLP"; DLinearPolynomialModel DLinearPolynomialModel = new DLinearPolynomialModel(); DLinearPolynomialModel.Calculate(OringalClock, CompareClock, intervalSec); list.Add(DLinearPolynomialModel.PredictedRms); Data = DLinearPolynomialModel.PredictedData;
                    }
                    if (radioButton_RobustDLP.Checked)
                    {
                        approach = "RobustDLP";
                        RobustDLinearPolynomial RobustDLinearPolynomial = new RobustDLinearPolynomial();
                        RobustDLinearPolynomial.Calculate(OringalClock, CompareClock, intervalSec);
                        list.Add(RobustDLinearPolynomial.PredictedRms);
                        Data = RobustDLinearPolynomial.PredictedData;
                        SSE a = new SSE();
                        a = GetSSE(RobustDLinearPolynomial);
                        ListOfSSE.Add(prn.ToString() + '-' + number, a);
                    }
                    if (radioButton_RobustLP.Checked)
                    {
                        approach = "RobustLP"; RobustLinearPolynomial RobustLinearPolynomial = new RobustLinearPolynomial(); RobustLinearPolynomial.Calculate(OringalClock, CompareClock, intervalSec); list.Add(RobustLinearPolynomial.PredictedRms); Data = RobustLinearPolynomial.PredictedData;
                    }



                    if (radioButton_GM.Checked)
                    {
                        approach = "GM";
                        ArrayMatrix GMOringalClock1 = new ArrayMatrix(ModelLength, 1);
                        for (int GMIndex = 0; GMIndex < ModelLength; GMIndex++)
                        {
                            GMOringalClock1[GMIndex, 0] = OringalClock[ModelLength - (ModelLength - GMIndex), 0];
                        }
                        GreyModel GreyModel1 = new GreyModel();
                        SSE       a          = new SSE();
                        GreyModel1.Calculate(GMOringalClock1, CompareClock, intervalSec);
                        a = GetSSE(GreyModel1);
                        ListOfSSE.Add(prn.ToString() + '-' + number, a);
                        Data = GreyModel1.PredictedData;
                    }
                    if (radioButton_KFAllan.Checked)
                    {
                        approach = "KFAllan"; KalmanAllan KalmanAllan = new KalmanAllan(); KalmanAllan.Calculate(OringalClock, CompareClock, intervalSec); list.Add(KalmanAllan.PredictedRms); Data = KalmanAllan.PredictedData;
                    }
                    if (radioButton_KFHardamard.Checked)
                    {
                        approach = "KFHardamard"; KalmanHardamard KalmanHardamard = new KalmanHardamard(); KalmanHardamard.Calculate(OringalClock, CompareClock, intervalSec); list.Add(KalmanHardamard.PredictedRms); Data = KalmanHardamard.PredictedData;
                    }
                    if (radioButton_KFReHardamard.Checked)
                    {
                        approach = "KFReHardamard"; KalmanRecursionHardamard KalmanRecursionHardamard = new KalmanRecursionHardamard(); KalmanRecursionHardamard.Calculate(OringalClock, CompareClock, intervalSec); list.Add(KalmanRecursionHardamard.PredictedRms); Data = KalmanRecursionHardamard.PredictedData;
                    }
                    if (radioButton_KFReAllan.Checked)
                    {
                        approach = "KFReAllan"; KalmanRecursionAllan KalmanRecursionAllan = new KalmanRecursionAllan(); KalmanRecursionAllan.Calculate(OringalClock, CompareClock, intervalSec); list.Add(KalmanRecursionAllan.PredictedRms); Data = KalmanRecursionAllan.PredictedData;
                    }
                    for (int i0 = 0; i0 < Data.RowCount; i0++)
                    {
                        AtomicClock sat = new AtomicClock();
                        sat.Prn       = prn;
                        sat.Time      = StartOfPredicted + i0 * intervalSec;
                        sat.ClockBias = Data[i0, 0];
                        sat.ClockType = ClockType.Satellite;
                        if (!(clkofPredicted.Contains(sat.Prn.ToString())))
                        {
                            clkofPredicted.Add(sat.Prn.ToString(), new List <AtomicClock>());
                        }
                        clkofPredicted[sat.Prn.ToString()].Add(sat);
                    }
                    clkofPredicted.Header.PrnList.Add(prn);
                }
                OutputOfPredictedClock(directory, approach, intervalSec);
            }
            #endregion
            OutputOfSSE(directory, ListOfSSE, approach);

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