示例#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();
        }
示例#2
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();
        }
示例#3
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();
        }
示例#4
0
        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();
        }
示例#5
0
        public void GetMaxHourlyWindSpeeds_Test()
        {
            Continuum thisInst = new Continuum("");

            string Filename = testingFolder + "\\GetMaxHourlyWindSpeeds\\GetMaxHourlyWindSpeeds test.cfm";

            thisInst.Open(Filename);

            double thisLat  = 41.0;
            double thisLong = -83.75;

            MERRA thisMERRA = thisInst.merraList.GetMERRA(thisLat, thisLong);

            thisMERRA.GetMERRADataFromDB(thisInst);
            thisMERRA.GetInterpData(thisInst.UTM_conversions);

            Met.MaxYearlyWind[] theseMaxWS = thisMERRA.GetMaxHourlyWindSpeeds();

            Assert.AreEqual(theseMaxWS[0].maxWS, 19.948, 0.001, "Wrong Max WS Year 2000");
            Assert.AreEqual(theseMaxWS[2].maxWS, 23.496, 0.001, "Wrong Max WS Year 2002");
            Assert.AreEqual(theseMaxWS[6].maxWS, 21.704, 0.001, "Wrong Max WS Year 2006");
            Assert.AreEqual(theseMaxWS[10].maxWS, 20.305, 0.001, "Wrong Max WS Year 2010");

            thisInst.Close();
        }
示例#6
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();
        }
        /// <summary> Returns MERRA object with specified latitude and longitude. </summary>
        public MERRA GetMERRA(double latitude, double longitude)
        {
            MERRA thisMERRA = new MERRA();

            for (int i = 0; i < numMERRA_Data; i++)
            {
                if (merraData[i].interpData.Coords.latitude == Math.Round(latitude, 3) && merraData[i].interpData.Coords.longitude == Math.Round(longitude, 3))
                {
                    thisMERRA = merraData[i];
                }
            }

            return(thisMERRA);
        }
示例#8
0
        public void Calc_MERRA2_WS_WD_Test()
        {
            string       UVfile = testingFolder + "\\Calc_MERRA_WS_WD\\U50_V50_WS.csv";
            StreamReader srUVs  = new StreamReader(UVfile);

            MERRA.East_North_WSs[] theseUVs = new MERRA.East_North_WSs[3];
            MERRA thisMERRA = new MERRA();

            thisMERRA.Size_East_North_WS_Data(ref theseUVs, 2);

            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 2; j++)
                {
                    string   theseUVstr = srUVs.ReadLine();
                    string[] UVs        = theseUVstr.Split(',');

                    theseUVs[i].U50[j] = Convert.ToDouble(UVs[0]);
                    theseUVs[i].V50[j] = Convert.ToDouble(UVs[1]);
                }
            }

            MERRA.MERRA_Pull[] theseMERRA = new MERRA.MERRA_Pull[3];
            Array.Resize(ref theseMERRA[0].Data, 2);
            Array.Resize(ref theseMERRA[1].Data, 2);
            Array.Resize(ref theseMERRA[2].Data, 2);

            thisMERRA.Calc_MERRA2_WS_WD(ref theseMERRA, theseUVs);

            Assert.AreEqual(4.07736, theseMERRA[0].Data[0].WS50m, 0.01, "Wrong WS Node 1 Hour 1");
            Assert.AreEqual(284.9041, theseMERRA[0].Data[0].WD50m, 0.01, "Wrong WD Node 1 Hour 1");

            Assert.AreEqual(5.18769, theseMERRA[0].Data[1].WS50m, 0.01, "Wrong WS Node 1 Hour 2");
            Assert.AreEqual(237.5902, theseMERRA[0].Data[1].WD50m, 0.01, "Wrong WD Node 1 Hour 2");

            Assert.AreEqual(4.7727, theseMERRA[1].Data[0].WS50m, 0.01, "Wrong WS Node 2 Hour 1");
            Assert.AreEqual(81.1243, theseMERRA[1].Data[0].WD50m, 0.01, "Wrong WD Node 2 Hour 1");

            Assert.AreEqual(5.70873, theseMERRA[1].Data[1].WS50m, 0.01, "Wrong WS Node 2 Hour 2");
            Assert.AreEqual(99.0641, theseMERRA[1].Data[1].WD50m, 0.01, "Wrong WD Node 2 Hour 2");

            Assert.AreEqual(1.24520, theseMERRA[2].Data[0].WS50m, 0.01, "Wrong WS Node 3 Hour 1");
            Assert.AreEqual(342.719, theseMERRA[2].Data[0].WD50m, 0.01, "Wrong WD Node 3 Hour 1");

            Assert.AreEqual(5.0064, theseMERRA[2].Data[1].WS50m, 0.01, "Wrong WS Node 3 Hour 2");
            Assert.AreEqual(272.743, theseMERRA[2].Data[1].WD50m, 0.01, "Wrong WD Node 3 Hour 2");

            srUVs.Close();
        }
