예제 #1
0
 /// <summary>
 /// 统计Dictionary<1-12月份,雷电日数字>。
 /// </summary>
 /// <returns>雷电日字典,按月份。</returns>
 public override Dictionary <int, double> StaticLightningStrikesDayMonthly()
 {
     try
     {
         Dictionary <int, double> LightningStrikesDayMonthlyDictionary = new Dictionary <int, double>();
         for (int i = 1; i <= 12; i++)//初始化类库
         {
             double     LightningStrikesDayMonthly = 0;
             double     numSum;
             List <int> yearList = new List <int>();
             yearList = StatisticYearList(LightningStrikesDayList);
             double yearNum = yearList.Count;
             if (parallel)
             {
                 numSum = (double)LightningStrikesDayList.AsParallel().Where(r => r.DateTime.Month == i).Count();
                 LightningStrikesDayMonthly = numSum / yearNum;
             }
             else
             {
                 numSum = (double)LightningStrikesDayList.Where(r => r.DateTime.Month == i).Count();
                 LightningStrikesDayMonthly = numSum / yearNum;
             }
             LightningStrikesDayMonthlyDictionary.Add(i, LightningStrikesDayMonthly);
         }
         return(LightningStrikesDayMonthlyDictionary);
     }
     catch
     { return(null); }
 }
예제 #2
0
 /// <summary>
 /// 输入年份,返回一个Dictionary<1-12月份,雷电日数字>。
 /// </summary>
 /// <param name="_monthIndex">1~12月份</param>
 /// <returns>雷电日数字</returns>
 public override Dictionary <int, double> StaticLightningStrikesDayMonthly(int _year)
 {
     try
     {
         Dictionary <int, double> LightningStrikesDayResultDictionary = new Dictionary <int, double>();
         for (int i = 1; i <= 12; i++)//初始化类库
         {
             int LightningStrikesDayYearly = 0;
             if (parallel)
             {
                 LightningStrikesDayYearly = LightningStrikesDayList.Where(r => r.DateTime.Year == _year && r.DateTime.Month == i).AsParallel().Count();
             }
             else
             {
                 LightningStrikesDayYearly = LightningStrikesDayList.Where(r => r.DateTime.Year == _year && r.DateTime.Month == i).Count();
             }
             LightningStrikesDayResultDictionary.Add(i, LightningStrikesDayYearly);
         }
         return(LightningStrikesDayResultDictionary);
     }
     catch
     { return(null); }
 }