示例#1
0
        /*!
         * \brief   Use this method to choose model for ET0 calculation automatically depending on available data.
         *
         * \param   climate     Parameter to relay to matching ET0 calculation model.
         * \param   date        Parameter to relay to matching ET0 calculation model.
         * \param   location    Parameter to relay to matching ET0 calculation model.
         * \param   et0PmArgs   Relayed to Et0CalcPm()
         * \param   et0HgArgs   Relayed to Et0CalcHg()
         *
         * \return  An Et0Result structure.
         */

        public static bool Et0Calc(
            Climate climate,
            DateTime date,
            Location location,
            Et0PmArgs et0PmArgs,
            Et0HgArgs et0HgArgs,
            ref Et0Result result
            )
        {
            var climateSet = climate.getValues(date);

            //check availability of values
            if (climateSet == null)
            {
                return(false);
            }
            if (
                climateSet.max_temp.HasValue &&
                climateSet.min_temp.HasValue &&
                climateSet.humidity.HasValue &&
                (climateSet.Rs.HasValue || climateSet.sunshine_duration.HasValue)
                )
            {
                //data sufficient for Penman-Monteith
                return(Et0CalcPm(climate, date, location, et0PmArgs, ref result));
            }
            //use Hargreaves
            return(Et0CalcHg(climate, date, location, et0HgArgs, ref result));
        }
示例#2
0
        /*!
         * \brief   Calculate ET0 with Hargreaves method as described in FAO paper 56.
         *
         * \param   climate     Use this dataset with climate data.
         * \param   date        Date for ET0 calculation.
         * \param   location    The location for calculation, latitude and altitude are used.
         * \param   et0Args     Regression coefficients for Hargreaves calculation
         * \param   [in,out]    result  Result of calculation
         *
         * \return  true on success
         */

        public static bool Et0CalcHg(
            Climate climate,
            DateTime date,
            Location location,
            Et0HgArgs et0Args,
            ref Et0Result result
            )
        {
            var climateSet = climate.getValues(date);

            if (climateSet == null)
            {
                return(false);
            }
            if (
                !climateSet.max_temp.HasValue ||
                !climateSet.min_temp.HasValue
                )
            {
                return(false);
            }

            var raResult = Ra.RaCalc(date, location);

            result.ra = raResult.ra;

            if (result.ra == 0)
            {
                result.et0 = 0;
                return(true);
            }

            var lambda = 2.5 - 0.002361 * ((double)climateSet.max_temp + (double)climateSet.min_temp) / 2;

            result.et0 = et0Args._ch * result.ra * Math.Pow(((double)climateSet.max_temp - (double)climateSet.min_temp), et0Args._eh) * (((double)climateSet.max_temp + (double)climateSet.min_temp) / 2 + et0Args._ct) / (double)lambda;

            return(true);
        }