public static void InitializeClimData(IInputParameters _parameters)
        {
            parameters = _parameters;

            ReadContent();

            SetFileProps();

            Data = new DateVar<CClimDay>("ClimateData", FirstYearOnFile, LastYearOnFile);

            for (int Year = FirstYearOnFile; Year < LastYearOnFile; Year++)
            {
                for(int Month = 1; Month <=12; Month++)
                {
                    string line = GetLine(Year, Month);
                    string[] terms = line.Split(delim);
                    if (terms.Count() != ColumnCount)
                    {
                        throw new System.Exception("Unexpected number of columns in " + parameters.climateFileName + " (year,month) "+ Year +" "+ Month);
                    }
                    DateTime CurrentDate = new DateTime(Year, Month, 15);

                    float TMax = float.Parse(terms[TMaxCol]);
                    float TMin = float.Parse(terms[TMinCol]);
                    float CO2 = float.Parse(terms[CO2Col]);
                    float PAR0 = float.Parse(terms[PAR0col]);
                    float Prec = float.Parse(terms[Preccol]);

                    if (TMax < TMin) throw new System.Exception("Recheck climate data in " + parameters.climateFileName + " Tmax < Tmin on " + CurrentDate);
                    else if (Prec < 0) throw new System.Exception("Recheck climate data in " + parameters.climateFileName + " Prec = " + Prec + "\t" + CurrentDate);

                    Data[CurrentDate] = new CClimDay(parameters.Latitude, CurrentDate, PAR0, TMin, TMax, Prec, CO2);
                }
            }
        }
Example #2
0
        public static void InitializeClimData(IInputParameters _parameters)
        {
            parameters = _parameters;

            ReadContent();


            SetFileProps();

            Data = new DateVar <CClimDay>("ClimateData", FirstYearOnFile, LastYearOnFile);

            for (int Year = FirstYearOnFile; Year < LastYearOnFile; Year++)
            {
                for (int Month = 1; Month <= 12; Month++)
                {
                    string   line  = GetLine(Year, Month);
                    string[] terms = line.Split(delim);
                    if (terms.Count() != ColumnCount)
                    {
                        throw new System.Exception("Unexpected number of columns in " + parameters.climateFileName + " (year,month) " + Year + " " + Month);
                    }
                    DateTime CurrentDate = new DateTime(Year, Month, 15);

                    float TMax = float.Parse(terms[TMaxCol]);
                    float TMin = float.Parse(terms[TMinCol]);
                    float CO2  = float.Parse(terms[CO2Col]);
                    float PAR0 = float.Parse(terms[PAR0col]);
                    float Prec = float.Parse(terms[Preccol]);

                    if (TMax < TMin)
                    {
                        throw new System.Exception("Recheck climate data in " + parameters.climateFileName + " Tmax < Tmin on " + CurrentDate);
                    }
                    else if (Prec < 0)
                    {
                        throw new System.Exception("Recheck climate data in " + parameters.climateFileName + " Prec = " + Prec + "\t" + CurrentDate);
                    }

                    Data[CurrentDate] = new CClimDay(parameters.Latitude, CurrentDate, PAR0, TMin, TMax, Prec, CO2);
                }
            }
        }