private void button_calculate_Click(object sender, EventArgs e) { CheckAndReadObsFile(); double cutOff = namedFloatControl_satCutoff.GetValue(); SatelliteNumber prn = (SatelliteNumber)this.bindingSource_sat.Current; var F1 = Frequence.GetFrequence(prn, 1); var F2 = Frequence.GetFrequence(prn, 2); var f1 = F1.Value * 1e6;//恢复单位 var f2 = F2.Value * 1e6; double f1f1 = f1 * f1; double f2f2 = f2 * f2; double a = -40.28 * (f2f2 - f1f1) / (f1f1 * f2f2); int smoothWindow = this.namedIntControl_smoothWindow.GetValue(); GlobalIgsGridIonoService ionoService = GlobalIgsGridIonoService.Instance; GlobalIgsGridIonoDcbService ionoDcbService = GlobalIgsGridIonoDcbService.Instance; GlobalIgsEphemerisService ephemerisService = GlobalIgsEphemerisService.Instance; var PhaseSmoothRangeBulider = new NamedCarrierSmoothedRangeBuilderManager(true, smoothWindow, true, IonoDifferCorrectionType.DualFreqCarrier); List <TimedRinexSatObsData> records = ObsFile.GetEpochTimedObservations(prn); ObjectTableStorage table = new ObjectTableStorage(prn + "_硬件延迟"); var firtTime = records[0].Time; double P1_P2sat = ionoDcbService.GetDcb(firtTime, prn).Value *GnssConst.MeterPerNano; double P1_P2recMeter = ionoDcbService.GetDcbMeterForP1(firtTime, Path.GetFileName(ObsPath).Substring(0, 4).ToLower()); var siteXyz = ObsFile.Header.ApproxXyz; progressBarComponent1.InitProcess(records.Count); foreach (var record in records) { progressBarComponent1.PerformProcessStep(); var time = record.Time; var data = record.SatObsData; var waveLenL1 = Frequence.GetFrequenceA(prn, time).WaveLength; var waveLenL2 = Frequence.GetFrequenceB(prn, time).WaveLength; double L1 = data.PhaseA.Value * waveLenL1; double P1 = data.RangeA.Value; double L2 = data.PhaseB != null ? record.SatObsData.PhaseB.Value * waveLenL2 : 0; double P2 = data.RangeB != null ? record.SatObsData.RangeB.Value : 0; var smootherP1 = PhaseSmoothRangeBulider.GetOrCreate("P1"); var smootherP2 = PhaseSmoothRangeBulider.GetOrCreate("P2"); var P1s = smootherP1 .SetReset(data.PhaseA.IsLossLock) .SetRawValue(record.Time, P1, L1, 0) .Build(); var P2s = smootherP2 .SetReset(data.PhaseB.IsLossLock) .SetRawValue(record.Time, P2, L2, 0) .Build(); //var smNew = smoother.GetSmoothedRange(); var eph = ephemerisService.Get(prn, time); if (eph == null) { continue; } var satXyz = eph.XYZ; var polar = Geo.Coordinates.CoordTransformer.XyzToGeoPolar(satXyz, siteXyz, AngleUnit.Degree); if (polar.Elevation < cutOff) { continue; } var cTEC = ionoService.GetSlope(time, siteXyz, satXyz); double ionoRange = a * cTEC.Value * 1e16; // 单位是1e16 double rawDifferP = P1 - P2; double smDifferP = P1s.Value - P2s.Value; //电离层倾斜延迟 double ionoP1 = ionoService.GetSlopeDelayRange(time, siteXyz, satXyz, F1.Value); double ionoP2 = ionoService.GetSlopeDelayRange(time, siteXyz, satXyz, F2.Value); double rawDifferIonoP = ionoP1 - ionoP2; var rawRecDcb = rawDifferP - P1_P2sat - rawDifferIonoP; var smRecDcb = smDifferP - P1_P2sat - rawDifferIonoP; table.NewRow(); table.AddItem("Epoch", record.Time); //table.AddItem("L1", L1); //table.AddItem("L2", L2); //table.AddItem("P1", P1); //table.AddItem("P2", P2); //table.AddItem("P1S", P1s); //table.AddItem("P2S", P2s); table.AddItem("P1-P2", rawDifferP); table.AddItem("SmP1-P2", smDifferP); table.AddItem("IonoDiffer", rawDifferIonoP); table.AddItem("SatDcb", P1_P2sat); //table.AddItem("P1-P2_rec", P1_P2recMeter); table.AddItem("RawRecDcb", rawRecDcb); table.AddItem("SmRecDcb", smRecDcb); } progressBarComponent1.Full(); BindDataSource(table); }
private void button_smoothCurrent_Click(object sender, EventArgs e) { EnableRunButton(false); CheckAndReadObsFile(); ObjectTableManager tableObjectStorages; ObjectTableStorage IonoFitTable; tableObjectStorages = new ObjectTableManager(Setting.TempDirectory); IonoFitTable = tableObjectStorages.AddTable("IonoFit"); DateTime start = DateTime.Now; int bufferSize = namedIntControl_bufferCount.GetValue(); bool isShowPoly = checkBox_showPoly.Checked; PhaseSmoothRangeBulider = BuildPhaseSmoothRangeBulider(); int smoothWindow = this.namedIntControl_smoothWindow.GetValue(); double cutOff = namedFloatControl_satCutoff.GetValue(); bool isShowL1Only = checkBox_isShowL1Only.Checked; SatelliteNumber prn = (SatelliteNumber)this.bindingSource_sat.Current; GlobalIgsGridIonoService ionoService = GlobalIgsGridIonoService.Instance; GlobalIgsGridIonoDcbService ionoDcbService = GlobalIgsGridIonoDcbService.Instance; GlobalIgsEphemerisService ephemerisService = GlobalIgsEphemerisService.Instance; var TimedSmoothValueBuilderManager = new TimedSmoothValueBuilderManager(smoothWindow); List <TimedRinexSatObsData> records = ObsFile.GetEpochTimedObservations(prn); ObjectTableStorage table = new ObjectTableStorage(prn + "_平滑伪距"); var firtTime = records[0].Time; double P1_P2sat = ionoDcbService.GetDcb(firtTime, prn).Value *GnssConst.MeterPerNano; double P1_P2recMeter = ionoDcbService.GetDcbMeterForP1(firtTime, Path.GetFileName(ObsPath).Substring(0, 4).ToLower()); var siteXyz = ObsFile.Header.ApproxXyz; double prevIonoAmbiDcb = 0; double prevIonoAmbiDcbL2 = 0; RinexFreqObsBuilder FreqObsBuilder = new RinexFreqObsBuilder(); var epochSatBuilder = new RinexEpochSatBuilder(FreqObsBuilder); progressBarComponent1.InitProcess(records.Count); BufferedStreamService <TimedRinexSatObsData> bufferStream = new BufferedStreamService <TimedRinexSatObsData>(records, bufferSize); bufferStream.MaterialInputted += BufferStream_MaterialInputted; foreach (var record in bufferStream) { if (record == null) { continue; } progressBarComponent1.PerformProcessStep(); var time = record.Time; var data = record.SatObsData; var eph = ephemerisService.Get(prn, time); if (eph == null) { continue; } var satXyz = eph.XYZ; var polar = Geo.Coordinates.CoordTransformer.XyzToGeoPolar(satXyz, siteXyz, AngleUnit.Degree); if (polar.Elevation < cutOff) { continue; } var waveLenL1 = Frequence.GetFrequence(prn, FrequenceType.A, time).WaveLength; var waveLenL2 = Frequence.GetFrequence(prn, FrequenceType.B, time).WaveLength; double L1 = data.PhaseA.Value * waveLenL1; double P1 = data.RangeA.Value; double L2 = data.PhaseB != null ? record.SatObsData.PhaseB.Value * waveLenL2 : 0; double P2 = data.RangeB != null ? record.SatObsData.RangeB.Value : 0; //扩展 var sat = epochSatBuilder.SetPrn(record.SatObsData.Prn).Build(record.SatObsData); // get => (this.FrequenceA.PhaseRange.Value - this.FrequenceB.PhaseRange.Value) * Frequence.GetIonoAndDcbCoeffL1L2(this.Prn.SatelliteType); //double differIonoL1 = 0; //double differIonoL2 = 0; //if (prevIonoAmbiDcb == 0) //{ // prevIonoAmbiDcb = sat.IonoLenOfL1ByDifferL1L2; // prevIonoAmbiDcbL2 = sat.IonoLenOfL2ByDifferL1L2; //} //differIonoL1 = sat.IonoLenOfL1ByDifferL1L2 - prevIonoAmbiDcb; //differIonoL1 = sat.IonoLenOfL1ByDifferL1L2 - prevIonoAmbiDcb; // L1 = L1 + 2 * differIono; #region 载波相位平滑伪距 var smootherP1 = PhaseSmoothRangeBulider.GetOrCreate("P1"); var smootherP2 = PhaseSmoothRangeBulider.GetOrCreate("P2"); var P1s = smootherP1 .SetReset(data.PhaseA.IsLossLock) .SetRawValue(record.Time, P1, L1, sat.IonoLenOfL1ByDifferL1L2) .Build().Value; IonoFitTable.NewRow(); IonoFitTable.AddItem("Epoch", time); IonoFitTable.AddItem("FittedIonoAndAmbiValue", smootherP1.CurrentRaw.FittedIonoAndAmbiValue); //var test = TestSmoothRangeBuilder.GetOrCreate("Test") // .SetReset(data.PhaseA.IsLossLock) // .SetRawValue(record.Time, P1, L1) // .Build().Value; //var differ = test - P1s; //int iii = 0; var P2s = 0.0; if (!isShowL1Only) { P2s = smootherP2 .SetReset(data.PhaseB.IsLossLock) .SetRawValue(record.Time, P2, L2, sat.IonoLenOfL2ByDifferL1L2) .Build().Value; } #endregion //二次多项式平滑比较 var lsSP1Smoother = TimedSmoothValueBuilderManager.GetOrCreate("P1"); var lsSP2Smoother = TimedSmoothValueBuilderManager.GetOrCreate("P2"); double lsSP1 = 0, lsSP2 = 0; if (isShowPoly) { foreach (var item in bufferStream.MaterialBuffers) { lsSP1Smoother.SetRawValue(item.Time, item.SatObsData.RangeA.Value); lsSP2Smoother.SetRawValue(item.Time, item.SatObsData.RangeB.Value); } if (data.PhaseA.IsLossLock) { lsSP1 = P1; lsSP1Smoother.SetReset(data.PhaseA.IsLossLock); } else { lsSP1 = lsSP1Smoother.SetReset(data.PhaseA.IsLossLock) .SetRawValue(time, P1) .SetSmoothTime(time) .Build(); } if (data.PhaseB.IsLossLock) { lsSP2 = P2; lsSP2Smoother.SetReset(data.PhaseB.IsLossLock); } else { lsSP2 = lsSP2Smoother.SetReset(data.PhaseB.IsLossLock) .SetRawValue(time, P2) .SetSmoothTime(time) .Build(); } } table.NewRow(); table.AddItem("Epoch", record.Time); //table.AddItem("L1", L1); //table.AddItem("L2", L2); table.AddItem("P1", P1); if (!isShowL1Only) { table.AddItem("P2", P2); } table.AddItem("P1S", P1s); if (!isShowL1Only && isShowPoly) { table.AddItem("P2S", P2s); } if (isShowPoly) { table.AddItem("LsP1S", lsSP1); } if (!isShowL1Only) { table.AddItem("LsP2S", lsSP2); } } progressBarComponent1.Full(); BindDataSource(table); EnableRunButton(true); Geo.Winform.TableObjectViewForm form = new Geo.Winform.TableObjectViewForm(IonoFitTable); form.Show(); // tableObjectStorages.WriteAllToFileAndClearBuffer(); var span = DateTime.Now - start;// = DateTime.Now; log.Info("计算完毕,耗时 : " + span); }
private void button_multiSolve_Click(object sender, EventArgs e) { CheckAndReadObsFile(); double cutOff = namedFloatControl_satCutoff.GetValue(); int smoothWindow = this.namedIntControl_smoothWindow.GetValue(); bool isUserRawValue = this.radioButton_isUserRawValue.Checked; bool isUseSphaseSmoothP = this.radioButton_isUsePhaaseSmoothP.Checked; bool isUserPolyFitValue = this.radioButton_isUserPolyFitVal.Checked; var PhaseSmoothRangeBulider = new NamedCarrierSmoothedRangeBuilderManager(true, smoothWindow, true, IonoDifferCorrectionType.DualFreqCarrier); GlobalIgsGridIonoService ionoService = GlobalIgsGridIonoService.Instance; GlobalIgsGridIonoDcbService ionoDcbService = GlobalIgsGridIonoDcbService.Instance; GlobalIgsEphemerisService ephemerisService = GlobalIgsEphemerisService.Instance; ObjectTableStorage table = new ObjectTableStorage(Path.GetFileName(ObsPath) + "_硬件延迟"); var EpochInfoBuilder = new RinexEpochInfoBuilder(ObsFile.Header); var _obsDataSource = new RinexFileObsDataSource(ObsPath); var option = new GnssProcessOption(); var context = DataSourceContext.LoadDefault(option, _obsDataSource); var bufferedStream = new BufferedStreamService <EpochInformation>(_obsDataSource, option.BufferSize); SatTimeInfoManager SatTimeInfoManager = new Gnsser.SatTimeInfoManager(_obsDataSource.ObsInfo.Interval); var CycleReviser = EpochInfoReviseManager.GetDefaultCycleSlipDetectReviser(context, option); var Reviser = new BufferPolyRangeSmoothReviser(option); //EpochInfoReviseManager.GetDefaultEpochInfoReviser(context, option, SatTimeInfoManager); var checker = EpochCheckingManager.GetDefaultCheckers(context, option); int i = -1; var siteXyz = ObsFile.Header.ApproxXyz; progressBarComponent1.InitProcess(ObsFile.Count); foreach (var item in bufferedStream) { i++; progressBarComponent1.PerformProcessStep(); //原始数据检核 var epochInfo = item; //if (!checker.Check(item)) //{ // continue; //} ////数据矫正 if (isUseSphaseSmoothP) //需要周跳探测 { bool result = CycleReviser.Revise(ref epochInfo); if (!result) { continue; } } if (isUserPolyFitValue)//缓存与多项式拟合改正 { Reviser.Buffers = bufferedStream.MaterialBuffers; bool result = Reviser.Revise(ref epochInfo); if (!result) { continue; } } table.NewRow(); table.AddItem("Epoch", epochInfo.ReceiverTime.ToShortTimeString()); //计算伪距平滑值 foreach (var sat in epochInfo) { var prn = sat.Prn; var time = sat.ReceiverTime; var eph = ephemerisService.Get(prn, time); if (eph == null) { continue; } var satXyz = eph.XYZ; var polar = Geo.Coordinates.CoordTransformer.XyzToGeoPolar(satXyz, siteXyz, AngleUnit.Degree); if (polar.Elevation < cutOff) { continue; } double P1_P2sat = ionoDcbService.GetDcb(time, prn).Value *GnssConst.MeterPerNano; // double P1_P2recMeter = ionoDcbService.GetDcbMeterForP1(time, Path.GetFileName(ObsPath).Substring(0, 4).ToLower()); var F1 = sat.FrequenceA.Frequence; // Frequence.GetFrequence(prn, 1, time); var F2 = sat.FrequenceB.Frequence; //Frequence.GetFrequence(prn, 2, time); var f1 = F1.Value * 1e6; //恢复单位 var f2 = F2.Value * 1e6; double f1f1 = f1 * f1; double f2f2 = f2 * f2; double a = -40.28 * (f2f2 - f1f1) / (f1f1 * f2f2); //观测值,或组合值 var P1 = sat.FrequenceA.PseudoRange.Value; var P2 = sat.FrequenceB.PseudoRange.Value; var L1 = sat.FrequenceA.PhaseRange.Value; var L2 = sat.FrequenceB.PhaseRange.Value; double differP = P1 - P2;//raw Value if (isUseSphaseSmoothP) { var smootherP1 = PhaseSmoothRangeBulider.GetOrCreate(prn + "_P1"); var smootherP2 = PhaseSmoothRangeBulider.GetOrCreate(prn + "_P2"); var P1s = smootherP1 .SetReset(sat.IsUnstable) .SetRawValue(sat.ReceiverTime, P1, L1, sat.IonoLenOfL1ByDifferL1L2) .Build(); var P2s = smootherP2 .SetReset(sat.IsUnstable) .SetRawValue(sat.ReceiverTime, P2, L2, sat.IonoLenOfL2ByDifferL1L2) .Build(); differP = P1s.Value - P2s.Value; } if (isUserPolyFitValue) { differP = sat.FrequenceA.PseudoRange.CorrectedValue - sat.FrequenceB.PseudoRange.CorrectedValue; } var cTEC = ionoService.GetSlope(time, siteXyz, satXyz); double ionoRange = a * cTEC.Value * 1e16; // 单位是1e16 double rawDifferP = P1 - P2; double ionoP1 = ionoService.GetSlopeDelayRange(time, siteXyz, satXyz, F1.Value); double ionoP2 = ionoService.GetSlopeDelayRange(time, siteXyz, satXyz, F2.Value); double rawDifferIonoP = ionoP1 - ionoP2; var recDcb = differP - P1_P2sat - rawDifferIonoP; //table.AddItem("L1", L1); //table.AddItem("L2", L2); //table.AddItem("P1", P1); //table.AddItem("P2", P2); //table.AddItem("P1S", P1s); //table.AddItem("P2S", P2s); //table.AddItem("P1-P2", rawDifferP); //table.AddItem("IonoDiffer", rawDifferIonoP); //table.AddItem("SatDcb", P1_P2sat); //table.AddItem("P1-P2_rec", P1_P2recMeter); table.AddItem(prn + "", recDcb); //table.AddItem("SmRecDcb", smRecDcb); //table.AddItem(sat.Prn + "_Raw", rangeVal + ""); //table.AddItem(sat.Prn + "_Smooth", smoothRangeVal + ""); } i++; } progressBarComponent1.Full(); table.EndRow(); this.BindDataSource(table); }