Ejemplo n.º 1
0
        //to make it easy to interface from matlab etc.
        public bool Mat_AddOutputVariable(SmOutput.OutputType hydraulicType, string name, bool mean, bool std, bool min, bool max, bool median)
        {
            EnsembleStatistics stats = new EnsembleStatistics();

            stats.SetStats(mean, std, min, max, median);
            AddOutputVariable(hydraulicType, stats, name);
            return(true);
        }
Ejemplo n.º 2
0
        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();
            }
        }
Ejemplo n.º 3
0
        public bool AddOutputVariable(SmOutput.OutputType hydraulicType, EnsembleStatistics stats, string name)
        {
            EnsOutput xouts = new EnsOutput(stats);

            xouts.name          = name;
            xouts.hydraulicType = hydraulicType;
            MainModel model = models[0];

            switch (hydraulicType)
            {
            case SmOutput.OutputType.linkFlowTimeSeries:
                break;

            case SmOutput.OutputType.nodeVolume:
                xouts.nodex = models[0].getNode(name);
                break;

            case SmOutput.OutputType.GlobalVolumen:
                break;

            case SmOutput.OutputType.outletFlowTimeSeries:

                bool bsuccess = false;
                foreach (int i in model.iOutlets)
                {
                    if (model.Nodes[i].name == name)
                    {
                        xouts.outletx = new Outlet[models.Length];


                        for (int j = 0; j < models.Length; j++)
                        {
                            xouts.outletx[j] = (Outlet)models[j].Nodes[i];
                        }
                        bsuccess = true;
                    }
                }
                if (!bsuccess)
                {
                    throw new Exception("could not find output variable " + name);
                }
                break;

            default:
                break;
            }

            outputCollection.addNewDataSeries(xouts);
            return(true);
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
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]);
                    }
                }
            }
        }