Example #1
0
        public void Calc_Perc_Diff_from_LT_Yearly_Test()
        {
            Continuum thisInst = new Continuum("");

            string Filename = testingFolder + "\\MERRA_Testing.cfm";

            thisInst.Open(Filename);

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

            UTM_conversion.Lat_Long theseLL = thisInst.UTM_conversions.UTMtoLL(thisInst.metList.metItem[0].UTMX, thisInst.metList.metItem[0].UTMY);
            MERRA merra = thisInst.merraList.GetMERRA(theseLL.latitude, theseLL.longitude);

            double This_Diff = merra.Calc_Perc_Diff_from_LT_Yearly(merra.interpData.Annual_Prod, 2008);

            Assert.AreEqual(0.09389, This_Diff, 0.001, "Wrong Perc Diff 2008");

            This_Diff = merra.Calc_Perc_Diff_from_LT_Yearly(merra.interpData.Annual_Prod, 2009);
            Assert.AreEqual(-0.0113, This_Diff, 0.001, "Wrong Perc Diff 2009");

            This_Diff = merra.Calc_Perc_Diff_from_LT_Yearly(merra.interpData.Annual_Prod, 2010);
            Assert.AreEqual(-0.08254, This_Diff, 0.001, "Wrong Perc Diff 2010");

            thisInst.Close();
        }
Example #2
0
        public void Calc_Perc_Diff_from_LT_Monthly_Test()
        {
            Continuum thisInst = new Continuum("");

            string Filename = testingFolder + "\\MERRA_Testing.cfm";

            thisInst.Open(Filename);

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

            UTM_conversion.Lat_Long theseLL = thisInst.UTM_conversions.UTMtoLL(thisInst.metList.metItem[0].UTMX, thisInst.metList.metItem[0].UTMY);
            MERRA merra = thisInst.merraList.GetMERRA(theseLL.latitude, theseLL.longitude);

            double thisDiff = merra.Calc_Perc_Diff_from_LT_Monthly(merra.interpData.Monthly_Prod[0], 2008);

            Assert.AreEqual(0.390928274, thisDiff, 0.001, "Wrong Perc Diff Jan 2008");

            thisDiff = merra.Calc_Perc_Diff_from_LT_Monthly(merra.interpData.Monthly_Prod[4], 2009);
            Assert.AreEqual(-0.186664345, thisDiff, 0.001, "Wrong Perc Diff May 2009");

            thisDiff = merra.Calc_Perc_Diff_from_LT_Monthly(merra.interpData.Monthly_Prod[11], 2010);
            Assert.AreEqual(-0.2157710, thisDiff, 0.001, "Wrong Perc Diff Dec 2010");

            thisInst.Close();
        }
Example #3
0
        public void Calc_LT_Avg_Prod_Test()
        {
            Continuum thisInst = new Continuum("");

            string Filename = testingFolder + "\\MERRA_Testing.cfm";

            thisInst.Open(Filename);

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

            UTM_conversion.Lat_Long theseLL = thisInst.UTM_conversions.UTMtoLL(thisInst.metList.metItem[0].UTMX, thisInst.metList.metItem[0].UTMY);
            MERRA merra = thisInst.merraList.GetMERRA(theseLL.latitude, theseLL.longitude);

            merra.Calc_LT_Avg_Prod(ref merra.interpData.Annual_Prod);

            // Test 1
            double thisProd = merra.interpData.Annual_Prod.LT_Avg;

            Assert.AreEqual(3302607.8, thisProd, 50, "Wrong LT Avg Prod");

            // Test 2
            thisProd = merra.interpData.Annual_Prod.Yearly_Prod[0].prod;
            Assert.AreEqual(3612674.8, thisProd, 50, "Wrong 2008 Prod");

            // Test 3
            Assert.AreEqual(3, merra.interpData.Annual_Prod.Yearly_Prod.Length, "Wrong number of years");

            thisInst.Close();
        }
        public void Do_MCP_Uncertainty_test()
        {
            Continuum thisInst = new Continuum("");

            string Filename = testingFolder + "\\MCP testing.cfm";

            thisInst.Open(Filename);
            Met thisMet = thisInst.metList.metItem[0];
            MCP thisMCP = thisMet.mcp;

            UTM_conversion.Lat_Long theseLL = thisInst.UTM_conversions.UTMtoLL(thisMet.UTMX, thisMet.UTMY);
            MERRA merra = thisInst.merraList.GetMERRA(theseLL.latitude, theseLL.longitude);

            thisMCP.numWD = 16;

            thisMCP.Do_MCP_Uncertainty(thisInst, merra, thisMet);

            Assert.AreEqual(thisMCP.uncertOrtho.Length, 12, 0, "Wrong number of uncertainty objects");
            Assert.AreEqual(thisMCP.uncertOrtho[0].NWindows, 12, 0, "Wrong number of monthly intervals");
            Assert.AreEqual(thisMCP.uncertOrtho[7].NWindows, 5, 0, "Wrong number ofintervals");
            Assert.AreEqual(thisMCP.uncertOrtho[5].WSize, 6, 0, "Wrong wrong window size");
            Assert.AreEqual(thisMCP.uncertOrtho[0].avg, 6.411818, 0.001, "Wrong average LT Estimate in uncertainty calculation");

            thisInst.Close();
        }
