private string getOutputFile(bool isQueryEachYear, OutputIntervalType interval, UnitType source, DataReadingMethodType method)
 {
     return(Path.Combine(getOutputFolder(isQueryEachYear, interval),
                         string.Format("{0}_{1}_{2}_{3}.csv", source, method,
                                       isQueryEachYear ? "each_year" : "all_year",
                                       interval)));
 }
        private string getOutputFolder(bool isQueryEachYear, OutputIntervalType interval)
        {
            string workingpath = Path.Combine(Directory.GetCurrentDirectory(), "extract_test");

            if (!Directory.Exists(workingpath))
            {
                Directory.CreateDirectory(workingpath);
            }

            string yearOption = isQueryEachYear ? "each_year" : "all_year";

            workingpath = Path.Combine(workingpath, yearOption);
            if (!Directory.Exists(workingpath))
            {
                Directory.CreateDirectory(workingpath);
            }

            workingpath = Path.Combine(workingpath, interval.ToString());
            if (!Directory.Exists(workingpath))
            {
                Directory.CreateDirectory(workingpath);
            }

            return(workingpath);
        }
Exemplo n.º 3
0
 public ExtractSWAT_SQLite(string txtinoutPath, OutputIntervalType interval)
 {
     _db3Path = System.IO.Path.Combine(txtinoutPath, getDatabaseName(interval));
     if (!System.IO.File.Exists(_db3Path))
     {
         _db3Path = "";
     }
 }
Exemplo n.º 4
0
 public ExtractSWAT_SQLite(string scenariosDir, string scenarioName, OutputIntervalType interval)
 {
     _db3Path = System.IO.Path.Combine(scenariosDir, scenarioName, "txtinout", getDatabaseName(interval));
     if (!System.IO.File.Exists(_db3Path))
     {
         _db3Path = "";
     }
 }
Exemplo n.º 5
0
        public SQLiteValidation(string scenariosDir, string scenarioName, OutputIntervalType interval)
        {
            _extractSQLite = new ExtractSWAT_SQLite(scenariosDir, scenarioName,interval);
            _extractText = new ExtractSWAT_Text_SWATPlot(scenariosDir,scenarioName);

            _startYear = _extractText.StartYear;
            _endYear = _extractText.EndYear;
        }
Exemplo n.º 6
0
        public SQLiteValidation(string scenariosDir, string scenarioName, OutputIntervalType interval)
        {
            _extractSQLite = new ExtractSWAT_SQLite(scenariosDir, scenarioName, interval);
            _extractText   = new ExtractSWAT_Text_SWATPlot(scenariosDir, scenarioName);

            _startYear = _extractText.StartYear;
            _endYear   = _extractText.EndYear;
        }
Exemplo n.º 7
0
        /// <summary>
        /// Retrieve data columns for given result interval
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public static string getDateColumns(OutputIntervalType type)
        {
            switch (type)
            {
            case OutputIntervalType.DAY: return(DATE_COLUMNS_DAILY);

            case OutputIntervalType.MON: return(DATE_COLUMNS_MONTHLY);

            case OutputIntervalType.YEAR: return(DATE_COLUMNS_YEARLY);

            default: return("");
            }
        }
Exemplo n.º 8
0
        public static string getDatabaseName(OutputIntervalType interval)
        {
            switch (interval)
            {
            case OutputIntervalType.DAY: return("result_627_daily.db3");

            case OutputIntervalType.MON: return("result_627_monthly.db3");

            case OutputIntervalType.YEAR: return("result_627_yearly.db3");

            default: return("");
            }
        }
Exemplo n.º 9
0
        private void getBasicInformation()
        {
            DataTable dt = Extract("select * from ave_annual_basin");

            if (dt.Rows.Count == 0)
            {
                return;
            }

            foreach (DataRow r in dt.Rows)
            {
                RowItem item = new RowItem(r);
                string  name = item.getColumnValue_String("NAME");
                if (name.Equals("START_YEAR_OUTPUT"))
                {
                    _startYear = item.getColumnValue_Int("VALUE");
                }
                else if (name.Equals("END_YEAR"))
                {
                    _endYear = item.getColumnValue_Int("VALUE");
                }
                else if (name.Equals("OUTPUT_INTERVAL"))
                {
                    _interval = (OutputIntervalType)(item.getColumnValue_Int("VALUE"));
                }
            }

            dt        = Extract("select * from hru_info");
            _numofHRU = dt.Rows.Count;

            dt        = Extract("select * from sub_info");
            _numofSub = dt.Rows.Count;

            dt = Extract("select * from sqlite_master where name = 'rsv_info'");
            if (dt.Rows.Count > 0)
            {
                dt        = Extract("select * from rsv_info");
                _numofSub = dt.Rows.Count;
            }
        }
