public void AnnualSumJanuaryThroughJuly() { string fn = TestData.DataPath + "\\heii_qd.csv"; TextSeries ts = new TextSeries(fn); ts.Read(); Console.WriteLine(ts.Count); Assert.AreEqual(28905, ts.Count, fn + " has been modified"); MonthDayRange rng = new MonthDayRange(1, 1, 7, 31); Series sum = Reclamation.TimeSeries.Math.AnnualSum(ts, rng, 10); sum.WriteToConsole(); Assert.AreEqual(1928, sum[0].DateTime.Year); Assert.AreEqual(2293240, sum[0].Value); Series min = Math.AnnualMin(ts, rng, 10); Series max = Math.AnnualMax(ts, rng, 10); }
public void AnnualSumFullWaterYear() { // using RIR QD from hydromet // compare to check program DataTable checkProgram = new DataTable(); checkProgram.Columns.Add("Year", typeof(int)); checkProgram.Columns.Add("Sum", typeof(double)); checkProgram.Columns.Add("missing", typeof(int)); checkProgram.Columns.Add("maxDate", typeof(DateTime)); checkProgram.Columns.Add("max", typeof(double)); checkProgram.Columns.Add("minDate", typeof(DateTime)); checkProgram.Columns.Add("min", typeof(double)); // Year sum missing Maxdate max MinDate min checkProgram.Rows.Add(1963, 32137.7, 0, DateTime.Parse("2/03/2006"), 700, DateTime.Parse("8/30/2006"), 6.1); checkProgram.Rows.Add(1964, 63817.0, 0, DateTime.Parse("5/15/2006"), 1570, DateTime.Parse("10/05/2006"), 17); checkProgram.Rows.Add(1965, 77084.0, 0, DateTime.Parse("4/24/2006"), 1740, DateTime.Parse("10/01/2006"), 39); checkProgram.Rows.Add(1966, 34863.0, 0, DateTime.Parse("4/18/2006"), 628, DateTime.Parse("8/12/2006"), 10); checkProgram.Rows.Add(1967, 39152.0, 0, DateTime.Parse("5/11/2006"), 1090, DateTime.Parse("8/28/2006"), 17); checkProgram.Rows.Add(1968, 41857.0, 0, DateTime.Parse("5/03/2006"), 814, DateTime.Parse("11/28/2006"), 21); checkProgram.Rows.Add(1969, 69656.0, 0, DateTime.Parse("4/25/2006"), 2300, DateTime.Parse("11/27/2006"), 27); checkProgram.Rows.Add(1970, 56442.0, 0, DateTime.Parse("5/19/2006"), 1820, DateTime.Parse("12/06/2006"), 23); checkProgram.Rows.Add(1971, 102310.0, 0, DateTime.Parse("5/04/2006"), 2660, DateTime.Parse("1/07/2006"), 24); checkProgram.Rows.Add(1972, 92143.0, 0, DateTime.Parse("5/09/2006"), 1510, DateTime.Parse("1/04/2006"), 44); checkProgram.Rows.Add(1973, 61642.0, 0, DateTime.Parse("5/06/2006"), 1320, DateTime.Parse("8/31/2006"), 36); checkProgram.Rows.Add(1974, 76544.5, 0, DateTime.Parse("4/26/2006"), 2170, DateTime.Parse("8/12/2006"), 1.2); checkProgram.Rows.Add(1975, 78953.0, 0, DateTime.Parse("5/20/2006"), 2290, DateTime.Parse("5/07/2006"), 23); checkProgram.Rows.Add(1976, 87413.1, 0, DateTime.Parse("5/08/2006"), 1520, DateTime.Parse("1/06/2006"), 0.27); checkProgram.Rows.Add(1977, 14110.9, 0, DateTime.Parse("10/28/2006"), 310, DateTime.Parse("2/22/2006"), 8.7); checkProgram.Rows.Add(1978, 22459.3, 0, DateTime.Parse("8/03/2006"), 206, DateTime.Parse("11/30/2006"), 4.5); checkProgram.Rows.Add(1979, 33610.8, 0, DateTime.Parse("9/19/2006"), 396, DateTime.Parse("1/09/2006"), 0.1); checkProgram.Rows.Add(1980, 37074.0, 0, DateTime.Parse("6/04/2006"), 415, DateTime.Parse("1/01/2006"), 0); checkProgram.Rows.Add(1981, -999.0, 3, DateTime.Parse("10/10/2006"), 503, DateTime.Parse("12/10/2006"), 0.73); checkProgram.Rows.Add(1982, 87835.9, 0, DateTime.Parse("5/20/2006"), 1284.11, DateTime.Parse("2/24/2006"), 0); checkProgram.Rows.Add(1983, 98116.5, 0, DateTime.Parse("5/27/2006"), 1320.13, DateTime.Parse("12/30/2006"), 0); checkProgram.Rows.Add(1984, 114705.8, 0, DateTime.Parse("5/22/2006"), 1720.05, DateTime.Parse("2/16/2006"), 0); checkProgram.Rows.Add(1985, -999.0, 1, DateTime.Parse("4/19/2006"), 729.47, DateTime.Parse("3/31/2006"), 0); checkProgram.Rows.Add(1986, 82530.0, 0, DateTime.Parse("5/07/2006"), 1230, DateTime.Parse("11/22/2006"), 0); checkProgram.Rows.Add(1987, 34610.1, 0, DateTime.Parse("10/11/2006"), 592, DateTime.Parse("12/11/2006"), 0); checkProgram.Rows.Add(1988, 20880.3, 0, DateTime.Parse("9/23/2006"), 847, DateTime.Parse("11/17/2006"), 0); checkProgram.Rows.Add(1989, 29083.8, 0, DateTime.Parse("9/23/2006"), 871, DateTime.Parse("11/02/2006"), 0); checkProgram.Rows.Add(1990, 20569.0, 0, DateTime.Parse("10/01/2006"), 807, DateTime.Parse("11/02/2006"), 0); checkProgram.Rows.Add(1991, 16571.4, 0, DateTime.Parse("9/24/2006"), 571, DateTime.Parse("11/23/2006"), 0); checkProgram.Rows.Add(1992, 26423.0, 0, DateTime.Parse("10/05/2006"), 872, DateTime.Parse("11/01/2006"), 0); checkProgram.Rows.Add(1993, 42308.4, 0, DateTime.Parse("9/29/2006"), 773, DateTime.Parse("11/03/2006"), 0); checkProgram.Rows.Add(1994, 35480.0, 0, DateTime.Parse("8/05/2006"), 750, DateTime.Parse("11/01/2006"), 0); checkProgram.Rows.Add(1995, 28779.0, 0, DateTime.Parse("5/26/2006"), 478, DateTime.Parse("11/01/2006"), 0); checkProgram.Rows.Add(1996, 51189.0, 0, DateTime.Parse("5/20/2006"), 888, DateTime.Parse("11/02/2006"), 0); checkProgram.Rows.Add(1997, 107622.1, 0, DateTime.Parse("5/07/2006"), 1750, DateTime.Parse("11/22/2006"), 0); checkProgram.Rows.Add(1998, 72138.0, 0, DateTime.Parse("5/24/2006"), 745, DateTime.Parse("11/13/2006"), 0); checkProgram.Rows.Add(1999, 64000.0, 0, DateTime.Parse("5/06/2006"), 885, DateTime.Parse("11/14/2006"), 0); checkProgram.Rows.Add(2000, 29604.0, 0, DateTime.Parse("10/06/2006"), 414, DateTime.Parse("11/30/2006"), 0); checkProgram.Rows.Add(2001, 28381.0, 0, DateTime.Parse("8/18/2006"), 429, DateTime.Parse("11/16/2006"), 0); checkProgram.Rows.Add(2002, 11817.0, 0, DateTime.Parse("8/29/2006"), 455, DateTime.Parse("10/01/2006"), 0); checkProgram.Rows.Add(2003, 14270.0, 0, DateTime.Parse("8/26/2006"), 439, DateTime.Parse("10/01/2006"), 0); checkProgram.Rows.Add(2004, 16328.2, 0, DateTime.Parse("8/31/2006"), 348.2, DateTime.Parse("10/01/2006"), 0); checkProgram.Rows.Add(2005, 11442.2, 0, DateTime.Parse("9/21/2006"), 202.02, DateTime.Parse("10/13/2006"), 0); checkProgram.Rows.Add(2006, -999.0, 91, DateTime.Parse("5/02/2006"), 1119.98, DateTime.Parse("11/22/2006"), 0); string fn = TestData.DataPath + @"\rire hydromet daily.txt"; TextSeries ts = new TextSeries(fn); ts.Read(); Assert.AreEqual(16814, ts.Count, fn + " has been modified"); MonthDayRange rr = new MonthDayRange(10, 1, 9, 30); Series sum = Math.AnnualSum(ts, rr, 10); Series min = Math.AnnualMin(ts, rr, 10); Series max = Math.AnnualMax(ts, rr, 10); Assert.AreEqual(sum.TimeInterval, TimeInterval.Yearly); Assert.AreEqual(min.TimeInterval, TimeInterval.Yearly); Assert.AreEqual(max.TimeInterval, TimeInterval.Yearly); Assert.IsTrue(sum.Count == min.Count && sum.Count == max.Count, "counts for sum,min,max are not the same"); for (int i = 0; i < sum.Count; i++) { Point ptSum = sum[i]; Point ptMin = min[i]; Point ptMax = max[i]; int yr = ptSum.DateTime.Year; DataRow[] rows = checkProgram.Select("Year=" + yr); if (rows.Length > 0) { double dsum = Convert.ToDouble(rows[0]["Sum"]); double dmin = Convert.ToDouble(rows[0]["min"]); double dmax = Convert.ToDouble(rows[0]["max"]); int numMissing = Convert.ToInt32(rows[0]["missing"]); Console.WriteLine("yr = " + yr + " sum = '" + sum + "'"); if (dsum != Point.MissingValueFlag) { // we compute sum anyway, but flag it. Assert.AreEqual(dsum, ptSum.Value, 0.25, "sum different in year " + yr); } if (numMissing == 0) { Assert.AreEqual("", ptSum.Flag); } else { Assert.AreEqual(numMissing + " missing", ptSum.Flag); } Assert.AreEqual(dmin, ptMin.Value, 0.01, "min different in year " + yr); Assert.AreEqual(dmax, ptMax.Value, 0.01, "max different in year " + yr); } } //min.WriteToConsole(); //max.WriteToConsole(); }