Exemplo n.º 1
0
        public void EntiatRiver()
        {
            Series s = new Series();

            DateTime t = new DateTime(2006, 5, 24);

            for (int i = 0; i < 365; i++)
            {
                s.Add(t, i);
                t = t.AddDays(1);
            }
            Series w = Math.ShiftToYear(s, 2000);

            Assert.AreEqual(2000, w[0].DateTime.Year);
            Assert.AreEqual(5, w[0].DateTime.Month);
            Assert.AreEqual(24, w[0].DateTime.Day);
        }
Exemplo n.º 2
0
        /// <summary>
        /// combines this list of series into a single series
        /// can be used to merge multiple aggregate series into a single
        /// series.
        /// </summary>
        /// <returns></returns>
        internal Series MergeYearlyScenarios()
        {
            var rval = new Series();

            if (HasMultipleSites)
            {
                throw new Exception("Error: Merge is only supported for a single site location");
            }

            for (int i = 0; i < this.Count; i++)
            {
                var s = this[i];
                if (s.ScenarioName == "")
                {
                    continue;
                }

                if (i == 0)
                {
                    rval.Name         = "Merged " + this.Count + " items " + s.Name;
                    rval.SiteID       = s.SiteID;
                    rval.TimeInterval = s.TimeInterval;
                }

                //shift to scenairo year.
                int yr;
                if (int.TryParse(s.ScenarioName, out yr))
                {
                    var shifted = Math.ShiftToYear(s, yr);
                    rval.Add(shifted);
                }
                else
                {
                    Logger.WriteLine("Error: Can't convert '" + s.ScenarioName + "' to an integer year");
                    // throw new Exception("Error: Can't convert '"+s.ScenarioName+"' to an integer year");
                }
            }

            return(rval);
        }
Exemplo n.º 3
0
        private static SeriesList FilterBySelectedRange(MonthDayRange range, SeriesList wyList)
        {
            SeriesList list = new SeriesList();

            foreach (Series item in wyList)
            {
                //// bug fix: leap years shifted to year 2000
                ////          have extra data point in October of next year.
                ////          delete this.
                //if (item.Count > 0 && item[0].DateTime.Month == 10
                //    && item[item.Count - 1].DateTime.Month == 10
                //    && range.Month2 != 10)
                //{
                //    item.ReadOnly = false;
                //    item.RemoveAt(item.Count - 1);

                //}

                list.Add(Math.ShiftToYear(Math.Subset(item, range), 2000));
            }

            return(list);
        }