コード例 #1
0
        static double GetValueFromList(List <PointValue> l, int r, int c, int i, int j)
        {
            PointValue p = GetEleFromList(l, r, c, i, j);

            if (p == null)
            {
                return(0);
            }
            double value = p.value;

            if (value < 0)
            {
                value = Math.Pow(10, value / 10) * 0.001;
            }
            return(value);
        }
コード例 #2
0
        /// <summary>
        /// 合并态势功率的方法
        /// </summary>
        /// <param name="resultType"></param>
        /// <param name="projectPath"></param>
        /// <param name="projectName"></param>
        internal void CombineSituationPower(List <ResultFile> resultTypes)
        {
            string totalResult = null;

            if (resultTypes != null && resultTypes.Count > 0)
            {
                totalResult = CombineMethod.CombineSituationPower(resultTypes);
                using (StreamWriter sw = File.CreateText(this.projectPath + "\\" + this.projectName + "_psum.p2m"))
                    sw.Write(totalResult);
                //********************添加生成bmp文件,有异常则不生成,跳至下一处
                do
                {
                    StreamReader      streamReader       = new StreamReader(this.projectPath + "\\" + this.projectName + "_psum.p2m");
                    List <PointValue> pointNormalizeList = new List <PointValue>();
                    List <PointValue> pointValueList     = new List <PointValue>();
                    streamReader.ReadLine();
                    streamReader.ReadLine();//第1、2行不读
                    string lineData = streamReader.ReadLine();
                    double tempMax  = -100;
                    double tempMin  = 0;
                    while (lineData != null)
                    {
                        PointValue pointValue = new PointValue();
                        lineData = lineData.Trim();
                        //按空格拆分
                        string[] tmp       = System.Text.RegularExpressions.Regex.Split(lineData, @"\s+");
                        bool     isSuccess = Double.TryParse(tmp[1], out pointValue.x);
                        if (!isSuccess)
                        {
                            break;
                        }
                        isSuccess = Double.TryParse(tmp[2], out pointValue.y);
                        if (!isSuccess)
                        {
                            break;
                        }
                        isSuccess = Double.TryParse(tmp[3], out pointValue.z);
                        if (!isSuccess)
                        {
                            break;
                        }
                        isSuccess = Double.TryParse(tmp[5], out pointValue.value);
                        if (!isSuccess)
                        {
                            break;
                        }
                        pointValueList.Add(pointValue);
                        pointNormalizeList.Add(pointValue);
                        if (pointValue.value > tempMax)
                        {
                            tempMax = pointValue.value;
                        }
                        if (pointValue.value < tempMin)
                        {
                            tempMin = pointValue.value;
                        }
                        lineData = streamReader.ReadLine();
                    }
                    streamReader.Close();
                    for (int itemp = 0; itemp < pointValueList.Count; itemp++)
                    {
                        pointNormalizeList[itemp].value = (pointValueList[itemp].value - tempMin) / (tempMax - tempMin);//以对数形式归一化
                    }
                    BmpResultUti.CreateBMP(pointValueList, this.projectPath + "\\" + this.projectName + "_situation_psum.bmp", tempMax, tempMin);
                    using (StreamWriter sw = File.CreateText(this.projectPath + "\\" + this.projectName + "_situation_psum_max_value" + ".p2m"))//将功率最大值最小值写入文件
                    {
                        sw.WriteLine(tempMax.ToString());
                        sw.WriteLine(tempMin.ToString());
                    }
                } while (false);
            }
        }
コード例 #3
0
 /// </summary>
 /// 合并态势显示的erm的方法
 /// </summary>
 internal void CombineSituationErms(List <ResultFile> resultTypes)
 {
     if (resultTypes != null && resultTypes.Count > 0)
     {
         string        totalResult         = null;
         List <string> midPointFrequencies = GetMidPointFrequency(resultTypes);
         List <Dictionary <ResultFile, double> > resultFilesWithWeights = GetWeight(resultTypes, midPointFrequencies);
         for (int i = 0; i < midPointFrequencies.Count; i++)
         {
             totalResult = CombineMethod.CombineSituationErms(resultFilesWithWeights[i]);
             using (StreamWriter sw = File.CreateText(this.projectPath + "\\" + this.projectName + "_erms_" + midPointFrequencies[i] + ".p2m"))
                 sw.Write(totalResult);
             //********************添加生成bmp文件,有异常则不生成,跳至下一处
             do
             {
                 StreamReader      streamReader       = new StreamReader(this.projectPath + "\\" + this.projectName + "_erms_" + midPointFrequencies[i] + ".p2m");
                 List <PointValue> pointValueList     = new List <PointValue>();
                 List <PointValue> pointNormalizeList = new List <PointValue>();
                 streamReader.ReadLine();
                 streamReader.ReadLine();//第1、2行不读
                 string lineData = streamReader.ReadLine();
                 double tempMax  = -80;
                 double tempMin  = 0;
                 while (lineData != null)
                 {
                     PointValue pointValue = new PointValue();
                     lineData = lineData.Trim();
                     string[] tmp       = System.Text.RegularExpressions.Regex.Split(lineData, @"\s+");
                     bool     isSuccess = Double.TryParse(tmp[1], out pointValue.x);
                     if (!isSuccess)
                     {
                         break;
                     }
                     isSuccess = Double.TryParse(tmp[2], out pointValue.y);
                     if (!isSuccess)
                     {
                         break;
                     }
                     isSuccess = Double.TryParse(tmp[3], out pointValue.z);
                     if (!isSuccess)
                     {
                         break;
                     }
                     isSuccess = Double.TryParse(tmp[5], out pointValue.value);
                     if (!isSuccess)
                     {
                         break;
                     }
                     pointValueList.Add(pointValue);
                     double tempValue = pointValue.value;
                     if (tempValue < 0.00000001)
                     {
                         tempValue = -80;
                     }
                     else
                     {
                         tempValue = 10 * Math.Log10(tempValue);
                     }
                     pointValue.value = tempValue;
                     pointNormalizeList.Add(pointValue);
                     if (pointValue.value > tempMax)
                     {
                         tempMax = pointValue.value;
                     }
                     if (pointValue.value < tempMin)
                     {
                         tempMin = pointValue.value;
                     }
                     lineData = streamReader.ReadLine();
                 }
                 streamReader.Close();
                 for (int itemp = 0; itemp < pointValueList.Count; itemp++)
                 {
                     pointNormalizeList[itemp].value = (pointValueList[itemp].value - tempMin) / (tempMax - tempMin);//以对数形式归一化
                 }
                 //生成bmp
                 BmpResultUti.CreateBMP(pointValueList, this.projectPath + "\\" + this.projectName + "_situation_erms_" + midPointFrequencies[i] + ".bmp", tempMax, tempMin);
                 using (StreamWriter sw = File.CreateText(this.projectPath + "\\" + this.projectName + "_situation_erms_max_value_" + midPointFrequencies[i] + ".p2m"))//将最大值写入文件
                 {
                     sw.WriteLine(tempMax.ToString());
                     sw.WriteLine(tempMin.ToString());
                 }
             } while (false);
         }
         //******************************************
     }
 }