Example #5
0
        public void Find_MERRA_Coords_Test()
        {
            Continuum thisInst = new Continuum("");

            string Filename = testingFolder + "\\MERRA_Testing.cfm";

            thisInst.Open(Filename);

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

            UTM_conversion.Lat_Long theseLL = thisInst.UTM_conversions.UTMtoLL(thisInst.metList.metItem[0].UTMX, thisInst.metList.metItem[0].UTMY);
            MERRA merra = thisInst.merraList.GetMERRA(theseLL.latitude, theseLL.longitude);

            // Test 1
            bool Get_MERRA_Coords = merra.Find_MERRA_Coords(merraFolder);

            Assert.AreEqual(4, merra.MERRA_Nodes[0].XY_ind.X_ind, "Wrong x ind");
            Assert.AreEqual(2, merra.MERRA_Nodes[0].XY_ind.Y_ind, "Wrong y ind");

            // Test 2
            merra.numMERRA_Nodes = 4;
            Array.Resize(ref merra.MERRA_Nodes, merra.numMERRA_Nodes);
            merra.ClearAll();
            merra.Set_Interp_LatLon_Dates_Offset(41.2, -83.8, thisInst.UTM_conversions.GetUTC_Offset(41.2, -83.8), thisInst);

            Get_MERRA_Coords = merra.Find_MERRA_Coords(merraFolder);
            Assert.AreEqual(4, merra.MERRA_Nodes[0].XY_ind.X_ind, "Wrong x ind 0");
            Assert.AreEqual(1, merra.MERRA_Nodes[0].XY_ind.Y_ind, "Wrong y ind 0");
            Assert.AreEqual(5, merra.MERRA_Nodes[1].XY_ind.X_ind, "Wrong x ind 1");
            Assert.AreEqual(1, merra.MERRA_Nodes[1].XY_ind.Y_ind, "Wrong y ind 1");
            Assert.AreEqual(4, merra.MERRA_Nodes[2].XY_ind.X_ind, "Wrong x ind 2");
            Assert.AreEqual(2, merra.MERRA_Nodes[2].XY_ind.Y_ind, "Wrong y ind 2");
            Assert.AreEqual(5, merra.MERRA_Nodes[3].XY_ind.X_ind, "Wrong x ind 3");
            Assert.AreEqual(2, merra.MERRA_Nodes[3].XY_ind.Y_ind, "Wrong y ind 3");

            // Test 3
            merra.numMERRA_Nodes = 16;
            Array.Resize(ref merra.MERRA_Nodes, merra.numMERRA_Nodes);
            merra.ClearAll();
            merra.Set_Interp_LatLon_Dates_Offset(40.4, -82.9, thisInst.UTM_conversions.GetUTC_Offset(40.4, -82.9), thisInst);
            Get_MERRA_Coords = merra.Find_MERRA_Coords(merraFolder);
            Assert.AreEqual(1, merra.MERRA_Nodes[0].XY_ind.X_ind, "Wrong x ind 0");
            Assert.AreEqual(2, merra.MERRA_Nodes[0].XY_ind.Y_ind, "Wrong y ind 0");
            Assert.AreEqual(2, merra.MERRA_Nodes[1].XY_ind.X_ind, "Wrong x ind 1");
            Assert.AreEqual(2, merra.MERRA_Nodes[1].XY_ind.Y_ind, "Wrong y ind 1");
            Assert.AreEqual(3, merra.MERRA_Nodes[2].XY_ind.X_ind, "Wrong x ind 2");
            Assert.AreEqual(2, merra.MERRA_Nodes[2].XY_ind.Y_ind, "Wrong y ind 2");
            Assert.AreEqual(4, merra.MERRA_Nodes[3].XY_ind.X_ind, "Wrong x ind 2");
            Assert.AreEqual(2, merra.MERRA_Nodes[3].XY_ind.Y_ind, "Wrong y ind 2");

            thisInst.Close();
        }
        public void CalcProbabilityOfHits()
        {
            Continuum thisInst = new Continuum("");

            string fileName = testingFolder + "\\Ice Throw\\Ice Throw testing.cfm";

            thisInst.Open(fileName);

            UTM_conversion.UTM_coords theseUTM = new UTM_conversion.UTM_coords();
            theseUTM.UTMZoneNumber = thisInst.UTM_conversions.UTMZoneNumber;
            theseUTM.hemisphere    = "Northern";
            theseUTM.UTMEasting    = 277870;
            theseUTM.UTMNorthing   = 4553300;
            UTM_conversion.Lat_Long theseLL = thisInst.UTM_conversions.UTMtoLL(theseUTM.UTMEasting, theseUTM.UTMNorthing);

            SiteSuitability.Zone zone = new SiteSuitability.Zone();
            zone.latitude  = theseLL.latitude;
            zone.longitude = theseLL.longitude;
            zone.xSize     = 20;
            zone.ySize     = 20;

            // Test 1: Probability of at least one ice hit in a year
            double probHits = thisInst.siteSuitability.CalcProbabilityOfHits(zone, 0, thisInst);

            Assert.AreEqual(probHits, 1.0, 0.001, "Wrong Ice hit probability Test 1");

            // Test 2: Prob of 1 or more hits
            probHits = thisInst.siteSuitability.CalcProbabilityOfHits(zone, 1, thisInst);
            Assert.AreEqual(probHits, 0.3, 0.001, "Wrong Ice hit probability Test 2");

            // Test 3: Prob of 2 or more hits
            probHits = thisInst.siteSuitability.CalcProbabilityOfHits(zone, 2, thisInst);
            Assert.AreEqual(probHits, 0.05, 0.001, "Wrong Ice hit probability Test 3");

            // Test 4: Prob of 3 or more hits
            probHits = thisInst.siteSuitability.CalcProbabilityOfHits(zone, 3, thisInst);
            Assert.AreEqual(probHits, 0.00, 0.001, "Wrong Ice hit probability Test 4");

            // Test 5: Prob of 4 or more hits
            probHits = thisInst.siteSuitability.CalcProbabilityOfHits(zone, 4, thisInst);
            Assert.AreEqual(probHits, 0.00, 0.001, "Wrong Ice hit probability Test 5");

            // Test 6: Prob of more than 4 hits
            probHits = thisInst.siteSuitability.CalcProbabilityOfHits(zone, 5, thisInst);
            Assert.AreEqual(probHits, 0.00, 0.001, "Wrong Ice hit probability Test 6");

            thisInst.Close();
        }
