当前位置: 首页>>代码示例>>C#>>正文


C# Series.Lookup方法代码示例

本文整理汇总了C#中Series.Lookup方法的典型用法代码示例。如果您正苦于以下问题:C# Series.Lookup方法的具体用法?C# Series.Lookup怎么用?C# Series.Lookup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Series的用法示例。


在下文中一共展示了Series.Lookup方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddToEmpty

        public void AddToEmpty()
        {
            Series s1 = new Series();
            Series s2 = new Series();
            DateTime t = new DateTime(2006, 7, 11);

            Series s3 = AddTwoSeriesWithDifferentLengths(s1, s2, ref t);

            Assert.AreEqual(s3.Count, s1.Count);

            t = new DateTime(2006, 7, 11);
            for (int i = 0; i < 10; i++)
            {
                Console.WriteLine(t);
                bool missing = true;
                if (i > 5 && i < 8)
                    missing = false;

                Assert.AreEqual(s3[i].IsMissing,missing);

                if (!missing)
                {
                    Assert.AreEqual(s1.Lookup(t) + s2.Lookup(t),3 );
                }
                t = t.AddDays(1);

            }
        }
开发者ID:usbr,项目名称:Pisces,代码行数:28,代码来源:TestAdd.cs

示例2: RMSEGenerateMatchList

        /// <summary>
        /// This builds a series with the dates from the target series and values that represent the year wherein
        /// the source series has the minimum moving 3-month RMSE
        /// </summary>
        /// <param name="SSmonthTot">Source monthly series</param>
        /// <param name="TSmonthTot">Target monthly series</param>
        /// <returns></returns>
        private static Series RMSEGenerateMatchList(Series SSmonthTot, Series TSmonthTot)
        {
            // Series to keep track of the corresponding year with the minimum RMSe
            Series TSrms = new Series();

            // For loop to generate corresponding month-year from Source with minimum 3 month RMSe
            for (int targetYear = TSmonthTot.MinDateTime.Year; targetYear <= TSmonthTot.MaxDateTime.Year; targetYear++)
            {
                for (int ithMonth = 1; ithMonth <= 12; ithMonth++)// i is the month for calculation evaluation
                {
                    // only estimate data for dates which are in the TS
                    DateTime tTarg = new DateTime(targetYear, ithMonth, DateTime.DaysInMonth(targetYear, ithMonth));

                    if (tTarg >= TSmonthTot.MinDateTime && tTarg <= TSmonthTot.MaxDateTime)
                    {
                        var RMSList = new List<double>();
                        var RMSYear = new List<int>();
                        for (int sourceYear = SSmonthTot.MinDateTime.Year; sourceYear < SSmonthTot.MaxDateTime.Year; sourceYear++)
                        {
                            DateTime tSour = new DateTime(sourceYear, ithMonth, DateTime.DaysInMonth(sourceYear, ithMonth));
                            if (tSour < SSmonthTot.MinDateTime) // makes sure that empty dailies before the daily record starts are not used
                            {
                                sourceYear++;
                                tSour = new DateTime(sourceYear, ithMonth, DateTime.DaysInMonth(sourceYear, ithMonth));
                            }
                            // RMSe calculation
                            double mon1 = getRMS(SSmonthTot.Lookup(tSour.AddMonths(-1)), TSmonthTot.Lookup(tTarg.AddMonths(-1)));
                            double mon2 = getRMS(SSmonthTot.Lookup(tSour.AddMonths(0)), TSmonthTot.Lookup(tTarg.AddMonths(0)));
                            // Sets mon3 value for the last month since there is no value for t.AddMonths(1)
                            double mon3;
                            if (tTarg == TSmonthTot.MaxDateTime)
                            { mon3 = 0.0; }
                            else
                            { mon3 = getRMS(SSmonthTot.Lookup(tSour.AddMonths(1)), TSmonthTot.Lookup(tTarg.AddMonths(1))); }
                            double RMSi = System.Math.Sqrt((mon1 + mon2 + mon3) / 3);
                            RMSList.Add(RMSi);
                            RMSYear.Add(sourceYear);
                        }
                        var RMSmin = RMSList.Min();
                        var RMSminYear = RMSYear[RMSList.IndexOf(RMSmin)];
                        TSrms.Add(tTarg, Convert.ToDouble(RMSminYear));
                    }
                }
            }
            return TSrms;
        }
开发者ID:usbr,项目名称:Pisces,代码行数:53,代码来源:Math.DissagregationUofI.cs


注:本文中的Series.Lookup方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。