/// <summary> /// If the Hydric Balance is lower than the Water Threhold we need to Irrigate /// The water Threhold is the half of the Available Water /// </summary> /// <param name="pCropIrrigationWeather"></param> /// <returns></returns> public bool IrrigateByHydricBalance(CropIrrigationWeather pCropIrrigationWeather) { bool lReturn = false; double lAvailableWater; double lHydricBalance; double lPermanentWiltingPoint; double lThreshold; double lMinEvapotrasnpirationToIrrigate; double lEvapotrAcum; lAvailableWater = pCropIrrigationWeather.GetSoilAvailableWaterCapacity(); lPermanentWiltingPoint = pCropIrrigationWeather.GetSoilPermanentWiltingPoint(); //This is the Threshold to determinate the need of lIrrigationItem lThreshold = Math.Round(lAvailableWater * InitialTables.PERCENTAGE_LIMIT_OF_AVAILABLE_WATER_CAPACITY, 2) + lPermanentWiltingPoint; lMinEvapotrasnpirationToIrrigate = pCropIrrigationWeather.Crop.MinEvapotranspirationToIrrigate; lEvapotrAcum = pCropIrrigationWeather.GetTotalEvapotranspirationCropFromLastWaterInput(); lHydricBalance = pCropIrrigationWeather.GetHydricBalance(); if (lHydricBalance <= lThreshold && lEvapotrAcum >= lMinEvapotrasnpirationToIrrigate) { lReturn = true; } return(lReturn); }
/// <summary> /// Calculate how much to irrigate in a Date. /// Use both ways to calculate: by available water and by acumulated evapotranspirationCrop /// </summary> /// <param name="pName">new name</param> public Pair <double, Utils.WaterInputType> HowMuchToIrrigate(CropIrrigationWeather pCropIrrigationWeather) { Pair <double, Utils.WaterInputType> lReturn; bool lIrrigationByEvapotranspiration; bool lIrrigationByHydricBalance; double lPercentageAvailableWater; lReturn = new Pair <double, Utils.WaterInputType>(); lIrrigationByEvapotranspiration = CalculusEvapotranspiration.IrrigateByEvapotranspiration(pCropIrrigationWeather); lIrrigationByHydricBalance = CalculusAvailableWater.IrrigateByHydricBalance(pCropIrrigationWeather); lPercentageAvailableWater = pCropIrrigationWeather.GetPercentageOfAvailableWaterTakingIntoAccointPermanentWiltingPoint(); //If we need to irrigate by Evapotranspiraton, then Available water has to be lower than 60% if (lIrrigationByEvapotranspiration && lPercentageAvailableWater < InitialTables.PERCENTAGE_OF_AVAILABE_WATER_TO_IRRIGATE) { lReturn.First = pCropIrrigationWeather.PredeterminatedIrrigationQuantity; lReturn.Second = Utils.WaterInputType.IrrigationByETCAcumulated; } else if (lIrrigationByHydricBalance) { lReturn.First = pCropIrrigationWeather.PredeterminatedIrrigationQuantity; lReturn.Second = Utils.WaterInputType.IrrigationByHydricBalance; } return(lReturn); }
public ActionResult DeleteConfirmed(long id) { CropIrrigationWeather cropIrrigationWeather = db.CropIrrigationWeathers.Find(id); db.CropIrrigationWeathers.Remove(cropIrrigationWeather); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "CropIrrigationWeatherId,SowingDate,HarvestDate,CropDate,HydricBalance,SoilHydricVolume,TotalEvapotranspirationCropFromLastWaterInput,DaysAfterSowing,DaysAfterSowingModified,GrowingDegreeDaysAccumulated,GrowingDegreeDaysModified,PredeterminatedIrrigationQuantity,LastWaterInputDate,LastBigWaterInputDate,LastPartialWaterInputDate,LastPartialWaterInput,UsingMainWeatherStation,TotalEvapotranspirationCrop,TotalEffectiveRain,TotalRealRain,TotalIrrigation,TotalIrrigationInHydricBalance,TotalExtraIrrigation,TotalExtraIrrigationInHydricBalance,OutPut")] CropIrrigationWeather cropIrrigationWeather) { if (ModelState.IsValid) { db.Entry(cropIrrigationWeather).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(cropIrrigationWeather)); }
// GET: CropIrrigationWeathers/Delete/5 public ActionResult Delete(long?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CropIrrigationWeather cropIrrigationWeather = db.CropIrrigationWeathers.Find(id); if (cropIrrigationWeather == null) { return(HttpNotFound()); } return(View(cropIrrigationWeather)); }
public CropIrrigationWeatherViewModel(CropIrrigationWeather pCropIrrigationWeather) { this.CropIrrigationWeatherId = pCropIrrigationWeather.CropIrrigationWeatherId; this.CropIrrigationWeatherName = pCropIrrigationWeather.CropIrrigationWeatherName; this.CropId = pCropIrrigationWeather.CropId; this.SoilId = pCropIrrigationWeather.SoilId; this.PhenologicalStageId = pCropIrrigationWeather.PhenologicalStageId; this.IrrigationUnitId = pCropIrrigationWeather.IrrigationUnitId; #region Weather this.MainWeatherStationId = pCropIrrigationWeather.MainWeatherStationId; this.AlternativeWeatherStationId = pCropIrrigationWeather.AlternativeWeatherStationId; #endregion this.PositionId = pCropIrrigationWeather.PositionId; #region Dates of Crop this.SowingDate = pCropIrrigationWeather.SowingDate; this.HarvestDate = pCropIrrigationWeather.HarvestDate; this.CropDate = pCropIrrigationWeather.CropDate; this.StartAdvisorDate = pCropIrrigationWeather.StartAdvisorDate; #endregion #region Crop State this.HydricBalance = pCropIrrigationWeather.HydricBalance; this.SoilHydricVolume = pCropIrrigationWeather.SoilHydricVolume; this.PhenologicalStageAdjustmentList = pCropIrrigationWeather.PhenologicalStageAdjustmentList; this.DayAfterSowing = pCropIrrigationWeather.DaysAfterSowing; this.DayAfterSowingModified = pCropIrrigationWeather.DaysAfterSowingModified; this.GrowingDegreeDaysAccumulated = pCropIrrigationWeather.GrowingDegreeDaysAccumulated; this.GrowingDegreeDaysModified = pCropIrrigationWeather.GrowingDegreeDaysModified; this.LastDayOfGrowingDegreeDays = pCropIrrigationWeather.LastDayOfGrowingDegreeDays; this.PredeterminatedIrrigationQuantity = pCropIrrigationWeather.PredeterminatedIrrigationQuantity; #endregion #region Water this.RainList = pCropIrrigationWeather.RainList; this.IrrigationList = pCropIrrigationWeather.IrrigationList; this.EvapotranspirationCropList = pCropIrrigationWeather.EvapotranspirationCropList; #endregion this.DailyRecordList = pCropIrrigationWeather.DailyRecordList; #region Totals this.TotalEvapotranspirationCrop = pCropIrrigationWeather.TotalEvapotranspirationCrop; this.TotalEffectiveRain = pCropIrrigationWeather.TotalEffectiveRain; this.TotalRealRain = pCropIrrigationWeather.TotalRealRain; this.TotalIrrigation = pCropIrrigationWeather.TotalIrrigation; this.TotalIrrigationInHydricBalance = pCropIrrigationWeather.TotalIrrigationInHydricBalance; this.TotalExtraIrrigation = pCropIrrigationWeather.TotalExtraIrrigation; this.TotalExtraIrrigationInHydricBalance = pCropIrrigationWeather.TotalExtraIrrigationInHydricBalance; #endregion }
/// <summary> /// If the evapotranspiration Acumulated from last water output is bigger than max evapotranspiration to irrigatte /// we need to irrigate /// </summary> /// <param name="pCropIrrigationWeather"></param> /// <returns></returns> public bool IrrigateByEvapotranspiration(CropIrrigationWeather pCropIrrigationWeather) { bool lReturn = false; double lMaxEvapotrToIrr; double lEvapotrAcum; lMaxEvapotrToIrr = pCropIrrigationWeather.Crop.MaxEvapotranspirationToIrrigate; lEvapotrAcum = pCropIrrigationWeather.GetTotalEvapotranspirationCropFromLastWaterInput(); //If the evapotranspiration Acumulated from last water output is bigger than max evapotranspiration to irrigatte //we need to irrigate if (lEvapotrAcum >= lMaxEvapotrToIrr) { lReturn = true; } return(lReturn); }
/// <summary> /// Get List of CropIrrigationWeather with all related data /// </summary> /// <param name="pCropIrrigationWeatherId"></param> /// <returns></returns> public CropIrrigationWeather GetCropIrrigationWeatherListBy( long pCropIrrigationWeatherId) { CropIrrigationWeather lReturn = null; long lCropIrrigationWeatherId; if (pCropIrrigationWeatherId > 0) { lCropIrrigationWeatherId = pCropIrrigationWeatherId; lReturn = db.CropIrrigationWeathers .Include(ciw => ciw.Crop) .Include(ciw => ciw.Crop.Region) .Include(ciw => ciw.Crop.Region.EffectiveRainList) .Include(ciw => ciw.Crop.Region.TemperatureDataList) .Include(ciw => ciw.Crop.PhenologicalStageList) .Include(ciw => ciw.Crop.CropCoefficient) .Include(ciw => ciw.Crop.CropCoefficient.KCList) .Include(ciw => ciw.Soil) .Include(ciw => ciw.Soil.HorizonList) .Include(ciw => ciw.CropInformationByDate) .Include(ciw => ciw.MainWeatherStation) .Include(ciw => ciw.MainWeatherStation.WeatherDataList) .Include(ciw => ciw.AlternativeWeatherStation) .Include(ciw => ciw.AlternativeWeatherStation.WeatherDataList) .Include(ciw => ciw.RainList) .Include(ciw => ciw.IrrigationList) .Include(ciw => ciw.EvapotranspirationCropList) .Include(ciw => ciw.DailyRecordList) .Include(ciw => ciw.DailyRecordList.Select(dr => dr.MainWeatherData)) .Include(ciw => ciw.DailyRecordList.Select(dr => dr.AlternativeWeatherData)) .Include(ciw => ciw.DailyRecordList.Select(dr => dr.PhenologicalStage)) .Include(ciw => ciw.DailyRecordList.Select(dr => dr.Rain)) .Include(ciw => ciw.DailyRecordList.Select(dr => dr.Irrigation)) .Include(ciw => ciw.DailyRecordList.Select(dr => dr.EvapotranspirationCrop)) .Where(ciw => ciw.CropIrrigationWeatherId == lCropIrrigationWeatherId).FirstOrDefault(); } return(lReturn); }