Example #7
0
        public void Calc_Avg_or_LT_Test()
        {
            Continuum thisInst = new Continuum("");

            string Filename = testingFolder + "\\MERRA_Testing.cfm";

            thisInst.Open(Filename);

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

            UTM_conversion.Lat_Long theseLL = thisInst.UTM_conversions.UTMtoLL(thisInst.metList.metItem[0].UTMX, thisInst.metList.metItem[0].UTMY);
            MERRA merra = thisInst.merraList.GetMERRA(theseLL.latitude, theseLL.longitude);

            if (merra.interpData.TS_Data.Length == 0)
            {
                merra.GetMERRADataFromDB(thisInst);
                merra.GetInterpData(thisInst.UTM_conversions);
            }

            // Test 1
            double thisAvg = merra.Calc_Avg_or_LT(merra.interpData.TS_Data, 100, 100, "50 m WS");

            Assert.AreEqual(6.670311915, thisAvg, 0.001, "Wrong 50m WS all data");

            // Test 2
            thisAvg = merra.Calc_Avg_or_LT(merra.interpData.TS_Data, 100, 100, "Surface Pressure");
            Assert.AreEqual(98.72393837, thisAvg, 0.001, "Wrong Pressure");

            // Test 3
            thisAvg = merra.Calc_Avg_or_LT(merra.interpData.TS_Data, 100, 100, "10 m Temp"); // all data
            Assert.AreEqual(10.33596373, thisAvg, 0.001, "Wrong 10m Temp");

            // Test 4
            thisAvg = merra.Calc_Avg_or_LT(merra.interpData.TS_Data, 1, 2008, "50 m WS"); // jan 2008
            Assert.AreEqual(8.938906452, thisAvg, 0.001, "Wrong 50m WS");

            // Test 5
            thisAvg = merra.Calc_Avg_or_LT(merra.interpData.TS_Data, 100, 2010, "50 m WS"); // avg 2010
            Assert.AreEqual(6.421752226, thisAvg, 0.001, "Wrong 50 m WS");

            // Test 6
            thisAvg = merra.Calc_Avg_or_LT(merra.interpData.TS_Data, 1, 100, "50 m WS"); // avg all january's
            Assert.AreEqual(7.639244713, thisAvg, 0.001, "Wrong 50m WS");

            thisInst.Close();
        }
