aw3843: correction on SMDMax
All checks were successful
FarmMaps.Develop/CarbonLib/pipeline/head This commit looks good
All checks were successful
FarmMaps.Develop/CarbonLib/pipeline/head This commit looks good
This commit is contained in:
@@ -214,12 +214,6 @@ namespace FarmMapsAPI.Carbon
|
|||||||
public double? GetCropYield(string cropCode, int year, int postalCode)
|
public double? GetCropYield(string cropCode, int year, int postalCode)
|
||||||
{
|
{
|
||||||
string provinceCode = GetProvinceCode(dataTransformationSet, postalCode);
|
string provinceCode = GetProvinceCode(dataTransformationSet, postalCode);
|
||||||
//var cropMapping = mappingCropFarmmapsMiterraRothC.FirstOrDefault(x => x.CropCode == cropCode);
|
|
||||||
//if (cropMapping == null)
|
|
||||||
//{
|
|
||||||
// return 0;
|
|
||||||
//}
|
|
||||||
//var crpYield = cropYieldConfig.SingleOrDefault(x => x.CropName.ToLower() == cropMapping.MiterraRothCCrop.ToLower());
|
|
||||||
var crpYield = cropYieldConfig.SingleOrDefault(x => x.CropName.ToLower() == cropCode.ToLower());
|
var crpYield = cropYieldConfig.SingleOrDefault(x => x.CropName.ToLower() == cropCode.ToLower());
|
||||||
var crpYieldProvince = crpYield.Yields.SingleOrDefault(x => x.ProvinceCode == provinceCode);
|
var crpYieldProvince = crpYield.Yields.SingleOrDefault(x => x.ProvinceCode == provinceCode);
|
||||||
var cropYield = crpYieldProvince.YearData.SingleOrDefault(x => x.Year == year)?.YieldValue;
|
var cropYield = crpYieldProvince.YearData.SingleOrDefault(x => x.Year == year)?.YieldValue;
|
||||||
@@ -264,7 +258,6 @@ namespace FarmMapsAPI.Carbon
|
|||||||
item.Value.OM_Corr = sumCorr;
|
item.Value.OM_Corr = sumCorr;
|
||||||
}
|
}
|
||||||
|
|
||||||
//var oM_corr_SoilType = new Dictionary<string, List<ColumnValue>>();
|
|
||||||
var oM_corr_SoilType = new Dictionary<(string,string), double>();
|
var oM_corr_SoilType = new Dictionary<(string,string), double>();
|
||||||
foreach (var item in soilPropertiesField)
|
foreach (var item in soilPropertiesField)
|
||||||
{
|
{
|
||||||
@@ -753,7 +746,7 @@ namespace FarmMapsAPI.Carbon
|
|||||||
coverModFactor.Add(crpCover.CropName, valueList);
|
coverModFactor.Add(crpCover.CropName, valueList);
|
||||||
}
|
}
|
||||||
|
|
||||||
// SMDMax (kan buiten yearLoop)
|
// SMDMax
|
||||||
// field, crop
|
// field, crop
|
||||||
var smdMax = new Dictionary<string, double>();
|
var smdMax = new Dictionary<string, double>();
|
||||||
foreach (var soil in soilPropertiesField)
|
foreach (var soil in soilPropertiesField)
|
||||||
@@ -762,7 +755,7 @@ namespace FarmMapsAPI.Carbon
|
|||||||
smdMax.Add(soil.Key, result);
|
smdMax.Add(soil.Key, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
// SMDaccMonthi (kan buiten yearLoop ??)
|
// SMDaccMonthi
|
||||||
var smdAccMonthi = new Dictionary<string, List<ColumnValue>>();
|
var smdAccMonthi = new Dictionary<string, List<ColumnValue>>();
|
||||||
|
|
||||||
foreach (var climateItem in climateVariable)
|
foreach (var climateItem in climateVariable)
|
||||||
@@ -772,16 +765,43 @@ namespace FarmMapsAPI.Carbon
|
|||||||
{
|
{
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/* smdMax met factor maand corrigeren
|
||||||
|
SMDmax(Field,Crop,AllMonths) = ifthen(CropCoverMonths(Crop,AllMonths)=1,
|
||||||
|
SMDmax(Field,Crop,AllMonths),SMDmax(Field,Crop,AllMonths)/1.8);
|
||||||
|
*/
|
||||||
|
var crop = cropAreaField1.SingleOrDefault(x => x.Key.Item2 == loopYear).Value[0].Key;
|
||||||
|
var cover = cropCoverMonthConfig.SingleOrDefault(x => x.CropName == crop)?.CoverMonths;
|
||||||
|
var hasCover = cover.Any(x => x == $"M{i + 1}");
|
||||||
|
var smdMaxValue = smdMax[climateItem.Key];
|
||||||
|
if (!hasCover)
|
||||||
|
{
|
||||||
|
smdMaxValue = smdMax[climateItem.Key] / 1.8;
|
||||||
|
}
|
||||||
|
|
||||||
var result = climateItem.Value[i].Precipitation - climateItem.Value[i].Evapotranspiration;
|
var result = climateItem.Value[i].Precipitation - climateItem.Value[i].Evapotranspiration;
|
||||||
result = result < 0 ? result : 0;
|
result = result < 0 ? result : 0;
|
||||||
result = result < smdMax[climateItem.Key] ? smdMax[climateItem.Key] : result;
|
result = result < smdMaxValue ? smdMaxValue : result;
|
||||||
valueList.Add(new ColumnValue("M1", result));
|
valueList.Add(new ColumnValue("M1", result));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
/* smdMax met factor maand corrigeren
|
||||||
|
SMDmax(Field,Crop,AllMonths) = ifthen(CropCoverMonths(Crop,AllMonths)=1,
|
||||||
|
SMDmax(Field,Crop,AllMonths),SMDmax(Field,Crop,AllMonths)/1.8);
|
||||||
|
*/
|
||||||
|
var crop = cropAreaField1.SingleOrDefault(x => x.Key.Item2 == loopYear).Value[0].Key;
|
||||||
|
var cover = cropCoverMonthConfig.SingleOrDefault(x => x.CropName == crop)?.CoverMonths;
|
||||||
|
var hasCover = cover.Any(x => x == $"M{i + 1}");
|
||||||
|
var smdMaxValue = smdMax[climateItem.Key];
|
||||||
|
if (!hasCover)
|
||||||
|
{
|
||||||
|
smdMaxValue = smdMax[climateItem.Key] / 1.8;
|
||||||
|
}
|
||||||
|
|
||||||
var result = climateItem.Value[i].Precipitation - climateItem.Value[i].Evapotranspiration + valueList.SingleOrDefault(x => x.Key == $"M{i}").Value;
|
var result = climateItem.Value[i].Precipitation - climateItem.Value[i].Evapotranspiration + valueList.SingleOrDefault(x => x.Key == $"M{i}").Value;
|
||||||
result = result < 0 ? result : 0;
|
result = result < 0 ? result : 0;
|
||||||
result = result < smdMax[climateItem.Key] ? smdMax[climateItem.Key] : result;
|
result = result < smdMaxValue ? smdMaxValue : result;
|
||||||
valueList.Add(new ColumnValue($"M{i + 1}", result));
|
valueList.Add(new ColumnValue($"M{i + 1}", result));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -796,13 +816,26 @@ namespace FarmMapsAPI.Carbon
|
|||||||
var valueList = new List<ColumnValue>();
|
var valueList = new List<ColumnValue>();
|
||||||
foreach (var smdAccMonth in fieldSmdAccMonthi.Value)
|
foreach (var smdAccMonth in fieldSmdAccMonthi.Value)
|
||||||
{
|
{
|
||||||
if (smdAccMonth.Value > 0.444 * smdMax[fieldSmdAccMonthi.Key])
|
/* smdMax met factor maand corrigeren
|
||||||
|
SMDmax(Field,Crop,AllMonths) = ifthen(CropCoverMonths(Crop,AllMonths)=1,
|
||||||
|
SMDmax(Field,Crop,AllMonths),SMDmax(Field,Crop,AllMonths)/1.8);
|
||||||
|
*/
|
||||||
|
var crop = cropAreaField1.SingleOrDefault(x => x.Key.Item2 == loopYear).Value[0].Key;
|
||||||
|
var cover = cropCoverMonthConfig.SingleOrDefault(x => x.CropName == crop)?.CoverMonths;
|
||||||
|
var hasCover = cover.Any(x => x == smdAccMonth.Key);
|
||||||
|
var smdMaxValue = smdMax[fieldSmdAccMonthi.Key];
|
||||||
|
if (!hasCover)
|
||||||
|
{
|
||||||
|
smdMaxValue = smdMax[fieldSmdAccMonthi.Key] / 1.8;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (smdAccMonth.Value > 0.444 * smdMaxValue)
|
||||||
{
|
{
|
||||||
valueList.Add(new ColumnValue(smdAccMonth.Key, 1));
|
valueList.Add(new ColumnValue(smdAccMonth.Key, 1));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var result = (0.2 + 0.8 * ((smdMax[fieldSmdAccMonthi.Key] - smdAccMonth.Value) / (smdMax[fieldSmdAccMonthi.Key] - 0.444 * smdMax[fieldSmdAccMonthi.Key])));
|
var result = (0.2 + 0.8 * ((smdMaxValue - smdAccMonth.Value) / (smdMaxValue - 0.444 * smdMaxValue)));
|
||||||
valueList.Add(new ColumnValue(smdAccMonth.Key, result));
|
valueList.Add(new ColumnValue(smdAccMonth.Key, result));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1680,11 +1713,9 @@ namespace FarmMapsAPI.Carbon
|
|||||||
|
|
||||||
// SOC_Summary_Farm
|
// SOC_Summary_Farm
|
||||||
var soc_Summary_Farm = new List<FarmYearSummary>();
|
var soc_Summary_Farm = new List<FarmYearSummary>();
|
||||||
//carbonSummary.FarmSummary = soc_Summary_Farm;
|
|
||||||
foreach (var item in cropAreaFarm)
|
foreach (var item in cropAreaFarm)
|
||||||
{
|
{
|
||||||
var sum = item.Value.Sum(x => x.Value);
|
var sum = item.Value.Sum(x => x.Value);
|
||||||
//soc_Summary_Farm.Add(item.Key, new List<ColumnValue> { new ColumnValue("Total_crop_area", sum) });
|
|
||||||
soc_Summary_Farm.Add(new FarmYearSummary { Year = item.Key.Item2, Total_crop_area = sum });
|
soc_Summary_Farm.Add(new FarmYearSummary { Year = item.Key.Item2, Total_crop_area = sum });
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1921,11 +1952,9 @@ namespace FarmMapsAPI.Carbon
|
|||||||
foreach (var manure in manures.GreenManureTypes)
|
foreach (var manure in manures.GreenManureTypes)
|
||||||
{
|
{
|
||||||
var manureQ = yieldGreenManureConfig.SingleOrDefault(x => x.ManureName.ToLower() == manure.Type.ToLower());
|
var manureQ = yieldGreenManureConfig.SingleOrDefault(x => x.ManureName.ToLower() == manure.Type.ToLower());
|
||||||
//double manureQuality = manure.Quality == "Goed" ? manureQ.GoodQuality : manure.Quality == "Matig" ? manureQ.AverageQuality : manure.Quality == "Slecht" ? manureQ.BadQuality : 0;
|
|
||||||
double manureQuality2 = manure.Quality == Quality.Good ? manureQ.GoodQuality : manure.Quality == Quality.Average ? manureQ.AverageQuality : manure.Quality == Quality.Bad ? manureQ.BadQuality : 0;
|
double manureQuality2 = manure.Quality == Quality.Good ? manureQ.GoodQuality : manure.Quality == Quality.Average ? manureQ.AverageQuality : manure.Quality == Quality.Bad ? manureQ.BadQuality : 0;
|
||||||
if (manureQuality2 > 0)
|
if (manureQuality2 > 0)
|
||||||
{
|
{
|
||||||
//var yieldGreenManureRow = yieldGreenManureSheet.Rows.SingleOrDefault(x => x.Cells[0] != null && x.Cells[0].Text.ToString() == manure.Type).Cells[qColumn].Value;
|
|
||||||
carbonInputGreenManure.Add((field.Name, manures.Year), new List<ColumnValue> { new ColumnValue(manure.Type, manureQuality2) });
|
carbonInputGreenManure.Add((field.Name, manures.Year), new List<ColumnValue> { new ColumnValue(manure.Type, manureQuality2) });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
|
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
|
||||||
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
|
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
|
||||||
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
|
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
|
||||||
<Version>1.1.6</Version>
|
<Version>1.2.0</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -74,7 +74,6 @@ namespace FarmMapsAPI.Carbon.Models
|
|||||||
|
|
||||||
public List<(string, int, string)> KeysWhereCropKeyExists(int year, string crop)
|
public List<(string, int, string)> KeysWhereCropKeyExists(int year, string crop)
|
||||||
{
|
{
|
||||||
//return TrippleKeyParam.Where(x => x.Value.Any(y => y.Key == column)).Select(s=>s.Key).ToList();
|
|
||||||
return TrippleKeyParam.Where(x => x.Key.Item2 == year && x.Key.Item3.ToLower() == crop.ToLower()).Select(s=>s.Key).ToList();
|
return TrippleKeyParam.Where(x => x.Key.Item2 == year && x.Key.Item3.ToLower() == crop.ToLower()).Select(s=>s.Key).ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user