コード例 #1
0
        public void Method_Of_Bins_Test()
        {
            // Test Method of Bins method
            // Loop through WD, TOD, Season, and WS width (0.5 and 1.0 m/s)
            Continuum thisInst = new Continuum("");
            string    fileName = "C:\\Users\\liz_w\\Desktop\\Continuum 3 GUI Testing\\SaveFolder\\OneMetTSNotFiltWithMERRAAndMCP_1";

            thisInst.Open(fileName + ".cfm");
            thisInst.isTest = true;
            thisInst.cboMCP_Type.SelectedIndex = 1;

            Met thisMet = thisInst.GetSelectedMet("MCP");

            Met.WSWD_Dist thisEst = new Met.WSWD_Dist();
            Met.WSWD_Dist lastEst = new Met.WSWD_Dist();

            for (int WD_ind = 0; WD_ind <= 4; WD_ind++)
            {
                for (int TOD_ind = 0; TOD_ind <= 1; TOD_ind++)
                {
                    for (int seasonInd = 0; seasonInd <= 1; seasonInd++)
                    {
                        for (int WS_width_ind = 0; WS_width_ind <= 1; WS_width_ind++)
                        {
                            if (WS_width_ind == 0)
                            {
                                thisInst.txtWS_bin_width.Text = "0.5";
                            }
                            else
                            {
                                thisInst.txtWS_bin_width.Text = "1.0";
                            }

                            thisInst.cboMCPNumHours.SelectedIndex   = TOD_ind;
                            thisInst.cboMCPNumSeasons.SelectedIndex = seasonInd;
                            thisInst.cboMCPNumWD.SelectedIndex      = WD_ind;
                            thisInst.DoMCP();
                            thisEst = thisMet.GetWS_WD_Dist(thisInst.modeledHeight, Met.TOD.All, Met.Season.All);

                            Assert.AreNotEqual(thisEst.WS, lastEst.WS, "LT Estimate did not change with setting change");
                            lastEst = thisEst;
                        }
                    }
                }
            }

            thisInst.Close();
        }
コード例 #2
0
        public void Variance_Ratio_Test()
        {
            // Test Variance Ratio method

            Continuum thisInst = new Continuum("");
            string    fileName = "C:\\Users\\liz_w\\Desktop\\Continuum 3 GUI Testing\\SaveFolder\\OneMetTSNotFiltWithMERRAAndMCP_1";

            thisInst.Open(fileName + ".cfm");
            thisInst.isTest = true;
            thisInst.cboMCP_Type.SelectedIndex = 2;

            Met thisMet = thisInst.GetSelectedMet("MCP");

            Met.WSWD_Dist thisEst = new Met.WSWD_Dist();
            Met.WSWD_Dist lastEst = new Met.WSWD_Dist();

            for (int WD_ind = 0; WD_ind <= 4; WD_ind++)
            {
                for (int TOD_ind = 0; TOD_ind <= 1; TOD_ind++)
                {
                    for (int seasonInd = 0; seasonInd <= 1; seasonInd++)
                    {
                        thisInst.cboMCPNumHours.SelectedIndex   = TOD_ind;
                        thisInst.cboMCPNumSeasons.SelectedIndex = seasonInd;
                        thisInst.cboMCPNumWD.SelectedIndex      = WD_ind;
                        thisInst.DoMCP();
                        thisEst = thisMet.GetWS_WD_Dist(thisInst.modeledHeight, Met.TOD.All, Met.Season.All);

                        Assert.AreNotEqual(thisEst.WS, lastEst.WS, "LT Estimate did not change with setting change");
                        lastEst = thisEst;
                    }
                }
            }

            thisInst.Close();
        }
