static CylData CorrectRing(CylData uncorrectedData, CylData landPointArr, ProbeDirection probeDirection, double nominalRadius) { try { int polyOrder = 1; bool segmentFit = true; var coeffList = new List <double[]>(); var landPointList = new CylData(uncorrectedData.FileName); landPointList.AddRange(landPointArr); AddSelfPoints(ref landPointList, landPointArr); landPointList.SortByTheta(); var fitData = new FitData(segmentFit, polyOrder); fitData.CalcFitCoeffs(landPointList); var eccData = fitData.CorrectData(uncorrectedData); eccData.SortByTheta(); eccData.MinRadius = GetMinAveRadius(eccData, 5); double rCorrection = uncorrectedData.MinRadius - eccData.MinRadius; var correctedData = CorrectRadius(eccData, rCorrection, probeDirection); return(correctedData); } catch (Exception) { throw; } }
public FitData CalcFit(List <DataPoint> points) { FitData result = new FitData("Power function"); var xdata = points.Select(x => x.X).ToArray(); var ydata = points.Select(x => x.Y).ToArray(); Tuple <double, double> p = Fit.Power(xdata, ydata); result.A = p.Item1; result.B = p.Item2; result.Points = DataPoints(points).ToList(); return(result); //local function for return list of regresion Points[need to C# 8] IEnumerable <DataPoint> DataPoints(List <DataPoint> points) { foreach (var point in points) { yield return(new DataPoint(point.X, result.A * Math.Exp(result.B * point.X))); } } }
public static List <FitDataCollection> Read(string path) { if (!File.Exists(path)) { return(new List <FitDataCollection>()); } XmlDocument doc = new XmlDocument(); doc.Load(path); XmlNode rootNode = doc.GetElementsByTagName("Root")[0]; if (rootNode == null) { return(new List <FitDataCollection>()); } List <FitDataCollection> list = new List <FitDataCollection>(); foreach (XmlNode typeNode in rootNode.ChildNodes) { FitDataCollection collectionItem = new FitDataCollection() { Type = typeNode.Attributes["Type"].Value.ToString(), FitDatas = new List <FitData>() }; foreach (XmlNode node in typeNode.ChildNodes) { FitData fitData = new FitData(); if (node.Attributes["Model"] != null) { fitData.Model = node.Attributes["Model"].Value.ToString(); } if (node.Attributes["Name"] != null) { fitData.Name = node.Attributes["Name"].Value.ToString(); } if (node.Attributes["Weight"] != null) { fitData.Weight = Convert.ToDouble(node.Attributes["Weight"].Value.ToString()); } if (node.Attributes["Voltage"] != null) { fitData.Voltage = Convert.ToDouble(node.Attributes["Voltage"].Value.ToString()); } if (node.Attributes["SecWind"] != null) { fitData.SecWind = Convert.ToDouble(node.Attributes["SecWind"].Value.ToString()); } collectionItem.FitDatas.Add(fitData); } list.Add(collectionItem); } return(list); }
/// <summary> /// get land points from data and assume minimum radius found is land /// </summary> /// <param name="rawSingleRing"></param> /// <returns></returns> static CylData GetLandPoints(CylData ring, int pointsPerRevolution, int grooveCount) { try { var outputList = new CylData(ring.FileName); double thMax = Math.Max(ring[0].ThetaRad, ring[ring.Count - 1].ThetaRad); double thMin = Math.Min(ring[0].ThetaRad, ring[ring.Count - 1].ThetaRad); var minPt = GetMinRadiusPt(ring); int searchHalfWindow = (int)((pointsPerRevolution / grooveCount) / 2.0); double dth = Math.PI * 2.0 / grooveCount; var landLocations = new List <double>(); landLocations.Add(minPt.ThetaRad); for (int i = 1; i < grooveCount; i++) { double land = (minPt.ThetaRad + (i * dth));// % Math.PI*2.0; if (land <= thMax && land >= thMin) { landLocations.Add(land); if (Math.Abs(land % (Math.PI * 2.0)) < .02) { landLocations.Add(0.0); } } land = (minPt.ThetaRad - (i * dth)); if (land <= thMax && land >= thMin) { landLocations.Add(land); } } landLocations.Sort(); bool useLocalMinPt = false; for (int i = 0; i < landLocations.Count; i++) { if (useLocalMinPt) { for (int j = 0; j < ring.Count - 1; j++) { var p1 = ring[j].ThetaRad; var p2 = ring[j + 1].ThetaRad; if (landLocations[i] < p2 && landLocations[i] >= p1) { int searchStart = Math.Max(0, j - searchHalfWindow); int searchEnd = Math.Min(ring.Count, j + searchHalfWindow); double minR = double.MaxValue; PointCyl localMinPt = new PointCyl(); //find local min var fit = new FitData(false, 2); //var segment = new SegmentFitData(); for (int k = searchStart; k < searchEnd; k++) { if (ring[k].R < minR) { minR = ring[k].R; localMinPt = ring[k].Clone(); } } outputList.Add(localMinPt); } } } else { for (int j = 0; j < ring.Count - 1; j++) { if (landLocations[i] < ring[j + 1].ThetaRad && landLocations[i] >= ring[j].ThetaRad) { double r = (ring[j].R + ring[j + 1].R) / 2.0; double th = (ring[j].ThetaRad + ring[j + 1].ThetaRad) / 2.0; double z = (ring[j].Z + ring[j + 1].Z) / 2.0; outputList.Add(new PointCyl(r, th, z)); } } } } outputList.SortByIndex(); return(outputList); } catch (Exception) { throw; } }
protected void UpdateSidePara(bool isBackSide, ElecCalsSideRes sidePara, out string waring) { waring = ""; //组装气候工况 if (sidePara.WeatherListName != null && sidePara.WeatherListName != "") { Weather waeBack = globalInst.GetLocalWeatherByName(sidePara.WeatherListName); List <ElecCalsWorkCondition> ListWkCdt = new List <ElecCalsWorkCondition>(); if (waeBack.WorkConditions != null && waeBack.WorkConditions.Count > 0) { foreach (var item in waeBack.WorkConditions) { ListWkCdt.Add(new ElecCalsWorkCondition(item)); } } if (isBackSide) { BackWeatherPara = new ElecCalsWeaRes() { Name = sidePara.WeatherListName, ID = 1, WeathComm = ListWkCdt, }; } else { FrontWeatherPara = new ElecCalsWeaRes() { Name = sidePara.WeatherListName, ID = 2, WeathComm = ListWkCdt, }; } } else { waring += "气候工况 "; } //组装导地线 Wire Ind, Grd, OPGW; if (sidePara.IndName != null && sidePara.IndName != "") { Ind = globalInst.GetLocalWireByName(true, sidePara.IndName); } else { Ind = new Wire(); waring += "导线 "; } if (sidePara.GrdName != null && sidePara.GrdName != "") { Grd = globalInst.GetLocalWireByName(false, sidePara.GrdName); } else { Grd = new Wire(); waring += "地线 "; } if (sidePara.OPGWName != null && sidePara.OPGWName != "") { OPGW = globalInst.GetLocalWireByName(false, sidePara.OPGWName); } else { OPGW = new Wire(); waring += "OPGW "; } if (isBackSide) { BackWirePara = new ElecCalsWireData() { Ind = new ElecCalsWire(Ind.ModelSpecification, 1, Ind.SectionArea, Ind.ExternalDiameter, Ind.UnitLengthMass, Ind.ModulusElasticity, Ind.LineCoefficient, Ind.RatedBreakingForce, 0, sidePara.IndDecrTem, sidePara.IndDevideNum), Grd = new ElecCalsWire(Grd.ModelSpecification, 2, Grd.SectionArea, Grd.ExternalDiameter, Grd.UnitLengthMass, Grd.ModulusElasticity, Grd.LineCoefficient, Grd.RatedBreakingForce, 1, sidePara.GrdDecrTem), OPGW = new ElecCalsWire(OPGW.ModelSpecification, 1, OPGW.SectionArea, OPGW.ExternalDiameter, OPGW.UnitLengthMass, OPGW.ModulusElasticity, OPGW.LineCoefficient, OPGW.RatedBreakingForce, 2, sidePara.OPGWDecrTem), }; } else { FrontWirePara = new ElecCalsWireData() { Ind = new ElecCalsWire(Ind.ModelSpecification, 1, Ind.SectionArea, Ind.ExternalDiameter, Ind.UnitLengthMass, Ind.ModulusElasticity, Ind.LineCoefficient, Ind.RatedBreakingForce, 0, sidePara.IndDecrTem, sidePara.IndDevideNum), Grd = new ElecCalsWire(Grd.ModelSpecification, 2, Grd.SectionArea, Grd.ExternalDiameter, Grd.UnitLengthMass, Grd.ModulusElasticity, Grd.LineCoefficient, Grd.RatedBreakingForce, 1, sidePara.GrdDecrTem), OPGW = new ElecCalsWire(OPGW.ModelSpecification, 1, OPGW.SectionArea, OPGW.ExternalDiameter, OPGW.UnitLengthMass, OPGW.ModulusElasticity, OPGW.LineCoefficient, OPGW.RatedBreakingForce, 2, sidePara.OPGWDecrTem), }; } //更新间隔棒和防震锤 FitData IndFZ, IndJGB, GrdFZ; if (sidePara.IndFZName != null && sidePara.IndFZName != "") { IndFZ = globalInst.GetLocalFitDataByName("防震锤", sidePara.IndFZName); } else { IndFZ = new FitData(); waring += "导线防震锤 "; } if (sidePara.IndJGBName != null && sidePara.IndJGBName != "") { IndJGB = globalInst.GetLocalFitDataByName("间隔棒", sidePara.IndJGBName); } else { IndJGB = new FitData(); waring += "导线间隔棒 "; } if (sidePara.GrdFZName != null && sidePara.GrdFZName != "") { GrdFZ = globalInst.GetLocalFitDataByName("防震锤", sidePara.GrdFZName); } else { GrdFZ = new FitData(); waring += "地线防震锤 "; } int IndFZNum = 0, IndJGBNum = 0, GrdFZNum = 0; //按照规则赋值的方法还不清楚 if (sidePara.FitDataCalsPara == "1 按规则") { } else { IndFZNum = sidePara.IndFZNum; IndJGBNum = sidePara.IndJGBNum; GrdFZNum = sidePara.GrdFZNum; } if (isBackSide) { BackSpanFit = new ElecCalsSpanFit(0, IndFZNum, IndFZ.Weight, 0, GrdFZNum, GrdFZ.Weight, 0, IndJGBNum, IndJGB.Weight); } else { FrontSpanFit = new ElecCalsSpanFit(0, IndFZNum, IndFZ.Weight, 0, GrdFZNum, GrdFZ.Weight, 0, IndJGBNum, IndJGB.Weight); } }