Example #1
0
        public override Series CreateScenario(TimeSeriesDatabaseDataSet.ScenarioRow scenario)
        {
            //string s = ConfigurationManager.AppSettings["scenarioList"];
            string fn = this.m_filename;  // TO DO..update scenarioNumber if needed

            if (m_scenarioNumber >= 0 && m_db != null)
            {
                int idx = Array.IndexOf(m_db.GetScenarios().GetNames(), scenario.Name);
                m_scenarioNumber = idx + 1;
            }
            else
            {
                string path = Path.GetDirectoryName(m_filename);
                fn = Path.Combine(path, scenario.Name + ".rdf");
                Logger.WriteLine("Reading series from " + fn);
                if (!File.Exists(fn))
                {
                    Logger.WriteLine("Error: Can't create scenario '" + scenario.Name + "'");
                    return(new Series());
                }
            }

            var rval = new RiverWareSeries(fn, m_objectName, m_slotName, m_scenarioNumber, m_isSnapShot);

            rval.Appearance.LegendText = scenario.Name + " " + Name;
            rval.ScenarioName          = scenario.Name;
            return(rval);
        }
Example #2
0
        /// <summary>
        /// Creates Scenario based on scenaroName as dss filename without extension (.dss)
        /// </summary>
        public override Series CreateScenario(TimeSeriesDatabaseDataSet.ScenarioRow scenario)
        {
            if (scenario.Name == ScenarioName)
            {
                this.Appearance.LegendText = scenario.Name + " " + Name;
                return(this);
            }

            string path = Path.GetDirectoryName(m_filename);
            string fn   = Path.Combine(path, scenario.Name + ".dss");

            Logger.WriteLine("Reading series from " + fn);
            if (!File.Exists(fn))
            {
                Logger.WriteLine("Error: Can't create scenario");
                return(new Series());
            }


            var rval = new HecDssSeries(m_filename, m_dssPath);

            rval.Name = this.Name;
            rval.Appearance.LegendText = scenario.Name + " " + Name;

            rval.SiteID       = this.SiteID;
            rval.TimeInterval = this.TimeInterval;
            return(rval);
        }
Example #3
0
        /// <summary>
        /// Crates Scenario based on scenaroName as xyfile name without extension (.xy)
        /// </summary>
        public override Series CreateScenario(TimeSeriesDatabaseDataSet.ScenarioRow scenario)
        {
            string fn = ConnectionStringUtility.GetFileName(scenario.Path, m_db.DataSource);

            if (fn == m_xyFilename)
            {
                return(this);
            }

            Logger.WriteLine("Reading series from: '" + fn + "'");
            if (!File.Exists(fn))
            {
                Logger.WriteLine("File not found: '" + fn + "'");
                throw new FileNotFoundException();
                //Logger.WriteLine("Error: Can't create scenario");
                //return new Series();
            }

            var rval = new ModsimSeries(fn, modsimName, timeSeriesName);

            rval.Name = this.Name;
            rval.Appearance.LegendText = scenario.Name + " " + Name;
            rval.ScenarioName          = scenario.Name;
            rval.SiteID       = this.SiteID;
            rval.TimeInterval = this.TimeInterval;
            return(rval);
        }
Example #4
0
        public override Series CreateScenario(TimeSeriesDatabaseDataSet.ScenarioRow scenario)
        {
            if (ScenarioName == scenario.Name)
            {
                return(this);
            }

            var sr = m_db.GetNewSeriesRow(false);

            sr.ItemArray = SeriesCatalogRow.ItemArray;


            string cs = sr.ConnectionString;
            string scenario_model_run_id   = ConnectionStringUtility.GetToken(scenario.Path, "model_run_id", "-1");
            string scenario_model_run_name = ConnectionStringUtility.GetToken(scenario.Path, "model_run_name", "");
            string scenario_run_date       = ConnectionStringUtility.GetToken(scenario.Path, "run_date", "");

            cs = ConnectionStringUtility.Modify(cs, "model_run_id", scenario_model_run_id);
            cs = ConnectionStringUtility.Modify(cs, "model_run_name", scenario_model_run_name);
            cs = ConnectionStringUtility.Modify(cs, "run_date", scenario_run_date);

            sr.ConnectionString = cs;
            var s = new HdbModelSeries(m_db, sr);

            s.Appearance.LegendText = BuildScenairoName(scenario_model_run_name, scenario_model_run_id, scenario_run_date)
                                      + " " + Name;
            return(s);
        }
