コード例 #1
0
ファイル: EnsOutput.cs プロジェクト: Moboha/DtuSmModels
        public EnsOutput(EnsembleStatistics statistics)
        {
            stats = statistics;
            int NstatTypes = stats.types.Length;

            dataSeries = new SmOutput[NstatTypes];

            for (int i = 0; i < NstatTypes; i++)
            {
                dataSeries[i] = new SmOutput();
            }
        }
コード例 #2
0
        public bool Mat_AddOutputVariableLinkFlow(string fromNode, string toNode, string name, bool mean, bool std, bool min, bool max, bool median)
        {
            SmOutput.OutputType hydraulicType = SmOutput.OutputType.linkFlowTimeSeries;
            EnsembleStatistics  stats         = new EnsembleStatistics();

            stats.SetStats(mean, std, min, max, median);
            EnsOutput xouts = new EnsOutput(stats);

            xouts.name          = name;
            xouts.hydraulicType = hydraulicType;
            MainModel         model = models[0];
            List <Connection> cons  = model.getConnections();
            int fromIndex           = model.getNode(fromNode).index;
            int toIndex             = model.getNode(toNode).index;

            bool bsuccess = false;

            for (int i = 0; i < cons.Count; i++)
            {
                if (cons[i].from == fromIndex && cons[i].to == toIndex)
                {
                    SmOutput xout = new SmOutput();
                    xout.name = name;
                    xouts.con = new Connection[models.Length];


                    for (int j = 0; j < models.Length; j++)
                    {
                        xouts.con[j] = models[j].Connections[i];
                    }
                }

                bsuccess = true;
            }
            if (!bsuccess)
            {
                throw new Exception("could not find output variable " + name);
            }

            outputCollection.addNewDataSeries(xouts);
            return(true);
        }
コード例 #3
0
        private void AddEnsembleOutputFromParameterTable(string[,] paramTable, int ix)
        {
            bool[] ensStats = new bool[5];

            for (int i = ix; i < paramTable.Length; i++)
            {
                if (paramTable[i, 0] == "[EndSect]")
                {
                    return;
                }
                if (paramTable[i, 0] == "<Stats>")
                {
                    string[] split = paramTable[i, 1].Split(new Char[] { ' ', '\t', '=', ',', '(', ')', ';' }, StringSplitOptions.RemoveEmptyEntries);
                    ensStats = new bool[split.Length];
                    for (int j = 0; j < split.Length; j++)
                    {
                        ensStats[j] = (split[j] == "1");
                    }
                }
                if (paramTable[i, 0] == "<output>")
                {
                    switch (paramTable[i, 1])
                    {
                    case "Flow":
                        Mat_AddOutputVariableLinkFlow(paramTable[i, 2], paramTable[i, 3], paramTable[i, 4], ensStats[0], ensStats[1], ensStats[2], ensStats[3], ensStats[4]);
                        break;

                    case "Vol":
                        Mat_AddOutputVariable(SmOutput.OutputType.nodeVolume, paramTable[i, 2], ensStats[0], ensStats[1], ensStats[2], ensStats[3], ensStats[4]);
                        break;

                    case "outletFlow":
                        Mat_AddOutputVariable(SmOutput.OutputType.outletFlowTimeSeries, paramTable[i, 2], ensStats[0], ensStats[1], ensStats[2], ensStats[3], ensStats[4]);
                        break;

                    case "GlobalVolume":
                        // addOutputVariable(SmOutput.OutputType.GlobalVolumen);
                        throw new NotImplementedException("Unknown connection type: " + paramTable[i, 1]);
                        break;

                    case "NodeWL":
                        SmOutput.OutputType hydraulicType = SmOutput.OutputType.nodeWaterLevel;
                        EnsembleStatistics  stats         = new EnsembleStatistics();
                        stats.SetStats(ensStats[0], ensStats[1], ensStats[2], ensStats[3], ensStats[4]);
                        EnsOutput xouts = new EnsOutput(stats);
                        xouts.name          = paramTable[i, 4];
                        xouts.hydraulicType = hydraulicType;
                        MainModel model = models[0];
                        xouts.nodex   = model.getNode((paramTable[i, 2]));
                        xouts.derived = new DerivedValue(paramTable[i, 5]);

                        for (int j = 0; j < models.Length; j++)
                        {
                            SmOutput xout = new SmOutput();
                            xout.name = paramTable[i, 4];
                        }
                        outputCollection.addNewDataSeries(xouts);
                        break;

                    default:
                        throw new NotImplementedException("Unknown connection type: " + paramTable[i, 1]);
                    }
                }
            }
        }