Ejemplo n.º 1
0
        public CropInput GetCropInput(string executeFilePath, string sRow)
        {
            // Read parameters from one line of execute.txt

            Console.WriteLine("Reading parameters from Execute.txt...");

            userName = Path.GetFileName(Path.GetDirectoryName(executeFilePath)); // Name of the last folder
            System.Console.WriteLine("  User name: " + userName);

            basinFolder = executeFilePath.Substring(0, executeFilePath.IndexOf("\\01 Analysis\\AquaCrop\\Results\\")); // basin Name
            System.Console.WriteLine("  Basin folder: " + basinFolder);


            ReadExecuteRow(sRow);

            Console.WriteLine("  Selected area: " + selectedArea.ToString());
            Console.WriteLine("  Basin name: " + basinName);
            Console.WriteLine("  Selected mode: " + selectedMode.ToString());

            // Finds the time series path based on input parameters

            string csvSuffix = selectedArea.ToString() + "_" + basinName + ".csv"; // all csv files end with this string

            string prec_ts;
            string climateChange_ts = "";      // need to set it to empty string

            if (selectedMode == Mode.Forecast) // Mode.Forecast
            {
                if (selectedForecastMode == ForecastMode.ModelBased)
                {
                    prec_ts = System.IO.Path.Combine(basinFolder, @"2_Forecast\SeasonalForecast\WeightedTS\member_") + csvSuffix;
                }
                else //if (selectedForecastMode==ForecastMode.Climatology)
                {
                    prec_ts = System.IO.Path.Combine(basinFolder, @"1a_CHIRPS\Climatology\WeightedTS\climatology_chirps_") + csvSuffix;
                }
            }
            else // Mode.ClimateChange or Mode.Historic
            {
                prec_ts = System.IO.Path.Combine(basinFolder, @"1a_CHIRPS\WeightedTS\chirps_") + csvSuffix;

                if (selectedMode == Mode.ClimateChange)
                {
                    Console.WriteLine("Applying Climate change scenario: " + selectedCCPeriod + " - " + selectedCCRCP);
                    climateChange_ts = System.IO.Path.Combine(basinFolder, "7_ClimateChange", "data", selectedCCPeriod, "prec", selectedCCRCP, @"WeightedTS\member_") + csvSuffix;
                }
            }

            string tempMin_ts = System.IO.Path.Combine(basinFolder, @"6d_CRU_temp\WeightedTS\tmn_mean_monthly_") + csvSuffix;
            string tempMax_ts = System.IO.Path.Combine(basinFolder, @"6d_CRU_temp\WeightedTS\tmx_mean_monthly_") + csvSuffix;

            string pet_ts = System.IO.Path.Combine(basinFolder, @"6b_CRU_PET\Data\WeightedTS\cru_pet_") + csvSuffix;

            //Read the climate input
            if (!File.Exists(prec_ts))
            {
                Console.WriteLine("  ERROR: rainfall TS not found, check: " + prec_ts);
                Environment.Exit(0);
            }
            if (!File.Exists(tempMin_ts))
            {
                Console.WriteLine("  ERROR: Temperature TS not found, check: " + tempMin_ts);
                Environment.Exit(0);
            }

            if (!File.Exists(pet_ts))
            {
                Console.WriteLine("  ERROR: PET TS not found, check: " + pet_ts);
                Environment.Exit(0);
            }

            Console.WriteLine("Reading Climate TS");
            this.Read_ClimateTS(prec_ts, pet_ts, tempMin_ts, tempMax_ts, selectedMode == Mode.Forecast, climateChange_ts); // 'ensemble = True' when 'selectedMode == Mode.Forecast'

            Console.WriteLine("Reading Crop parameters");

            return(this);
        }