static BottomLossSample ParseHighFrequencyOutput(TextReader stream, BottomLossSample curPoint) { var splitCharsSpaceEquals = new[] { ' ', '=' }; var splitCharsCommaEquals = new[] { ',', '=' }; var fields = NextLine(stream).Split(splitCharsSpaceEquals, StringSplitOptions.RemoveEmptyEntries); if (fields[0].ToLower() != "lat") throw new FormatException("Error parsing bottom loss results. HFBL output not in expected format (lat)"); var hfLatitude = Math.Round(double.Parse(fields[1]), 4); if (fields[2].ToLower() != "lon") throw new FormatException("Error parsing bottom loss results. HFBL output not in expected format (lon)"); var hfLongitude = Math.Round(double.Parse(fields[3]), 4); if (curPoint == null) curPoint = new BottomLossSample(hfLatitude, hfLongitude, new BottomLossData()); else if (((int)Math.Round(hfLatitude * 10000.0) != (int)Math.Round(curPoint.Latitude * 10000)) && ((int)Math.Round(hfLongitude * 10000.0) != (int)Math.Round(curPoint.Longitude * 10000))) throw new FormatException("Error parsing bottom loss results. Adjacent LFBL and HFBL extractions do not refer to the same point"); fields = NextLine(stream).Split(splitCharsCommaEquals, StringSplitOptions.RemoveEmptyEntries); if (fields[0].Trim().ToUpper() != "HFBL CURVE NUMBER") throw new FormatException("Error parsing bottom loss results. HFBL output not in expected format (HFBL curve number)"); curPoint.Data.CurveNumber = double.Parse(fields[1]); return curPoint; }
static BottomLossSample ParseLowFrequencyOutput(TextReader stream) { var splitCharsSpaceEquals = new[] { ' ', '=' }; //NextLine(stream); var fields = NextLine(stream).Split(splitCharsSpaceEquals, StringSplitOptions.RemoveEmptyEntries); if (fields[0].ToLower() != "latitude") throw new FormatException("Error parsing bottom loss results. LFBL output not in expected format (latitude)"); var lfLatitude = Math.Round(double.Parse(fields[1]), 4); fields = NextLine(stream).Split(splitCharsSpaceEquals, StringSplitOptions.RemoveEmptyEntries); if (fields[0].ToLower() != "longitude") throw new FormatException("Error parsing bottom loss results. LFBL output not in expected format (longitude)"); var lfLongitude = Math.Round(double.Parse(fields[1]), 4); var curPoint = new BottomLossSample(lfLatitude, lfLongitude, new BottomLossData()); NextLine(stream, "---- World 15 Parameter set ----"); var curLine = NextLine(stream); while (!curLine.Contains("Tabular Listing of Parameters")) { fields = curLine.Split(splitCharsSpaceEquals, StringSplitOptions.RemoveEmptyEntries); switch (fields[0].ToUpper()) { case "RATIOD": curPoint.Data.RATIOD = double.Parse(fields[1]); break; case "DLD": curPoint.Data.DLD = double.Parse(fields[1]); break; case "RHOLD": curPoint.Data.RHOLD = double.Parse(fields[1]); break; case "RHOSD": curPoint.Data.RHOSD = double.Parse(fields[1]); break; case "GD": curPoint.Data.GD = double.Parse(fields[1]); break; case "BETAD": curPoint.Data.BETAD = double.Parse(fields[1]); break; case "FKZD": curPoint.Data.FKZD = double.Parse(fields[1]); break; case "FKZP": curPoint.Data.FKZP = double.Parse(fields[1]); break; case "BRFLD": curPoint.Data.BRFLD = double.Parse(fields[1]); break; case "FEXP": curPoint.Data.FEXP = double.Parse(fields[1]); break; case "D2A": curPoint.Data.D2A = double.Parse(fields[1]); break; case "ALF2A": curPoint.Data.ALF2A = double.Parse(fields[1]); break; case "RHO2A": curPoint.Data.RHO2A = double.Parse(fields[1]); break; case "SUBCRIT": curPoint.Data.SUBCRIT = double.Parse(fields[1]); break; case "T2RH": curPoint.Data.T2RH = double.Parse(fields[1]); break; case "SEDTHK_M": curPoint.Data.SEDTHK_M = double.Parse(fields[1]); break; case "SEDTHK_S": curPoint.Data.SEDTHK_S = double.Parse(fields[1]); break; } curLine = NextLine(stream); } return curPoint; }