Example #1
0
        public void CalcAvgWS_Diffs_by_WD_Test()
        {
            string filename = testingFolder + "\\CalcAvgWS_DiffsByWD\\WS Diffs and WD.csv";

            StreamReader file = new StreamReader(filename);
            string       line;

            char[] delims = { ',' };

            Met_Data_Filter.WS_Ratio_WD_Data theseDiffs = new Met_Data_Filter.WS_Ratio_WD_Data();
            int Diff_Count = 0;

            while ((line = file.ReadLine()) != null)
            {
                String[] Data = line.Split(delims);

                if (Data[0] != "" & Data[1] != "")
                {
                    Diff_Count++;
                    Array.Resize(ref theseDiffs.WS_Ratio, Diff_Count);
                    Array.Resize(ref theseDiffs.WD, Diff_Count);
                    theseDiffs.WS_Ratio[Diff_Count - 1] = Convert.ToSingle(Data[0]);
                    theseDiffs.WD[Diff_Count - 1]       = Convert.ToDouble(Data[1]);
                }
            }

            Met_Data_Filter thisMetData = new Met_Data_Filter();

            double[] theseAvgDiffs = thisMetData.CalcAvgWS_DiffsByWD(theseDiffs);

            Assert.AreEqual(theseAvgDiffs[0], -0.075307018, 0.0001, "Wrong avg Diff Test 1");
            Assert.AreEqual(theseAvgDiffs[13], 0.367984064, 0.0001, "Wrong avg Diff Test 2");
            Assert.AreEqual(theseAvgDiffs[27], 0.376872093, 0.0001, "Wrong avg Diff Test 3");
            Assert.AreEqual(theseAvgDiffs[179], -0.051792271, 0.0001, "Wrong avg Diff Test 4");
        }
Example #2
0
        public void Get_WS_Ratio_or_Diff_and_WD_Test()
        {
            Continuum thisInst = new Continuum("");

            string Filename = testingFolder + "\\MetDataFilter Archbold testing.cfm";

            thisInst.Open(Filename);

            Met thisMet = thisInst.metList.metItem[0];

            Met_Data_Filter.WS_Ratio_WD_Data theseCalcs = new Met_Data_Filter.WS_Ratio_WD_Data();

            // 30m Anem tests
            theseCalcs = thisMet.metData.GetWS_RatioOrDiffAndWD(30, "Unfiltered", "Ratio", true);
            Assert.AreEqual(theseCalcs.WS_Ratio[2468], 0.96742, 0.001, "Wrong value for Test 1");

            theseCalcs = thisMet.metData.GetWS_RatioOrDiffAndWD(30, "Unfiltered", "Diff", true);
            Assert.AreEqual(theseCalcs.WS_Ratio[49], 0, 0.001, "Wrong value for Test 2");

            theseCalcs = thisMet.metData.GetWS_RatioOrDiffAndWD(30, "Filtered", "Ratio", true);
            Assert.AreEqual(theseCalcs.WD[1567], 199.6, 0.001, "Wrong value for Test 3");

            theseCalcs = thisMet.metData.GetWS_RatioOrDiffAndWD(30, "Filtered", "Diff", true);
            Assert.AreEqual(theseCalcs.WS_Ratio[15559], -0.492, 0.001, "Wrong value for Test 4");

            thisMet.metData.startDate = Convert.ToDateTime("1/1/2009 22:00");
            thisMet.metData.endDate   = Convert.ToDateTime("4/3/2009 8:00");

            // 50m Anem Tests
            theseCalcs = thisMet.metData.GetWS_RatioOrDiffAndWD(50, "Unfiltered", "Ratio", false);
            Assert.AreEqual(theseCalcs.WD[1687], 315, 0.001, "Wrong value for Test 5");

            theseCalcs = thisMet.metData.GetWS_RatioOrDiffAndWD(50, "Unfiltered", "Diff", false);
            Assert.AreEqual(theseCalcs.WS_Ratio[6874], 0.134, 0.001, "Wrong value for Test 6");

            theseCalcs = thisMet.metData.GetWS_RatioOrDiffAndWD(50, "Filtered", "Ratio", false);
            Assert.AreEqual(theseCalcs.WS_Ratio[2198], 1.020134, 0.001, "Wrong value for Test 7");

            theseCalcs = thisMet.metData.GetWS_RatioOrDiffAndWD(50, "Filtered", "Diff", false);
            Assert.AreEqual(theseCalcs.WD[357], 253, 0.001, "Wrong value for Test 8");

            thisInst.Close();
        }