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); }
/// <summary> /// 提取到表格 /// </summary> /// <returns></returns> public ObjectTableStorage ExtractRowToTable(ObjectTableStorage table) { var list = this.GetSatValueList(); var length = this.GetMaxSpanCount(); for (int i = 0; i < length; i++) { table.NewRow(); table.AddItem("GroupNum", i + 1); var keys = list.Keys; keys.Sort(); string note = ""; foreach (var key in keys) { var val = list.Data[key]; if (val.Count > i) { var rmsVal = val[i]; table.AddItem(key, rmsVal.Value.Value); if (this.Count < 100)//如果文件太多,就节约内存不完全显示。 { note += key + ": " + rmsVal.Key.ToString() + "; "; } } } table.AddItem("Note", note); } 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); }
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); }
/// <summary> /// 读取 /// </summary> /// <returns></returns> public ObjectTableStorage Read() { using (StreamReader reader = new StreamReader(Stream, this.Encoding)) { //记录第一次出现的数据类型,后续依此转换 var name = Path.GetFileNameWithoutExtension(FilePath); ObjectTableStorage storage = new ObjectTableStorage(name); string [] titles = null; var line = ""; int index = -1; while ((line = reader.ReadLine()) != null) { if (String.IsNullOrWhiteSpace(line)) { continue; } index++; if (index == 0)//tittle { titles = line.Split(Spliters, StringSplitOptions); ColTypes.InitNames(titles); continue; } var vals = line.Split(Spliters, StringSplitOptions);//, StringSplitOptions.RemoveEmptyEntries); storage.NewRow(); int length = Math.Min(titles.Length, vals.Length); for (int i = 0; i < length; i++) { var title = titles[i].Trim(); var type = ColTypes[title]; var val = vals[i]; object newVal = null; if (!Appeared.Contains(i)) { type.ValueType = ValueTypeHelper.GetValueType(val); Appeared.Add(i); } if (type.ValueType == ValueType.Unknown) { type.ValueType = ValueTypeHelper.GetValueType(val); } newVal = type.GetValue(val); if (newVal != null)//更新类型 { // type.ValueType = ValueTypeHelper.GetValueType(currentVal); storage.AddItem(title, newVal); } } //storage.AddItem(titles, vals); storage.EndRow(); } return(storage); } }
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); }
/// <summary> /// 转换为表格 /// </summary> /// <returns></returns> public ObjectTableStorage ToTable() { ObjectTableStorage table = new ObjectTableStorage(); int i = 0; foreach (var kv in this.KeyValues) { foreach (var item in kv.Value.KeyValues) { table.NewRow(); table.AddItem("Index", i); table.AddItem("Name", kv.Key); table.AddItem("TimePeriod", item.Key.ToString()); table.AddItem("Value", item.Value.Value.ToString("G8")); table.AddItem("Rms", item.Value.Rms.ToString("G8")); i++; } } return(table); }
/// <summary> /// 通过缓存,按照系统类型,转换为表格,以便统计。 /// </summary> /// <returns></returns> private Dictionary <SatelliteType, ObjectTableStorage> BuildObsCodeTables(Dictionary <SatelliteType, List <string> > ObsCodes) { var SatelliteTypes = ObsCodes.Keys; var buffer = this.BufferedStream.MaterialBuffers; var tables = new Dictionary <SatelliteType, ObjectTableStorage>(); foreach (var epoch in buffer) { foreach (var sat in epoch) { var satType = sat.Prn.SatelliteType; //如果已经过滤则不考虑了 if (!SatelliteTypes.Contains(satType)) { continue; } if (!tables.ContainsKey(satType)) { tables.Add(satType, new ObjectTableStorage()); } ObjectTableStorage table = tables[satType]; table.NewRow(); var types = ObsCodes[satType]; foreach (var obsType in sat.ObsTypes) { if (!types.Contains(obsType)) { continue; } table.AddItem(obsType.ToString(), sat.TryGetValue(obsType)); } table.EndRow(); } } return(tables); }
/// <summary> /// 构建行 /// </summary> /// <param name="table"></param> /// <param name="index"></param> /// <param name="outName"></param> /// <param name="outValue"></param> /// <returns></returns> public void AddDetailRowsToTable(ObjectTableStorage table, ref int index, string outName = null, object outValue = null) { foreach (var topKv in this.Data) //分组遍历 { foreach (var kv in topKv.Value.Data) //一个分组一个数据 { index++; table.NewRow(); table.AddItem("Index", index); if (!String.IsNullOrWhiteSpace(outName) && outValue != null) { table.AddItem(outName, outValue); } table.AddItem("Name", topKv.Key); table.AddItem("Group", kv.Key); table.AddItem("Value", kv.Value.Value); table.AddItem("Rms", kv.Value.StdDev); } } }
private void Process(string subDir, string inputPath) { try { log.Info("processing :" + inputPath); var header = RinexObsFileReader.ReadHeader(inputPath); var siteInfo = header.SiteInfo; var obsInfo = header.ObsInfo; table.NewRow(); if (IsLonLatFirst) { table.AddItem("Lon", siteInfo.ApproxGeoCoord.Lon); table.AddItem("Lat", siteInfo.ApproxGeoCoord.Lat); table.AddItem("Name", siteInfo.SiteName); } else { table.AddItem("Name", siteInfo.SiteName); table.AddItem("Lon", siteInfo.ApproxGeoCoord.Lon); table.AddItem("Lat", siteInfo.ApproxGeoCoord.Lat); } table.AddItem("Height", siteInfo.ApproxGeoCoord.Height); table.AddItem("X", siteInfo.ApproxXyz.X); table.AddItem("Y", siteInfo.ApproxXyz.Y); table.AddItem("Z", siteInfo.ApproxXyz.Z); table.AddItem("ReceiverType", siteInfo.ReceiverType); table.AddItem("ReceiverNumber", siteInfo.ReceiverNumber); table.AddItem("AntennaType", siteInfo.AntennaType); table.AddItem("AntennaNumber", siteInfo.AntennaNumber); } catch (Exception ex) { log.Error("转换出错:\t" + inputPath + "\t, " + ex.Message); } }
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); }