Example #8
0
        public void Calc_Dev_from_LT_Test()
        {
            Continuum thisInst = new Continuum("");

            string Filename = testingFolder + "\\MERRA_Testing.cfm";

            thisInst.Open(Filename);

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

            UTM_conversion.Lat_Long theseLL = thisInst.UTM_conversions.UTMtoLL(thisInst.metList.metItem[0].UTMX, thisInst.metList.metItem[0].UTMY);
            MERRA merra = thisInst.merraList.GetMERRA(theseLL.latitude, theseLL.longitude);

            double thisDev = merra.Calc_Dev_from_LT(merra.interpData.Monthly_Prod, merra.interpData.Annual_Prod, 2010, 11);

            Assert.AreEqual(0.0404134, thisDev, 0.001, "Wrong deviation in Nov 2010");

            thisDev = merra.Calc_Dev_from_LT(merra.interpData.Monthly_Prod, merra.interpData.Annual_Prod, 2010, 100);
            Assert.AreEqual(-0.082540128, thisDev, 0.001, "Wrong deviation in 2010");

            thisInst.Close();
        }
Example #9
0
        public void Calc_MonthProdStats_Test()
        {
            Continuum thisInst = new Continuum("");

            string Filename = testingFolder + "\\MERRA_Testing.cfm";

            thisInst.Open(Filename);

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

            UTM_conversion.Lat_Long theseLL = thisInst.UTM_conversions.UTMtoLL(thisInst.metList.metItem[0].UTMX, thisInst.metList.metItem[0].UTMY);
            MERRA merra = thisInst.merraList.GetMERRA(theseLL.latitude, theseLL.longitude);

            merra.Calc_MonthProdStats(thisInst.UTM_conversions);

            Assert.AreEqual(539195.69, merra.interpData.Monthly_Prod[0].YearProd[0].prod, 10, "Wrong Prod Jan 2008");
            Assert.AreEqual(326853.70, merra.interpData.Monthly_Prod[1].LT_Avg, 10, "Wrong Prod Feb LT Avg");
            Assert.AreEqual(395500.22, merra.interpData.Monthly_Prod[3].YearProd[1].prod, 10, "Wrong Prod April 2009");
            Assert.AreEqual(327228.91, merra.interpData.Monthly_Prod[9].YearProd[2].prod, 10, "Wrong Prod Oct 2010");
            Assert.AreEqual(400752.219, merra.interpData.Monthly_Prod[11].LT_Avg, 10, "Wrong Prod Dec LT Avg");

            thisInst.Close();
        }
Example #10
0
        public void CalcAvgSD_Uncert_test()
        {
            Continuum thisInst = new Continuum("");

            string Filename = testingFolder + "\\MCP testing.cfm";

            thisInst.Open(Filename);
            Met thisMet = thisInst.metList.metItem[0];
            MCP thisMCP = thisMet.mcp;

            UTM_conversion.Lat_Long theseLL = thisInst.UTM_conversions.UTMtoLL(thisMet.UTMX, thisMet.UTMY);
            thisInst.merraList.MERRAfolder = MERRA2Folder;
            MERRA merra = thisInst.merraList.GetMERRA(theseLL.latitude, theseLL.longitude);

            thisMCP.numWD          = 16;
            thisInst.metList.numWD = 16;
            thisMCP.Do_MCP_Uncertainty(thisInst, merra, thisMet);

            Assert.AreEqual(thisMCP.uncertOrtho[0].avg, 6.411818, 0.001, "Wrong calculated average of LT estimates in uncertainty analysis");
            Assert.AreEqual(thisMCP.uncertOrtho[0].stDev, 0.19069, 0.001, "Wrong calculated standard deviation of LT estimates in uncertainty analysis");

            thisInst.Close();
        }
Example #11
0
        public void UTMtoLL_Test()
        {
            UTM_conversion thisConverter = new UTM_conversion();

            thisConverter.savedDatumIndex = 0;
            thisConverter.UTMZoneNumber   = 17;
            thisConverter.hemisphere      = "Northern";
            double UTMX = 477685;
            double UTMY = 4618287;

            UTM_conversion.Lat_Long theseLatLong = thisConverter.UTMtoLL(UTMX, UTMY);

            Assert.AreEqual(41.716058, theseLatLong.latitude, 1, "Wrong latitude in Test 1");
            Assert.AreEqual(-81.268258, theseLatLong.longitude, 1, "Wrong longitude in Test 1");

            thisConverter.UTMZoneNumber = 14;
            thisConverter.hemisphere    = "Northern";
            UTMX         = 292802;
            UTMY         = 4346641.9;
            theseLatLong = thisConverter.UTMtoLL(UTMX, UTMY);

            Assert.AreEqual(39.244365, theseLatLong.latitude, 1, "Wrong latitude in Test 2");
            Assert.AreEqual(-101.400952, theseLatLong.longitude, 1, "Wrong longitude in Test 2");
        }
