Beispiel #1
0
        public void JacksonQU()
        {
            // daily data based on other daily data
            //DailyCalculator.
            Reclamation.TimeSeries.Parser.SeriesExpressionParser.Debug = true;
            var s = new CalculationSeries();
            s.Expression = "(jck_af-jck_af[t-1])/1.98347+jck_qd";
            s.TimeInterval = TimeInterval.Daily;
            s.Parser.VariableResolver = new HydrometVariableResolver();

            s.Calculate(new DateTime(2012,11,1),new DateTime(2012,11,15));

            Assert.AreEqual(298, s["2012-11-15"].Value, 0.01);
        }
Beispiel #2
0
        public void ValeQU()
        {
            // daily data based on other daily data
            //DailyCalculator.
            Reclamation.TimeSeries.Parser.SeriesExpressionParser.Debug = true;
            var s = new CalculationSeries();
            s.Expression = "(WAR_AF[t-2]-WAR_AF[t-3]+BEU_AF[t-2]-BEU_AF[t-3]+BUL_AF-BUL_AF[t-1])/1.98347+VALO_QD";
            s.TimeInterval = TimeInterval.Daily;
            s.Parser.VariableResolver = new HydrometVariableResolver();

            DateTime t = new DateTime(2012, 12, 6);
            s.Calculate(t,t);

            Assert.AreEqual(1, s.Count);
            Assert.AreEqual(573.75, s[t].Value, 0.01);
        }
Beispiel #3
0
        public void MathMax()
        {
            //DailyCalculator.
            DateTime t = new DateTime(2012, 12, 6);
            ConstantSeries s1 = new ConstantSeries("s1", "aa", -1, TimeInterval.Daily);
            s1.TimeInterval = TimeInterval.Daily;
            Reclamation.TimeSeries.Parser.SeriesExpressionParser.Debug = true;
            var s = new CalculationSeries();
            s.Expression = "Max(s1,0)";
            s.TimeInterval = TimeInterval.Daily;
            s.Parser.VariableResolver = new VariableResolver();
            s.Parser.VariableResolver.Add("s1", s1);

            s.Calculate(t, t.AddDays(2));
            s.WriteToConsole();
            Assert.AreEqual(3, s.Count);
        }
Beispiel #4
0
        public void AddBug()
        {
            DateTime t1 = new DateTime(2013,1,1);
            var t2 = t1.AddDays(365);
            var fn = FileUtility.GetTempFileNameInDirectory(@"c:\temp\",".pdb");
            SQLiteServer svr = new SQLiteServer(fn);
            TimeSeriesDatabase db = new Reclamation.TimeSeries.TimeSeriesDatabase(svr,false);
            var s = new HydrometDailySeries("pal","af");
            s.Name = "pal_af";
            s.Read(t1,t2);
            db.AddSeries(s);

            var cs = new CalculationSeries("add_test");
            cs.Expression = "pal_af + pal_af";
            db.AddSeries(cs);

            cs = db.GetSeriesFromName("add_test") as CalculationSeries;
            cs.Calculate(t1, t2);

            cs = db.GetSeriesFromName("add_test") as CalculationSeries;
            cs.Read();

            Assert.IsTrue(cs.Count > 0);
        }
        private static void AddSeries(string period, string scenario,
                                  TimeSeriesDatabase db, VariableResolver vr,
                                  string name, string equation, ModsimType mType)
        {
            if (name.Trim().ToLower() == "nan")
            {
            return;
            }

            if (name.Trim() == "")
            {
            Console.WriteLine("--- WARNING modsim Node Name is missing. Type = " +
                              mType.ToString());
            return;
            }

            CalculationSeries cs = new CalculationSeries(name);
            cs.TimeInterval = TimeInterval.Monthly;

            if (mType == ModsimType.Gain)
            {
            cs.Expression = string.Format("Max({0}, 0)", equation);
            }
            if (mType == ModsimType.Negative)
            {
            cs.Expression = string.Format("Abs(Min({0}, 0))", equation);
            }
            cs.TimeSeriesDatabase = db;
            cs.Parser.VariableResolver = vr;
            cs.Units = "cfs";
            db.AddSeries(cs);    // add series before calcualte to get an id assigned.
            cs.Calculate(); // Calculate also saves the data.

            SetSeriesDatesToBeginningOfMonth(cs);
            ConsolePrintSeriesNameAndCount(cs);
        }