コード例 #3
0
        /// <summary> Conducts wind speed estimate from Met 1 to Met 2 and vice-versa and calculates WS cross-prediction struct (WS_CrossPreds[,]) </summary>
        public void DoMetCrossPred(int crossPredInd, int radiusIndex, Continuum thisInst)
        {
            int            numWD    = thisInst.metList.numWD;
            int            numNodes = 0;
            NodeCollection nodeList = new NodeCollection();

            if (WS_Pred[crossPredInd, radiusIndex].nodePath == null)
            {
                numNodes = 0;
            }
            else
            {
                numNodes = WS_Pred[crossPredInd, radiusIndex].nodePath.Length;
            }

            if (numNodes > 0)
            {
                WS_Pred[crossPredInd, radiusIndex].nodeWS_Ests1to2       = new double[numNodes];
                WS_Pred[crossPredInd, radiusIndex].nodeSectorWS_Ests1to2 = new double[numNodes, numWD];

                WS_Pred[crossPredInd, radiusIndex].nodeWS_Ests2to1       = new double[numNodes];
                WS_Pred[crossPredInd, radiusIndex].nodeSectorWS_Ests2to1 = new double[numNodes, numWD];
            }

            Nodes[] pathOfNodes;
            Model   thisModel = WS_Pred[crossPredInd, radiusIndex].model;

            // Get WS distributions at each site (used to calculate the cross-prediction percent error)
            Met.WSWD_Dist met1Dist = met1.GetWS_WD_Dist(thisInst.modeledHeight, thisModel.timeOfDay, thisModel.season);
            Met.WSWD_Dist met2Dist = met2.GetWS_WD_Dist(thisInst.modeledHeight, thisModel.timeOfDay, thisModel.season);

            // Conduct cross-prediction from Met 1 to Met 2
            Nodes endNode = nodeList.GetMetNode(met2);

            ModelCollection.WS_Est_Struct WS_EstStr = thisInst.modelList.DoWS_Estimate(met1, endNode, WS_Pred[crossPredInd, radiusIndex].nodePath, thisModel, thisInst);

            // Get sectorwise wind speed and calculate sectorwise percent error (for Met 1 predicting Met 2)
            for (int WD_Ind = 0; WD_Ind < numWD; WD_Ind++)
            {
                WS_Pred[crossPredInd, radiusIndex].sectorWS_Ests[0, WD_Ind] = WS_EstStr.sectorWS[WD_Ind];
                double met2WS = met2Dist.WS * met2Dist.sectorWS_Ratio[WD_Ind];
                WS_Pred[crossPredInd, radiusIndex].percErrSector[0, WD_Ind] = (WS_EstStr.sectorWS[WD_Ind] - met2WS) / met2WS;
            }

            WS_Pred[crossPredInd, radiusIndex].nodeSectorWS_Ests1to2 = WS_EstStr.sectorWS_AtNodes;
            double avgWS    = 0;
            double WR_count = 0;

            // Get overall wind speed at nodes (for Met 1 predicting Met 2)
            for (int nodeInd = 0; nodeInd < numNodes; nodeInd++)
            {
                avgWS    = 0;
                WR_count = 0;
                Nodes    thisNode     = WS_Pred[crossPredInd, radiusIndex].nodePath[nodeInd];
                double[] nodeWindRose = thisInst.metList.GetInterpolatedWindRose(thisModel.metsUsed, thisNode.UTMX, thisNode.UTMY, thisModel.timeOfDay, thisModel.season, thisInst.modeledHeight);

                for (int WD_Ind = 0; WD_Ind < numWD; WD_Ind++)
                {
                    avgWS    = avgWS + nodeWindRose[WD_Ind] * WS_Pred[crossPredInd, radiusIndex].nodeSectorWS_Ests1to2[nodeInd, WD_Ind];
                    WR_count = WR_count + nodeWindRose[WD_Ind];
                }

                WS_Pred[crossPredInd, radiusIndex].nodeWS_Ests1to2[nodeInd] = avgWS / WR_count;
            }

            avgWS    = 0;
            WR_count = 0;

            for (int WD = 0; WD < numWD; WD++)
            {
                avgWS    = avgWS + WS_Pred[crossPredInd, radiusIndex].sectorWS_Ests[0, WD] * met2Dist.windRose[WD];
                WR_count = WR_count + met2Dist.windRose[WD];
            }

            // Calculate avg WS estimate and overall error at Met 2
            avgWS = avgWS / WR_count;
            WS_Pred[crossPredInd, radiusIndex].WS_Ests[0] = avgWS;
            WS_Pred[crossPredInd, radiusIndex].percErr[0] = (avgWS - met2Dist.WS) / met2Dist.WS;

            // Now conduct same calculations but going from Met 2 to Met 1.
            endNode = nodeList.GetMetNode(met1);

            if (numNodes > 0)
            {
                pathOfNodes = new Nodes[numNodes];
            }
            else
            {
                pathOfNodes = null;
            }

            // Reverse order of nodes when going from Met 2 to Met 1
            for (int i = 0; i < numNodes; i++)
            {
                pathOfNodes[i] = WS_Pred[crossPredInd, radiusIndex].nodePath[numNodes - 1 - i];
            }

            // Do WS Estimate for Met 2 predicting Met 1
            WS_EstStr = thisInst.modelList.DoWS_Estimate(met2, endNode, pathOfNodes, thisModel, thisInst);

            // Get sectorwise wind speed and sectorwise percent error (for Met 2 predicting Met 1)
            for (int WD_Ind = 0; WD_Ind < numWD; WD_Ind++)
            {
                WS_Pred[crossPredInd, radiusIndex].sectorWS_Ests[1, WD_Ind] = WS_EstStr.sectorWS[WD_Ind];
                WS_Pred[crossPredInd, radiusIndex].percErrSector[1, WD_Ind] = (WS_EstStr.sectorWS[WD_Ind] - met1Dist.WS * met1Dist.sectorWS_Ratio[WD_Ind])
                                                                              / (met1Dist.WS * met1Dist.sectorWS_Ratio[WD_Ind]);
            }

            WS_Pred[crossPredInd, radiusIndex].nodeSectorWS_Ests2to1 = WS_EstStr.sectorWS_AtNodes;
            avgWS    = 0;
            WR_count = 0;
            // Get overall wind speed at nodes (for Met 2 predicting Met 1)
            for (int nodeInd = 0; nodeInd < numNodes; nodeInd++)
            {
                avgWS    = 0;
                WR_count = 0;
                Nodes    thisNode     = pathOfNodes[nodeInd];
                double[] nodeWindRose = thisInst.metList.GetInterpolatedWindRose(thisModel.metsUsed, thisNode.UTMX, thisNode.UTMY, thisModel.timeOfDay, thisModel.season, thisInst.modeledHeight);

                for (int WD_Ind = 0; WD_Ind < numWD; WD_Ind++)
                {
                    avgWS    = avgWS + nodeWindRose[WD_Ind] * WS_Pred[crossPredInd, radiusIndex].nodeSectorWS_Ests2to1[nodeInd, WD_Ind];
                    WR_count = WR_count + nodeWindRose[WD_Ind];
                }

                WS_Pred[crossPredInd, radiusIndex].nodeWS_Ests2to1[nodeInd] = avgWS / WR_count;
            }

            avgWS    = 0;
            WR_count = 0;
            for (int WD = 0; WD < numWD; WD++)
            {
                avgWS    = avgWS + WS_Pred[crossPredInd, radiusIndex].sectorWS_Ests[1, WD] * met1Dist.windRose[WD];
                WR_count = WR_count + met1Dist.windRose[WD];
            }

            // Calculate avg WS estimate and overall error at Met 1
            avgWS = avgWS / WR_count;
            WS_Pred[crossPredInd, radiusIndex].WS_Ests[1] = avgWS;
            WS_Pred[crossPredInd, radiusIndex].percErr[1] = (avgWS - met1Dist.WS) / met1Dist.WS;
        }