private void button_export_Click(object sender, EventArgs e) { bool fillWithZero = checkBox1.Checked; int intervalSec = (int)(double.Parse(textBox_interval.Text) * 60); var ModelLength = (int)(24 * double.Parse(textBox_ModelLength.Text)) * 3600 / intervalSec; var PredictedLength = (int)(24 * double.Parse(textBox_PredictedLength.Text)) * 3600 / intervalSec; var directory = this.directorySelectionControl1.Path; Geo.Utils.FileUtil.CheckOrCreateDirectory(directory); var PredictedNumber = int.Parse(textBox_PredictedNumber.Text); string[] pathes = this.textBox_Pathes.Lines; EphemerisDataSourceFactory fac = new EphemerisDataSourceFactory(); coll = new SequentialFileEphemerisService(fac, pathes); int allSec = (int)coll.TimePeriod.Span; Time end = coll.TimePeriod.End + intervalSec; List <SatelliteNumber> prns = new List <SatelliteNumber> (); if (this.IsSelectedPrn.Checked) { prns = SatelliteNumber.ParsePRNsBySplliter(textBox_satPrns.Text, new char[] { ',' }); } else { prns = coll.Prns; } List <double> list = new List <double>(); Dictionary <string, SSE> ListOfSSE = new Dictionary <string, SSE>(); string approach = null; #region 逐个卫星进行钟差预报 for (int number = 0; number < PredictedNumber; number++) { sp3ofPredicted = new Sp3File(); foreach (var prn in prns) { int GlideEpochNumber = int.Parse(this.textBox1_GlideEpochNumber.Text);//滑动历元历元数 ArrayMatrix OringalClock = new ArrayMatrix(ModelLength, 1); ArrayMatrix CompareClock = new ArrayMatrix(PredictedLength, 1); #region 获取建模,比较数据等 Time StartOfModel = coll.TimePeriod.Start + number * GlideEpochNumber * intervalSec; Time EndOfModel = StartOfModel + (ModelLength - 1) * intervalSec; Time StartOfPredicted = EndOfModel + intervalSec; Time EndOfPredicted = StartOfPredicted + (PredictedLength - 1) * intervalSec; var OriginalClockData = coll.Gets(prn, StartOfModel, EndOfModel); var PredictedClockData = coll.Gets(prn, StartOfPredicted, EndOfPredicted); int ModelDataNumberIndex = 0; int PredictedDataNumberIndex = 0; bool IsNeedFilling = false; for (Time i = StartOfModel; i <= EndOfModel; i = i + intervalSec) { var findofmodel = OriginalClockData.SingleOrDefault(m => m.Time == i); if (findofmodel == null) { if (!fillWithZero) { continue; } IsNeedFilling = true; findofmodel = new Ephemeris() { Time = i, Prn = prn }; } OringalClock[ModelDataNumberIndex, 0] = findofmodel.ClockBias; ModelDataNumberIndex++; } if (IsNeedFilling) { QuadraticPolynomialModel Filling = new QuadraticPolynomialModel(); Filling.FillingCalculate(OringalClock, intervalSec); } for (Time i = StartOfPredicted; i <= EndOfPredicted; i = i + intervalSec) { var findofpredicted = PredictedClockData.SingleOrDefault(m => m.Time == i); if (findofpredicted == null) { if (!fillWithZero) { continue; } findofpredicted = new Ephemeris() { Time = i, Prn = prn }; } CompareClock[PredictedDataNumberIndex, 0] = findofpredicted.ClockBias; PredictedDataNumberIndex++; } #endregion 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(8, 1); for (int GMIndex = 0; GMIndex < 8; GMIndex++) { GMOringalClock1[GMIndex, 0] = OringalClock[ModelLength - (8 - 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++) { var sat = new Ephemeris(); sat.Prn = prn; sat.Time = StartOfPredicted + i0 * intervalSec; sat.ClockBias = Data[i0, 0]; if (!(sp3ofPredicted.Contains(sat.Time))) { sp3ofPredicted.Add(sat.Time, new Sp3Section()); } sp3ofPredicted[sat.Time].Add(sat.Prn, sat); } sp3ofPredicted.Prns.Add(prn); } OutputOfPredictedClock(directory, approach, number); } #endregion OutputOfSSE(directory, ListOfSSE, approach); Geo.Utils.FileUtil.OpenDirectory(directory); }
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); }