Example #5
0
        private bool HackForUrgsimInputData(TimeSeriesDatabaseDataSet.ScenarioRow scenario,
                                            out string variableName, out string scenarioName)
        {
            variableName = m_variable;
            scenarioName = scenario.Name;
            bool hackRequired = false;

            if (UrgsimUtilitycs.UrgsimPath.Contains("urgsim1/") &&
                m_projection.Contains("inputdata/"))
            {
                hackRequired = true;
                // all input data needs to use /inputdata directory regardless of scenario
                int idx = scenarioName.IndexOf("/");
                if (idx > 0)
                {
                    scenarioName = "inputdata" + scenarioName.Substring(idx);
                }

                if (m_variable.Contains("[cfs]"))
                {
                    if (scenario.Name.Contains("rawflows/"))
                    {  // use file with -raw
                        variableName = m_variable.Replace(" [cfs]", "-raw [cfs]");
                    }
                    else // all other scenarios (operation models)
                    {// use file wtih -bc  (Bias corrected flows)
                        variableName = m_variable.Replace(" [cfs]", "-bc [cfs]");
                    }
                }
            }
            return(hackRequired);
        }
Example #6
0
        public override Series CreateScenario(TimeSeriesDatabaseDataSet.ScenarioRow scenario)
        {
            if (scenario.Name == m_projection)
            {
                return(this);
            }
            var s = new UrgsimSeries(m_path, scenario.Name, m_variable);

            s.TimeInterval = this.TimeInterval;
            return(s);
        }
Example #7
0
        /// <summary>
        /// Create series based on Scenario
        /// Multiple Runs can be in the same file (Specified by Path.ScenarioNumber)
        /// or Multiple Runs each in different file (Path.FileName)
        /// or scenario can be by the Name
        /// examples:  https://github.com/usbr/Pisces/issues/161
        /// </summary>
        /// <param name="scenario"></param>
        /// <returns></returns>
        public override Series CreateScenario(TimeSeriesDatabaseDataSet.ScenarioRow scenario)
        {
            var fn = GetScenarioFileName(scenario);
            int sn = GetScenarioNumber(scenario);

            if (!File.Exists(fn))
            {
                Logger.WriteLine("Error: Can't create scenario '" + scenario.Name + "'");
                return(new Series());
            }

            var rval = new RiverWareSeries(fn, m_objectName, m_slotName, sn, m_isSnapShot);

            rval.Appearance.LegendText = scenario.Name + " " + Name;
            rval.ScenarioName          = scenario.Name;
            return(rval);
        }
Example #8
0
        public override Series CreateScenario(TimeSeriesDatabaseDataSet.ScenarioRow scenario)
        {
            if (scenario.Name == ScenarioName)
            {
                return(this);
            }
            else
            {
                string fn = ConnectionStringUtility.GetFileName(scenario.Path, m_db.DataSource);
                Logger.WriteLine("Reading series from " + fn);
                var sr = m_db.GetNewSeriesRow(false);
                sr.ItemArray = SeriesCatalogRow.ItemArray;

                sr.ConnectionString = ConnectionStringUtility.Modify(sr.ConnectionString, "FileName", fn);
                Series s = new HydrossSeries(m_db, sr);
                s.ReadOnly     = true;
                s.ScenarioName = scenario.Name;
                return(s);
            }
        }
Example #9
0
        public override Series CreateScenario(TimeSeriesDatabaseDataSet.ScenarioRow scenario)
        {
            string scenairoName = scenario.Name;
            string variableName = "";
            string legendText   = "";

            if (HackForUrgsimInputData(scenario, out variableName, out scenairoName))
            {
                legendText = scenario.Name;
            }

            //if (scenairoName == m_projection && m_variable == variableName)
            //{ // not working for Hack
            //    return this;
            //}
            var s = new UrgsimSeries(m_path, scenairoName, variableName, legendText);

            s.TimeInterval = this.TimeInterval;
            return(s);
        }
Example #10
0
        private string GetScenarioFileName(TimeSeriesDatabaseDataSet.ScenarioRow scenario)
        {
            var rval         = m_filename;
            var pathFileName = ConnectionStringUtility.GetFileName(scenario.Path, m_db.Server.DataSource);

            if (File.Exists(pathFileName)) // filename specified in path
            {
                rval = pathFileName;
            }
            else
            { // derive filename from  ScenarioName
                var path = Path.GetDirectoryName(m_filename);
                var x    = Path.Combine(path, scenario.Name + ".rdf");
                if (File.Exists(x))
                {
                    rval = x;
                }
            }

            return(rval);
        }
Example #11
0
        private int GetScenarioNumber(TimeSeriesDatabaseDataSet.ScenarioRow scenario)
        {
            var sn = ConnectionStringUtility.GetIntFromConnectionString(scenario.Path, "ScenarioNumber");

            if (sn >= 0) // scenario number specified (use existing filename)
            {
                return(sn);
            }

            if (m_scenarioNumber >= 0 && m_db != null)
            {
                int idx = Array.IndexOf(m_db.GetScenarios().GetNames(), scenario.Name);
                if (idx >= 0)
                {
                    sn = idx + 1;
                }
            }
            else
            {
                sn = m_scenarioNumber;
            }
            return(sn);
        }