Exemple #1
0
        public void GetValuesExtrapolateTest()
        {
            string dataFileRoot = @"..\..\..\..\..\Examples\AsciiFileReader\Data\";

            AsciiFileDataComponent ascii = new AsciiFileDataComponent();

            IArgument[] arguments = new IArgument[2];
            arguments[0] = Argument.Create("File1", dataFileRoot + "FlowDataId.txt", false, "Name of first file to load");
            arguments[1] = Argument.Create("File2", dataFileRoot + "WaterlevelDataPoints.txt", false, "Name of second file to load");
            ascii.ApplyArguments(arguments);
            ascii.Initialize();

            Assert.AreEqual(2, ascii.Outputs.Count);

            ITimeSpaceOutput flowOutput  = (ITimeSpaceOutput)ascii.Outputs[0];
            ITimeSpaceOutput levelOutput = (ITimeSpaceOutput)ascii.Outputs[1];

            Time   startTime       = new Time(new DateTime(2005, 1, 1, 0, 0, 0));
            double startTimeMjd    = startTime.StampAsModifiedJulianDay;
            double afterEndTimeMjd = startTimeMjd + 4;


            double[] expectedFlows  = new double[] { 11, 15.6, 21.3 };
            double[] expectedLevels = new double[] { 1, 5.6, 8.3 };


            // TODO: Make it extrapolate instead!
            _queryItem1.TimeSet.SetSingleTimeStamp(afterEndTimeMjd);
            ITimeSpaceValueSet flows  = flowOutput.GetValues(_queryItem1);
            ITimeSpaceValueSet levels = levelOutput.GetValues(_queryItem1);

            Assert.AreEqual(expectedFlows, flows.Values2D[0]);
            Assert.AreEqual(expectedLevels, levels.Values2D[0]);
        }
Exemple #2
0
        public void GetValuesTest()
        {
            string dataFileRoot = @"..\..\..\..\..\Examples\AsciiFileReader\Data\";

            AsciiFileDataComponent ascii = new AsciiFileDataComponent();

            IArgument[] arguments = new IArgument[3];
            arguments[0]    = Argument.Create("File1", dataFileRoot + "FlowDataId.txt", false, "Name of first file to load");
            arguments[1]    = Argument.Create("File2", dataFileRoot + "WaterlevelDataPoints.txt", false, "Name of second file to load");
            arguments[2]    = Argument.Create("File3", dataFileRoot + "RainDataGrid.txt", false, "Name of third file to load");
            ascii.Arguments = arguments;
            ascii.ApplyArguments(arguments);
            ascii.Initialize();

            Assert.AreEqual(3, ascii.Outputs.Count);

            ITimeSpaceOutput flowOutput  = (ITimeSpaceOutput)ascii.Outputs[0];
            ITimeSpaceOutput levelOutput = (ITimeSpaceOutput)ascii.Outputs[1];
            ITimeSpaceOutput rainOutput  = (ITimeSpaceOutput)ascii.Outputs[2];

            Assert.IsNotNull(flowOutput.ValueDefinition as IQuantity);
            Assert.AreEqual("Flow", flowOutput.ValueDefinition.Caption);

            Assert.IsNotNull(levelOutput.ValueDefinition as IQuantity);
            Assert.AreEqual("WaterLevel", levelOutput.ValueDefinition.Caption);


            Time   startTime          = new Time(new DateTime(2005, 1, 1, 0, 0, 0));
            double startTimeMjd       = startTime.StampAsModifiedJulianDay;
            double midTimeMjd         = startTimeMjd + 1.3;
            double endTimeMjd         = startTimeMjd + 3;
            double beforeStartTimeMjd = startTimeMjd - 1;
            double afterEndTimeMjd    = startTimeMjd + 4;


            double[] expectedFlows  = new double[] { 15.4, 18.2, 22.4 };
            double[] expectedLevels = new double[] { 5.4, 8.2, 9.4 };
            double[] expectedRain   = new double[] { 15.4, 18.2, 22.4, 22.4 };

            _queryItem1.TimeSet.SetSingleTimeStamp(startTimeMjd);
            ITimeSpaceValueSet flows  = flowOutput.GetValues(_queryItem1);
            ITimeSpaceValueSet levels = levelOutput.GetValues(_queryItem1);
            ITimeSpaceValueSet rain   = rainOutput.GetValues(_queryItem1);

            Assert.AreEqual(expectedFlows, flows.Values2D[0]);
            Assert.AreEqual(expectedLevels, levels.Values2D[0]);
            Assert.AreEqual(expectedRain, rain.Values2D[0]);

            _queryItem1.TimeSet.SetSingleTimeStamp(beforeStartTimeMjd);
            flows  = flowOutput.GetValues(_queryItem1);
            levels = levelOutput.GetValues(_queryItem1);
            rain   = rainOutput.GetValues(_queryItem1);
            Assert.AreEqual(expectedFlows, flows.Values2D[0]);
            Assert.AreEqual(expectedLevels, levels.Values2D[0]);
            Assert.AreEqual(expectedRain, rain.Values2D[0]);

            expectedFlows  = new double[] { 0.6 * 13.8 + 0.4 * 13.9, 0.6 * 18.2 + 0.4 * 18, 0.6 * 23.5 + 0.4 * 23.6 };
            expectedLevels = new double[] { 0.6 * 3.8 + 0.4 * 3.9, 0.6 * 8.2 + 0.4 * 8, 0.6 * 10.5 + 0.4 * 10.6 };
            expectedRain   = new double[] { 0.6 * 13.8 + 0.4 * 13.9, 0.6 * 18.2 + 0.4 * 18, 0.6 * 23.5 + 0.4 * 23.6, 0.6 * 23.5 + 0.4 * 23.6 };

            _queryItem1.TimeSet.SetSingleTimeStamp(midTimeMjd);
            flows  = flowOutput.GetValues(_queryItem1);
            levels = levelOutput.GetValues(_queryItem1);
            rain   = rainOutput.GetValues(_queryItem1);
            AssertAreEqual(expectedFlows, (IList <double>)flows.Values2D[0], 1e-8);
            AssertAreEqual(expectedLevels, (IList <double>)levels.Values2D[0], 1e-8);
            AssertAreEqual(expectedRain, (IList <double>)rain.Values2D[0], 1e-8);

            expectedFlows  = new double[] { 11, 15.6, 21.3 };
            expectedLevels = new double[] { 1, 5.6, 8.3 };
            expectedRain   = new double[] { 11, 15.6, 21.3, 21.3 };

            _queryItem1.TimeSet.SetSingleTimeStamp(endTimeMjd);
            flows  = flowOutput.GetValues(_queryItem1);
            levels = levelOutput.GetValues(_queryItem1);
            rain   = rainOutput.GetValues(_queryItem1);
            Assert.AreEqual(expectedFlows, flows.Values2D[0]);
            Assert.AreEqual(expectedLevels, levels.Values2D[0]);
            Assert.AreEqual(expectedRain, rain.Values2D[0]);

            Console.Out.WriteLine("done!");
        }