Example #12
0
        public void Calc_CF_Test()
        {
            Continuum thisInst = new Continuum("");

            string Filename = testingFolder + "\\MERRA_Testing.cfm";

            thisInst.Open(Filename);

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

            UTM_conversion.Lat_Long theseLL = thisInst.UTM_conversions.UTMtoLL(thisInst.metList.metItem[0].UTMX, thisInst.metList.metItem[0].UTMY);
            MERRA merra = thisInst.merraList.GetMERRA(theseLL.latitude, theseLL.longitude);

            TurbineCollection.PowerCurve powerCurve = thisInst.turbineList.powerCurves[0];

            Assert.AreEqual(0.338060246, merra.Calc_CF(456, 1, 2000, powerCurve), 0.001, "Wrong CF 31 days");
            Assert.AreEqual(0.361374746, merra.Calc_CF(456, 2, 2000, powerCurve), 0.001, "Wrong CF 29 days");
            Assert.AreEqual(0.374280987, merra.Calc_CF(456, 2, 2001, powerCurve), 0.001, "Wrong CF 28 days");
            Assert.AreEqual(0.349328921, merra.Calc_CF(456, 4, 2010, powerCurve), 0.001, "Wrong CF 30 days");
            Assert.AreEqual(0.287119661, merra.Calc_CF(4560, 100, 2001, powerCurve), 0.001, "Wrong CF normal year");
            Assert.AreEqual(0.286335181, merra.Calc_CF(4560, 100, 2010, powerCurve), 0.001, "Wrong CF leap year");

            thisInst.Close();
        }
