Exemple #1
0
 ///<summary>
 ///Acces to daily meanTemp.
 ///</summary>
 ///<param name="theDate">The date to get infos.</param>
 ///<returns>meanTemp</returns>
 public double MeanTemp(DateTime theDate)
 {
     if (isUnlimitedTemperature)
     {
         return(CheckTemperatures(theDate)[2]);
     }
     else
     {
         return(cache.TemperatureMean(theDate));
     }
 }
Exemple #2
0
        public void EstimateSowingWindow_JRC_Winter(Cache cache, SiteItem site)
        {
            DateTime date1;
            DateTime date2;
            DateTime datex;
            int      dayn1;
            int      dayn2;
            int      daynx;
            int      ndays;
            double   tempsum;

            esd_W = 366;
            lsd_W = 0;

            var MinLength     = site.MinSowWinLength;
            var TempThr       = site.TempThr;
            var TempSum       = site.TempSum;
            var PcpSum        = site.PcpSum;
            var CheckDaysPcp  = site.CheckDaysPcp;
            var CheckDaysTemp = site.CheckDaysTemp;

            var year1 = cache.Start.Value.Year;
            var year2 = cache.End.Value.Year;

            for (var year = year1; year <= year2; ++year)
            {
                date1 = new DateTime(year, 12, 30);
                date2 = new DateTime(year, 09, 01);
                dayn1 = date1.DayOfYear;
                dayn2 = date2.DayOfYear;
                ndays = dayn1 - dayn2 + 1;

                if (date1 <= cache.End && date2 >= cache.Start)
                {
                    tempsum = 0;

                    for (var dayn = 1; dayn <= ndays; ++dayn)
                    {
                        datex = date1.AddDays(-dayn + 1);
                        daynx = datex.DayOfYear;

                        tempsum += Math.Max(0, cache.TemperatureMean(datex) - TempThr);

                        if (tempsum >= TempSum || dayn == ndays)
                        {
                            if (datex.DayOfYear > lsd_W)
                            {
                                lsd_W = datex.DayOfYear;
                            }
                            break;
                        }
                    }
                }
            }
            esd_W = lsd_W - MinLength;
        }
Exemple #3
0
        public void EstimateSowingWindow_JRC_Spring(Cache cache, SiteItem site)
        {
            DateTime date1;
            DateTime date2;
            DateTime datex;
            int      daynx;
            int      ndays;
            double   tav10d;
            double   pcp3d;

            esd_S = 366;
            lsd_S = 0;
            List <int> esd = new List <int>();
            List <int> lsd = new List <int>();

            var year1 = cache.Start.Value.Year;
            var year2 = cache.End.Value.Year;
            var yy    = site.MaxSowingDate.Year - site.MinSowingDate.Year;

            var TempThr       = site.TempThr;
            var TempSum       = site.TempSum;
            var PcpSum        = site.PcpSum;
            var CheckDaysPcp  = site.CheckDaysPcp;
            var CheckDaysTemp = site.CheckDaysTemp;

            for (var year = year1; year <= year2; ++year)
            {
                date1 = new DateTime(year, site.MinSowingDate.Month, site.MinSowingDate.Day);
                date2 = new DateTime(year + yy, site.MaxSowingDate.Month, site.MaxSowingDate.Day);
                ndays = (int)(date2 - date1).TotalDays;

                if (date2 <= cache.End && date1 >= cache.Start.Value.AddDays(-CheckDaysTemp))
                {
                    for (var dayn = 1; dayn <= ndays; ++dayn)
                    {
                        datex  = date1.AddDays(dayn - 1);
                        daynx  = datex.DayOfYear;
                        tav10d = cache.TemperatureMean(datex.AddDays(-1), CheckDaysTemp);

                        if (tav10d >= TempThr)
                        {
                            pcp3d = cache.Rain(datex.AddDays(-1), CheckDaysPcp);

                            if (pcp3d >= PcpSum)
                            {
                                var xx = datex.Year - year;
                                esd.Add(xx * 365 + daynx);
                                lsd.Add(xx * 365 + daynx);
                                break;
                            }
                        }
                    }
                }
            }

            if (esd.Count == 0)
            {
                date1 = new DateTime(year1, site.MinSowingDate.Month, site.MinSowingDate.Day);
                date2 = new DateTime(year1 + yy, site.MaxSowingDate.Month, site.MaxSowingDate.Day);
                esd_S = (int)(date1.DayOfYear + date2.DayOfYear - 0.5) / 2;
            }
            else
            {
                esd_S = (int)Percentile(esd, 0.25);
            }

            if (lsd.Count == 0)
            {
                date1 = new DateTime(year1, site.MinSowingDate.Month, site.MinSowingDate.Day);
                date2 = new DateTime(year1 + yy, site.MaxSowingDate.Month, site.MaxSowingDate.Day);
                lsd_S = (int)(date1.DayOfYear + date2.DayOfYear + 0.5) / 2;
            }
            else
            {
                lsd_S = (int)Percentile(lsd, 0.75);
            }
        }