示例#9
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();
        }
示例#10
0
        public void GetInterpData_Test()
        {
            Continuum thisInst = new Continuum("");

            string Filename = testingFolder + "\\GetInterpData test.cfm";

            thisInst.Open(Filename);
            thisInst.merraList.MERRAfolder = MERRA2Folder;

            // Test site
            double thisLat  = 41.23;
            double thisLong = -83.4;
            Met    thisMet  = new Met();

            thisInst.merraList.numMERRA_Nodes = 4;
            thisInst.merraList.AddMERRA_GetDataFromTextFiles(thisLat, thisLong, -5, thisInst, thisMet, true);

            while (thisInst.BW_worker.DoWorkDone == false && thisInst.BW_worker.WasReturned == false && thisInst.BW_worker.IsBusy()) // 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();
            }

            MERRA thisMERRA = thisInst.merraList.GetMERRA(thisLat, thisLong);


            Assert.AreEqual(thisMERRA.interpData.TS_Data[226].WS50m, 14.60535, 0.001, "Wrong interp WS Index 226");
            Assert.AreEqual(thisMERRA.interpData.TS_Data[1000].WS50m, 6.364464, 0.001, "Wrong interp WS Index 1000");
            Assert.AreEqual(thisMERRA.interpData.TS_Data[2475].WS50m, 6.745679, 0.001, "Wrong interp WS Index 2475");
            Assert.AreEqual(thisMERRA.interpData.TS_Data[4444].WS50m, 4.426161, 0.001, "Wrong interp WS Index 4444");

            Assert.AreEqual(thisMERRA.interpData.TS_Data[226].WD50m, 220.7011, 0.01, "Wrong interp WD Index 226");
            Assert.AreEqual(thisMERRA.interpData.TS_Data[1000].WD50m, 347.4748, 0.01, "Wrong interp WD Index 1000");
            Assert.AreEqual(thisMERRA.interpData.TS_Data[2475].WD50m, 131.8697, 0.01, "Wrong interp WD Index 2475");
            Assert.AreEqual(thisMERRA.interpData.TS_Data[4444].WD50m, 44.31306, 0.01, "Wrong interp WD Index 4444");

            thisInst.Close();
        }
示例#11
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();
        }
示例#12
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();
        }
示例#13
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();
        }
        /// <summary> Deletes MERRA data from list. </summary>
        public void deleteMERRA(double latitude, double longitude)
        {
            int newCount = numMERRA_Data - 1;

            if (newCount > 0)
            {
                MERRA[] tempList  = new MERRA[newCount]; // Create list of met towers that you//re keeping(so size one less than before)
                int     tempIndex = 0;

                for (int i = 0; i < numMERRA_Data; i++)
                {
                    if (merraData[i].interpData.Coords.latitude != Math.Round(latitude, 3) && merraData[i].interpData.Coords.longitude != Math.Round(longitude, 3))
                    {
                        tempList[tempIndex] = merraData[i];
                        tempIndex++;
                    }
                }
                merraData = tempList;
            }
            else
            {
                merraData = new MERRA[0];
            }
        }
示例#15
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();
        }
示例#16
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();
        }
