/// <summary> /// 读取文件 /// </summary> /// <returns></returns> public IonoFile ReadAll(bool isSkipContent = false) { this.Reset(); IonoFile file = new IonoFile(); file.Name = Path.GetFileName(InputPath); // this.ReadHeader(InputPath); file.Header = Header; startTime = Header.EpochOfFirstMap; // Time.MaxValue; endTime = Header.EpochOfLastMap; // Time.MinValue; if (!isSkipContent) { while (this.MoveNext()) { var section = this.Current; if (section != null && section.Count != 0) { file.Add(section); if (section.Time < startTime) { startTime = section.Time; } if (section.Time > endTime) { endTime = section.Time; } } } log.Info("完全加载了电离层文件到内存 " + Name); } file.TimePeriod = new BufferedTimePeriod(startTime, endTime); return(file); }
/// <summary> /// 修改数据源,重新初始化。 /// </summary> /// <param name="IonoFile"></param> public void SetFile(IonoFile IonoFile) { this.IonoFile = IonoFile; this.Init(); }
/// <summary> /// 以文件初始化 /// </summary> /// <param name="IonoFile"></param> public GridIonoFileService(IonoFile IonoFile) { SetFile(IonoFile); }
/// <summary> /// 读取历元对象 /// </summary> /// <param name="Header"></param> /// <param name="StreamReader"></param> /// <returns></returns> private IonoSection ReadSection(IonoFile ionoFile, IonoHeader Header, StreamReader StreamReader) { string line = StreamReader.ReadLine(); var isValueOrRms = (IsStartLineOfEpochMapSection(line)); if (isValueOrRms) { IsCurrentValueOrRms = true; return(ReadSection(ionoFile, Header, StreamReader)); } isValueOrRms = !(IsStartLineOfRmsEpochMapSection(line)); while (!IsFirstLineOfEpochMapSectionWithTime(line)) { line = StreamReader.ReadLine(); if (line == null) { return(null); } if (line.Length > 60 && line.Substring(60).Trim() == RinexHeaderLabel.END_OF_FILE) { return(null); } } IonoSection IonoSection = null; var time = this.ParseTime(line); if (ionoFile.Contains(time)) { IonoSection = ionoFile[time]; } else { IonoSection = new IonoSection() { Header = Header, Time = time }; } while ((line = StreamReader.ReadLine()) != null && IsStartOfRecord(line) && !IsEndLineOfEpochMapSection(line)) { var lat = double.Parse(line.Substring(2, 6)); IonoRecord record = null; if (IonoSection.Contains(lat)) { record = IonoSection[lat]; } else { record = new IonoRecord() { LonRange = new IncreaseValue { Start = double.Parse(line.Substring(8, 6)), End = double.Parse(line.Substring(14, 6)), Increament = double.Parse(line.Substring(20, 6)), }, Height = double.Parse(line.Substring(26, 6)), Lat = lat, }; } double lineCount = Math.Ceiling(record.LonRange.Count / 16.0); List <double> vals = new List <double>(); for (int i = 0; i < lineCount; i++) { line = StreamReader.ReadLine(); var items = StringUtil.Split(line, 5); foreach (var item in items) { if (String.IsNullOrWhiteSpace(item)) { continue; } vals.Add(StringUtil.ParseDouble(item)); } } for (int i = 0; i < vals.Count; i++) { //TEC values in 0.1 TECU(10^16) double val = vals[i]; if (Header.Exponent == 0) { val *= 0.1; } else { val *= Math.Pow(10, Header.Exponent); } var alat = record.LonRange.Start + i * record.LonRange.Increament; if (record.Contains(alat)) { record[alat].Rms = val; } else { record.Add(alat, new RmsedNumeral(val, Double.NaN)); } } IonoSection[lat] = record; } if (isValueOrRms) { ionoFile[time] = IonoSection; return(ReadSection(ionoFile, Header, StreamReader)); } return(IonoSection); }
/// <summary> /// 构造函数 /// </summary> /// <param name="filePath"></param> public IonoReader(string filePath) : base(filePath) { Header = ReadHeader(InputPath); IonoFile = new IonoFile(); }