Exemple #4
0
        public void EstimateSowingWindow_Sirius(Cache cache, SiteItem site, ManagementItem management)
        {
            DateTime   date1;
            DateTime   date2;
            DateTime   datex;
            int        daynx;
            int        ndays;
            double     tav10d;
            double     pcp3d;
            int        HalfSowWindow = (int)(InitSowWindow / 2);
            List <int> esd           = new List <int>();
            List <int> lsd           = new List <int>();

            var TempThr       = site.TempThr;
            var TempSum       = site.TempSum;
            var PcpSum        = site.PcpSum;
            var CheckDaysPcp  = site.CheckDaysPcp;
            var CheckDaysTemp = site.CheckDaysTemp;

            var year1 = cache.Start.Value.Year;
            var year2 = cache.End.Value.Year;
            var yy    = management.SowingDate.AddDays(HalfSowWindow).Year - management.SowingDate.AddDays(-HalfSowWindow).Year;

            date1   = new DateTime(year1, management.SowingDate.Month, management.SowingDate.Day);
            esd_Sir = date1.DayOfYear;
            lsd_Sir = date1.DayOfYear;
            esd.Add(esd_Sir);
            lsd.Add(lsd_Sir);

            for (var year = year1; year <= year2; ++year)
            {
                date1 = new DateTime(year, management.SowingDate.Month, management.SowingDate.Day);
                date2 = date1.AddDays(HalfSowWindow);
                ndays = (int)(date2 - date1).TotalDays;

                if (date2 <= cache.End.Value && date1 >= cache.Start.Value)
                {
                    for (var dayn = 1; dayn <= ndays; ++dayn)
                    {
                        datex  = date1.AddDays(dayn - 1);
                        daynx  = datex.DayOfYear;
                        tav10d = cache.TemperatureMean(datex.AddDays(-1), CheckDaysTemp);

                        if (tav10d >= TempThr)
                        {
                            pcp3d = cache.Rain(datex.AddDays(-1), CheckDaysPcp);

                            if (pcp3d >= PcpSum)
                            {
                                var xx = datex.Year - year;
                                lsd.Add(xx * 365 + daynx);
                                break;
                            }
                        }
                    }
                }

                date2 = new DateTime(year, management.SowingDate.Month, management.SowingDate.Day);
                date1 = date2.AddDays(-HalfSowWindow);
                if (date1 < cache.Start.Value)
                {
                    date1 = cache.Start.Value;
                }
                ndays = (int)(date2 - date1).TotalDays;

                if (date2 <= cache.End.Value)
                {
                    for (var dayn = 1; dayn <= ndays; ++dayn)
                    {
                        datex  = date2.AddDays(-dayn + 1);
                        daynx  = datex.DayOfYear;
                        tav10d = cache.TemperatureMean(datex.AddDays(-1), CheckDaysTemp);

                        if (tav10d >= TempThr)
                        {
                            pcp3d = cache.Rain(datex.AddDays(-1), CheckDaysPcp);

                            if (pcp3d >= PcpSum)
                            {
                                var xx = datex.Year - year;
                                esd.Add(xx * 365 + daynx);
                                break;
                            }
                        }
                    }
                }
            }
            esd_Sir = (int)Percentile(esd, 0.25);
            lsd_Sir = (int)Percentile(lsd, 0.75);
        }