示例#17
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();
        }
        /// <summary> Adds new MERRA object to list. Figures out if additional MERRA nodes need to be uploaded from textfiles.
        ///    Runs MCP at Met site (if thisMet not null) if have all MERRA node data. Calls BW worker to upload additional data if needed. </summary>
        public void AddMERRA_GetDataFromTextFiles(double thisLat, double thisLong, int offset, Continuum thisInst, Met thisMet, bool isTest)
        {
            // Create new MERRA object and assign lat, long, and node lat/long
            MERRA thisMERRA = new MERRA();

            thisMERRA.Set_Interp_LatLon_Dates_Offset(thisLat, thisLong, offset, thisInst);
            thisMERRA.numMERRA_Nodes = numMERRA_Nodes;
            thisMERRA.MERRA_Nodes    = new MERRA.MERRA_Node_Data[numMERRA_Nodes];

            if (thisMet.name == null)
            {
                thisMERRA.isUserDefined = true;
            }

            if (MERRAfolder == "")
            {
                try
                {
                    MessageBox.Show("Please select folder containing MERRA2 data .ascii files.");
                    if (thisInst.fbd_MERRAData.ShowDialog() == DialogResult.OK)
                    {
                        MERRAfolder = thisInst.fbd_MERRAData.SelectedPath;
                    }
                    else
                    {
                        return;
                    }

                    SetMERRA2LatLong(thisInst);
                }
                catch
                {
                    MessageBox.Show("Folder path not valid.", "", MessageBoxButtons.OK);
                    return;
                }
            }

            // Figure out if MERRA textfile has the necessary lat/long range and get MERRA node coordinates
            bool gotCoords = thisMERRA.Find_MERRA_Coords(MERRAfolder);

            if (gotCoords == false)
            {
                return;
            }

            DialogResult doMCP = DialogResult.No;

            if (thisMet.name != null && isTest == false && (thisInst.metList.ThisCount == 1 || thisInst.metList.isMCPd == false))
            {
                doMCP = MessageBox.Show("Do you want to conduct MCP at selected met?", "Continuum 3.0", MessageBoxButtons.YesNo);
            }
            else if (thisMet.name != "" && isTest == false && thisInst.metList.ThisCount > 1 && thisInst.metList.isMCPd == true)
            {
                doMCP = DialogResult.Yes;
            }
            else if (isTest == true)
            {
                doMCP = DialogResult.No;
            }

            if (doMCP == DialogResult.Yes)
            {
                thisInst.metList.isMCPd = true;
                thisInst.modelList.ClearAllExceptImported();
                thisInst.turbineList.ClearAllWSEsts();
                thisInst.turbineList.ClearAllGrossEsts();
                thisInst.turbineList.ClearAllNetEsts();
                thisInst.mapList.ClearAllMaps();
                thisInst.metPairList.ClearAll();
            }

            // Figure out what MERRA nodes need to be downloaded
            UTM_conversion.Lat_Long[] requiredMERRANode = GetRequiredNewMERRANodeCoords(thisLat, thisLong, thisInst);

            if (requiredMERRANode.Length != 0)
            {
                MERRA.MERRA_Pull[] nodesToPull = new MERRA.MERRA_Pull[requiredMERRANode.Length];

                for (int i = 0; i < requiredMERRANode.Length; i++)
                {
                    nodesToPull[i].Coords.latitude  = requiredMERRANode[i].latitude;
                    nodesToPull[i].Coords.longitude = requiredMERRANode[i].longitude;
                    nodesToPull[i].UTM = thisInst.UTM_conversions.LLtoUTM(nodesToPull[i].Coords.latitude, nodesToPull[i].Coords.longitude);
                }

                // Check to see that MERRA data files have required lat/long and assign XInd and YInd
                bool gotIndices = thisMERRA.GetMERRAPullXYIndices(ref nodesToPull, MERRAfolder);

                if (gotIndices == false)
                {
                    return;
                }

                BackgroundWork.Vars_for_MERRA Vars_for_MERRA = new BackgroundWork.Vars_for_MERRA();
                Vars_for_MERRA.thisInst    = thisInst;
                Vars_for_MERRA.thisMERRA   = thisMERRA;
                Vars_for_MERRA.MCP_type    = thisInst.Get_MCP_Method();
                Vars_for_MERRA.thisMet     = thisMet;
                Vars_for_MERRA.nodesToPull = nodesToPull;

                thisInst.BW_worker = new BackgroundWork();
                thisInst.BW_worker.Call_BW_MERRA2_Import(Vars_for_MERRA);
            }
            else
            {
                // Have all necessary MERRA nodes and user wants to do MCP so.... Run MCP!

                // Add MERRA object to list
                Array.Resize(ref merraData, numMERRA_Data + 1);
                merraData[numMERRA_Data - 1] = thisMERRA;
                thisMERRA.GetMERRADataFromDB(thisInst);
                thisMERRA.GetInterpData(thisInst.UTM_conversions);

                if (doMCP == DialogResult.Yes)
                {
                    thisMet.WSWD_Dists = new Met.WSWD_Dist[0];
                    thisInst.metList.RunMCP(ref thisMet, thisMERRA, thisInst, thisInst.Get_MCP_Method());
                    thisMet.CalcAllLT_WSWD_Dists(thisInst, thisMet.mcp.LT_WS_Ests); // Calculates LT wind speed / wind direction distributions for using all day and using each season and each time of day (Day vs. Night)
                    thisInst.updateThe.AllTABs(thisInst);
                }
                else
                {
                    thisInst.updateThe.MERRA_Dropdowns(thisInst);
                    thisInst.updateThe.MERRA_TAB(thisInst);
                }
            }
        }