Example #13
0
        public void CalcLT_WSWD_Dists_Test()
        {
            Continuum thisInst = new Continuum("");

            string fileName = testingFolder + "\\Met testing.cfm";

            thisInst.Open(fileName);

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

            thisInst.metList.numWD     = 16;
            thisInst.metList.numTOD    = 1;
            thisInst.metList.numSeason = 1;
            thisInst.ResetTimeSeries();

            string MCP_Method = "Orth. Regression";

            UTM_conversion.Lat_Long theseLL = thisInst.UTM_conversions.UTMtoLL(thisMet.UTMX, thisMet.UTMY);
            int   offset    = thisInst.UTM_conversions.GetUTC_Offset(theseLL.latitude, theseLL.longitude);
            MERRA thisMERRA = thisInst.merraList.GetMERRA(theseLL.latitude, theseLL.longitude);

            thisInst.metList.RunMCP(ref thisMet, thisMERRA, thisInst, MCP_Method);
            thisInst.metList.isMCPd = true;

            // Test 1
            Met.WSWD_Dist thisDist = thisMet.CalcLT_WSWD_Dists(80, Met.TOD.All, Met.Season.All, thisInst, thisMet.mcp.LT_WS_Ests);

            Assert.AreEqual(thisDist.WS, 6.566949, 0.01, "Wrong overall WS Test 1");
            Assert.AreEqual(thisDist.sectorWS_Ratio[0] * thisDist.WS, 4.993328, 0.01, "Wrong WS in WD 0 Test 1");
            Assert.AreEqual(thisDist.sectorWS_Ratio[4] * thisDist.WS, 5.192708, 0.01, "Wrong WS in WD 4 Test 1");
            Assert.AreEqual(thisDist.sectorWS_Ratio[13] * thisDist.WS, 6.9277, 0.01, "Wrong WS in WD 13 Test 1");
            Assert.AreEqual(thisDist.sectorWS_Ratio[15] * thisDist.WS, 5.627835, 0.01, "Wrong WS in WD 15 Test 1");

            // Test 2 - 3
            thisInst.ResetTimeSeries();
            thisInst.metList.numTOD = 2;
            thisInst.metList.RunMCP(ref thisMet, thisMERRA, thisInst, MCP_Method);
            thisInst.metList.isMCPd = true;

            thisDist = thisMet.CalcLT_WSWD_Dists(80, Met.TOD.Day, Met.Season.All, thisInst, thisMet.mcp.LT_WS_Ests);

            Assert.AreEqual(thisDist.WS, 6.296237, 0.01, "Wrong overall WS Test 2");
            Assert.AreEqual(thisDist.sectorWS_Ratio[0] * thisDist.WS, 4.80529, 0.01, "Wrong WS in WD 0 Test 2");
            Assert.AreEqual(thisDist.sectorWS_Ratio[2] * thisDist.WS, 5.194316, 0.01, "Wrong WS in WD 2 Test 2");
            Assert.AreEqual(thisDist.sectorWS_Ratio[8] * thisDist.WS, 6.918986, 0.01, "Wrong WS in WD 8 Test 2");
            Assert.AreEqual(thisDist.sectorWS_Ratio[15] * thisDist.WS, 5.327543, 0.01, "Wrong WS in WD 15 Test 2");

            thisDist = thisMet.CalcLT_WSWD_Dists(80, Met.TOD.Night, Met.Season.All, thisInst, thisMet.mcp.LT_WS_Ests);

            Assert.AreEqual(thisDist.WS, 6.83764, 0.01, "Wrong overall WS Test 3");
            Assert.AreEqual(thisDist.sectorWS_Ratio[0] * thisDist.WS, 5.182166, 0.01, "Wrong WS in WD 0 Test 3");
            Assert.AreEqual(thisDist.sectorWS_Ratio[5] * thisDist.WS, 5.764806, 0.01, "Wrong WS in WD 2 Test 3");
            Assert.AreEqual(thisDist.sectorWS_Ratio[12] * thisDist.WS, 7.685679, 0.01, "Wrong WS in WD 8 Test 3");
            Assert.AreEqual(thisDist.sectorWS_Ratio[15] * thisDist.WS, 5.916732, 0.01, "Wrong WS in WD 15 Test 3");

            // Test 4 - 7
            thisInst.ResetTimeSeries();
            thisInst.metList.numTOD    = 1;
            thisInst.metList.numSeason = 4;
            thisInst.metList.RunMCP(ref thisMet, thisMERRA, thisInst, MCP_Method);
            thisInst.metList.isMCPd = true;

            thisDist = thisMet.CalcLT_WSWD_Dists(80, Met.TOD.All, Met.Season.Winter, thisInst, thisMet.mcp.LT_WS_Ests);

            Assert.AreEqual(thisDist.WS, 7.413855, 0.01, "Wrong overall WS Test 4");
            Assert.AreEqual(thisDist.sectorWS_Ratio[0] * thisDist.WS, 5.1053, 0.01, "Wrong WS in WD 0 Test 4");
            Assert.AreEqual(thisDist.sectorWS_Ratio[4] * thisDist.WS, 5.0283, 0.01, "Wrong WS in WD 4 Test 4");
            Assert.AreEqual(thisDist.sectorWS_Ratio[8] * thisDist.WS, 8.429297, 0.01, "Wrong WS in WD 8 Test 4");
            Assert.AreEqual(thisDist.sectorWS_Ratio[15] * thisDist.WS, 6.318312, 0.01, "Wrong WS in WD 15 Test 4");

            thisDist = thisMet.CalcLT_WSWD_Dists(80, Met.TOD.All, Met.Season.Spring, thisInst, thisMet.mcp.LT_WS_Ests);

            Assert.AreEqual(thisDist.WS, 7.015339, 0.01, "Wrong overall WS Test 5");
            Assert.AreEqual(thisDist.sectorWS_Ratio[2] * thisDist.WS, 6.313987, 0.01, "Wrong WS in WD 2 Test 5");
            Assert.AreEqual(thisDist.sectorWS_Ratio[6] * thisDist.WS, 6.10201, 0.01, "Wrong WS in WD 6 Test 5");
            Assert.AreEqual(thisDist.sectorWS_Ratio[12] * thisDist.WS, 8.21204, 0.01, "Wrong WS in WD 12 Test 5");

            thisDist = thisMet.CalcLT_WSWD_Dists(80, Met.TOD.All, Met.Season.Summer, thisInst, thisMet.mcp.LT_WS_Ests);

            Assert.AreEqual(thisDist.WS, 5.344627, 0.01, "Wrong overall WS Test 6");
            Assert.AreEqual(thisDist.sectorWS_Ratio[0] * thisDist.WS, 4.7078, 0.01, "Wrong WS in WD 2 Test 6");
            Assert.AreEqual(thisDist.sectorWS_Ratio[4] * thisDist.WS, 4.88008, 0.01, "Wrong WS in WD 6 Test 6");
            Assert.AreEqual(thisDist.sectorWS_Ratio[14] * thisDist.WS, 4.95684, 0.01, "Wrong WS in WD 12 Test 6");

            thisDist = thisMet.CalcLT_WSWD_Dists(80, Met.TOD.All, Met.Season.Fall, thisInst, thisMet.mcp.LT_WS_Ests);

            Assert.AreEqual(thisDist.WS, 6.50441, 0.01, "Wrong overall WS Test 7");
            Assert.AreEqual(thisDist.sectorWS_Ratio[1] * thisDist.WS, 4.96994, 0.01, "Wrong WS in WD 1 Test 7");
            Assert.AreEqual(thisDist.sectorWS_Ratio[3] * thisDist.WS, 5.28866, 0.01, "Wrong WS in WD 3 Test 7");
            Assert.AreEqual(thisDist.sectorWS_Ratio[9] * thisDist.WS, 8.097313, 0.01, "Wrong WS in WD 9 Test 7");

            // Test 9
            thisInst.ResetTimeSeries();
            thisInst.metList.numTOD    = 2;
            thisInst.metList.numSeason = 4;
            thisInst.metList.numWD     = 24;
            thisInst.metList.RunMCP(ref thisMet, thisMERRA, thisInst, MCP_Method);
            thisInst.metList.isMCPd = true;

            thisDist = thisMet.CalcLT_WSWD_Dists(80, Met.TOD.Night, Met.Season.Summer, thisInst, thisMet.mcp.LT_WS_Ests);

            Assert.AreEqual(thisDist.WS, 5.76306, 0.01, "Wrong overall WS Test 9");
            Assert.AreEqual(thisDist.sectorWS_Ratio[0] * thisDist.WS, 4.90395, 0.01, "Wrong WS in WD 0 Test 4");
            Assert.AreEqual(thisDist.sectorWS_Ratio[11] * thisDist.WS, 5.706386, 0.01, "Wrong WS in WD 4 Test 4");
            Assert.AreEqual(thisDist.sectorWS_Ratio[20] * thisDist.WS, 5.528143, 0.01, "Wrong WS in WD 8 Test 4");
            Assert.AreEqual(thisDist.sectorWS_Ratio[23] * thisDist.WS, 5.174853, 0.01, "Wrong WS in WD 15 Test 4");

            thisInst.Close();
        }
        public void Changing_Num_MERRA_Nodes_Test()
        {
            Continuum thisInst = new Continuum("");

            thisInst.isTest = true;

            string fileName = "C:\\Users\\liz_w\\Desktop\\Continuum 3 GUI Testing\\SaveFolder\\MERRA_Node_Test";

            thisInst.savedParams.savedFileName = fileName + ".cfm";

            if (File.Exists(fileName + ".cfm"))
            {
                File.Delete(fileName + ".cfm");
                File.Delete(fileName + ".mdf");
                File.Delete(fileName + "_log.ldf");
            }

            thisInst.UTM_conversions.savedDatumIndex = 0;
            thisInst.UTM_conversions.UTMZoneNumber   = 16;
            thisInst.UTM_conversions.hemisphere      = "Northern";

            thisInst.modeledHeight = 80;
            thisInst.SaveFile(true);

            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // Load one met TS
            thisInst.metList.isTimeSeries      = true;
            thisInst.metList.filteringEnabled  = true;
            thisInst.turbineList.genTimeSeries = true;

            string metTSFile = testingFolder + "\\Met TS files\\Findlay\\Archbold TS short 16 MERRA test.csv";

            thisInst.metList.ImportFilterExtrapMetData(metTSFile, thisInst); // Reads in formatted .csv file, filters and extrapolates to modeled height

            thisInst.metList.numWD = Convert.ToInt16(thisInst.cboMCPNumWD.SelectedItem);
            thisInst.metList.numWS = 30;

            string metName = thisInst.metList.metItem[thisInst.metList.ThisCount - 1].name;
            Met    thisMet = thisInst.metList.GetMet(metName);

            thisMet.metData.FindStartEndDatesWithMaxRecovery();

            thisInst.metList.isMCPd = false;
            thisMet.CalcAllMeas_WSWD_Dists(thisInst, thisMet.metData.GetSimulatedTimeSeries(thisInst.modeledHeight));

            thisInst.updateThe.AllTABs(thisInst);

            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            /// Load one MERRA node
            thisMet = thisInst.metList.metItem[0];
            thisInst.dateMERRAStart.Value = Convert.ToDateTime("1/1/2008 12:00:00 AM");
            thisInst.dateMERRAEnd.Value   = Convert.ToDateTime("12/31/2009 11:00:00 PM");
            UTM_conversion.Lat_Long theseLL = thisInst.UTM_conversions.UTMtoLL(thisMet.UTMX, thisMet.UTMY);
            int    offset      = thisInst.UTM_conversions.GetUTC_Offset(theseLL.latitude, theseLL.longitude);
            string merraFolder = "C:\\Users\\liz_w\\Desktop\\MERRA2";

            thisInst.merraList.MERRAfolder = merraFolder;

            thisInst.merraList.AddMERRA_GetDataFromTextFiles(theseLL.latitude, theseLL.longitude, offset, thisInst, thisMet, true);

            while (thisInst.BW_worker.DoWorkDone == false && thisInst.BW_worker.WasReturned == false) // RunWorkerCompleted isn't getting called (?) so killing BW_Worker once it reaches end of DoWork
            {
                Thread.Sleep(1000);
            }

            if (thisInst.BW_worker.WasReturned)
            {
                Assert.Fail();
            }

            thisInst.BW_worker.Close();

            Assert.AreEqual(thisInst.merraList.merraData[0].MERRA_Nodes.Length, 1, "Didn't load one MERRA node");

            // Change to 4 MERRA nodes
            thisInst.cboNumMERRA_Nodes.SelectedIndex = 1;

            thisInst.merraList.AddMERRA_GetDataFromTextFiles(theseLL.latitude, theseLL.longitude, offset, thisInst, thisMet, true);

            while (thisInst.BW_worker.DoWorkDone == false && thisInst.BW_worker.WasReturned == false) // RunWorkerCompleted isn't getting called (?) so killing BW_Worker once it reaches end of DoWork
            {
                Thread.Sleep(1000);
            }

            if (thisInst.BW_worker.WasReturned)
            {
                Assert.Fail();
            }

            Assert.AreEqual(thisInst.merraList.merraData[0].MERRA_Nodes.Length, 4, "Didn't load four MERRA nodes");
            thisInst.BW_worker.Close();

            // Change to 16 MERRA nodes
            thisInst.cboNumMERRA_Nodes.SelectedIndex = 2;
            thisInst.merraList.AddMERRA_GetDataFromTextFiles(theseLL.latitude, theseLL.longitude, offset, thisInst, thisMet, true);

            while (thisInst.BW_worker.DoWorkDone == false && thisInst.BW_worker.WasReturned == false) // RunWorkerCompleted isn't getting called (?) so killing BW_Worker once it reaches end of DoWork
            {
                Thread.Sleep(1000);
            }

            if (thisInst.BW_worker.WasReturned)
            {
                Assert.Fail();
            }

            Assert.AreEqual(thisInst.merraList.merraData[0].MERRA_Nodes.Length, 16, "Didn't load 16 MERRA nodes");
            thisInst.BW_worker.Close();

            thisInst.Close();
        }