Exemplo n.º 10
0
        protected void getModelSettings()
        {
            //get start year and output interval
            string cioFile = this.getFilePath("file.cio");

            string line;
            // get number of records
            int numYears;

            using (StreamReader sr = new StreamReader(cioFile))
            {
                // skip 7 lines
                for (int i = 1; i <= 7; i++)
                {
                    sr.ReadLine();
                }
                line       = sr.ReadLine();
                numYears   = Int32.Parse(line.Substring(0, 16));
                line       = sr.ReadLine();
                _startYear = Int32.Parse(line.Substring(0, 16));
                _endYear   = _startYear + numYears - 1;
                line       = sr.ReadLine();
                line       = sr.ReadLine();
                // skip 47 lines, so next is line 59
                for (int i = 1; i <= 47; i++)
                {
                    sr.ReadLine();
                }
                line      = sr.ReadLine();
                _interval = (OutputIntervalType)(Int32.Parse(line.Substring(0, 16)));
                line      = sr.ReadLine();
                int NYSKIP = Int32.Parse(line.Substring(0, 16));
                _startYear += NYSKIP;
            }

            //get number of hru, subbasin and reservoir from the output file
            _numofHRU = getNumberOfUnit(UnitType.HRU);
            _numofSub = getNumberOfUnit(UnitType.SUB);
            _numofRes = getNumberOfUnit(UnitType.RSV);
        }
Exemplo n.º 11
0
        protected void getModelSettings()
        {
            //get start year and output interval
            string cioFile = this.getFilePath("file.cio");

            string line;
            // get number of records
            int numYears;

            using (StreamReader sr = new StreamReader(cioFile))
            {
                // skip 7 lines
                for (int i = 1; i <= 7; i++) sr.ReadLine();
                line = sr.ReadLine();
                numYears = Int32.Parse(line.Substring(0, 16));
                line = sr.ReadLine();
                _startYear = Int32.Parse(line.Substring(0, 16));
                _endYear = _startYear + numYears - 1;
                line = sr.ReadLine();
                line = sr.ReadLine();
                // skip 47 lines, so next is line 59
                for (int i = 1; i <= 47; i++) sr.ReadLine();
                line = sr.ReadLine();
                _interval = (OutputIntervalType)(Int32.Parse(line.Substring(0, 16)));
                line = sr.ReadLine();
                int NYSKIP = Int32.Parse(line.Substring(0, 16));
                _startYear += NYSKIP;
            }

            //get number of hru, subbasin and reservoir from the output file
            _numofHRU = getNumberOfUnit(UnitType.HRU);
            _numofSub = getNumberOfUnit(UnitType.SUB);
            _numofRes = getNumberOfUnit(UnitType.RSV);
        }
Exemplo n.º 12
0
        private void getBasicInformation()
        {
            DataTable dt = Extract("select * from ave_annual_basin");
            if (dt.Rows.Count == 0) return;

            foreach (DataRow r in dt.Rows)
            {
                RowItem item = new RowItem(r);
                string name = item.getColumnValue_String("NAME");
                if (name.Equals("START_YEAR_OUTPUT"))
                    _startYear = item.getColumnValue_Int("VALUE");
                else if (name.Equals("END_YEAR"))
                    _endYear = item.getColumnValue_Int("VALUE");
                else if (name.Equals("OUTPUT_INTERVAL"))
                    _interval = (OutputIntervalType)(item.getColumnValue_Int("VALUE"));
            }

            dt = Extract("select * from hru_info");
            _numofHRU = dt.Rows.Count;

            dt = Extract("select * from sub_info");
            _numofSub = dt.Rows.Count;

            dt = Extract("select * from sqlite_master where name = 'rsv_info'");
            if (dt.Rows.Count > 0)
            {
                dt = Extract("select * from rsv_info");
                _numofSub = dt.Rows.Count;
            }
        }
Exemplo n.º 13
0
 /// <summary>
 /// Retrieve data columns for given result interval
 /// </summary>
 /// <param name="type"></param>
 /// <returns></returns>
 public static string getDateColumns(OutputIntervalType type)
 {
     switch (type)
     {
         case OutputIntervalType.DAY: return DATE_COLUMNS_DAILY;
         case OutputIntervalType.MON: return DATE_COLUMNS_MONTHLY;
         case OutputIntervalType.YEAR: return DATE_COLUMNS_YEARLY;
         default: return "";
     }
 }
Exemplo n.º 14
0
 public static string getDatabaseName(OutputIntervalType interval)
 {
     switch (interval)
     {
         case OutputIntervalType.DAY: return "result_627_daily.db3";
         case OutputIntervalType.MON: return "result_627_monthly.db3";
         case OutputIntervalType.YEAR: return "result_627_yearly.db3";
         default: return "";
     }
 }
Exemplo n.º 15
0
 public ExtractSWAT_SQLite(string txtinoutPath, OutputIntervalType interval)
 {
     _db3Path = System.IO.Path.Combine(txtinoutPath, getDatabaseName(interval));
     if (!System.IO.File.Exists(_db3Path)) _db3Path = "";
 }
Exemplo n.º 16
0
 public ExtractSWAT_SQLite(string scenariosDir, string scenarioName, OutputIntervalType interval)
 {
     _db3Path = System.IO.Path.Combine( scenariosDir, scenarioName,"txtinout", getDatabaseName(interval));
     if (!System.IO.File.Exists(_db3Path)) _db3Path = "";
 }