Example #15
0
        public void Calc_Wind_Rose_Test()
        {
            Continuum thisInst = new Continuum("");

            string Filename = testingFolder + "\\MERRA_Testing.cfm";

            thisInst.Open(Filename);

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

            UTM_conversion.Lat_Long theseLL = thisInst.UTM_conversions.UTMtoLL(thisMet.UTMX, thisMet.UTMY);
            MERRA merra = thisInst.merraList.GetMERRA(theseLL.latitude, theseLL.longitude);

            // Test 1: All Months, all years
            double[] thisWR  = merra.Calc_Wind_Rose(100, 100, thisInst.UTM_conversions); // all years all months
            string   WR_file = testingFolder + "\\Calc_Wind_Rose\\All Months All Years Wind Rose.csv";

            StreamReader sr = new StreamReader(WR_file);

            for (int i = 0; i < thisInst.metList.numWD; i++)
            {
                double fileFreq = Convert.ToDouble(sr.ReadLine());
                Assert.AreEqual(fileFreq, thisWR[i], 0.001, "Wrong freq in Test 1 WD " + i);
            }

            sr.Close();

            // Test 2: March 2009
            thisWR  = merra.Calc_Wind_Rose(3, 2009, thisInst.UTM_conversions); // March 2009
            WR_file = testingFolder + "\\Calc_Wind_Rose\\March 2009 Wind Rose.csv";

            sr = new StreamReader(WR_file);

            for (int i = 0; i < thisInst.metList.numWD; i++)
            {
                double fileFreq = Convert.ToDouble(sr.ReadLine());
                Assert.AreEqual(fileFreq, thisWR[i], 0.001, "Wrong freq in Test 2 WD " + i);
            }

            sr.Close();

            // Test 3: June All Years
            thisWR  = merra.Calc_Wind_Rose(6, 100, thisInst.UTM_conversions); // June LT
            WR_file = testingFolder + "\\Calc_Wind_Rose\\June All Years Wind Rose.csv";

            sr = new StreamReader(WR_file);

            for (int i = 0; i < thisInst.metList.numWD; i++)
            {
                double fileFreq = Convert.ToDouble(sr.ReadLine());
                Assert.AreEqual(fileFreq, thisWR[i], 0.001, "Wrong freq in Test 3 WD " + i);
            }

            sr.Close();

            // Test 4: 2010 All Months
            thisWR  = merra.Calc_Wind_Rose(100, 2010, thisInst.UTM_conversions); // 2010
            WR_file = testingFolder + "\\Calc_Wind_Rose\\2010 Wind Rose.csv";

            sr = new StreamReader(WR_file);

            for (int i = 0; i < thisInst.metList.numWD; i++)
            {
                double fileFreq = Convert.ToDouble(sr.ReadLine());
                Assert.AreEqual(fileFreq, thisWR[i], 0.001, "Wrong freq in Test 4 WD " + i);
            }

            sr.Close();

            thisInst.Close();
        }