Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7bfe3d1e50 | |||
| e8d328d6c2 | |||
| b0ac42a957 | |||
|
|
6cc39e3482 | ||
| 31c8a4e250 | |||
| a98374129c | |||
| 597f42001b |
@@ -139,7 +139,7 @@ namespace FarmMapsAPI.Carbon
|
|||||||
Area = cropField.Area,
|
Area = cropField.Area,
|
||||||
HistoricalCropData = mappedCropData,
|
HistoricalCropData = mappedCropData,
|
||||||
SoilType = MapSoil(cropField.SoilType),
|
SoilType = MapSoil(cropField.SoilType),
|
||||||
SoilProperty = new SoilProperty { Clay_Content = cropField.SoilProperty.Clay_Content, OM_Const = cropField.SoilProperty.OM_Const },
|
SoilProperty = new SoilProperty { Clay_Content = cropField.SoilProperty.Clay_Content, OM_Const = cropField.SoilProperty.OM_Const, Depth10 = cropField.SoilProperty.Depth10 },
|
||||||
GreenManures = greenManures
|
GreenManures = greenManures
|
||||||
});
|
});
|
||||||
foreach (var crops in cropField.HistoricalCropData)
|
foreach (var crops in cropField.HistoricalCropData)
|
||||||
@@ -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;
|
||||||
@@ -242,6 +236,7 @@ namespace FarmMapsAPI.Carbon
|
|||||||
// cropAreaSheet (external input)
|
// cropAreaSheet (external input)
|
||||||
var cropAreaField = GetCropAreaField(farmInput);
|
var cropAreaField = GetCropAreaField(farmInput);
|
||||||
|
|
||||||
|
var year = GetYears(farmInputSet, farmInput);
|
||||||
|
|
||||||
//////////////////////////////////////////////
|
//////////////////////////////////////////////
|
||||||
// precalculations
|
// precalculations
|
||||||
@@ -251,7 +246,7 @@ namespace FarmMapsAPI.Carbon
|
|||||||
//soilPropSoilType
|
//soilPropSoilType
|
||||||
var soilPropSoilType = GetSoilPropSoilType(soilTypeData, soilPropertiesField);
|
var soilPropSoilType = GetSoilPropSoilType(soilTypeData, soilPropertiesField);
|
||||||
|
|
||||||
//soilPropertiesField (again)
|
//soilPropertiesField (again) --> remove this
|
||||||
foreach (var item in soilPropertiesField)
|
foreach (var item in soilPropertiesField)
|
||||||
{
|
{
|
||||||
var soilProps = soilPropSoilType.Keys.Where(x => x.Item1 == item.Key).ToList();
|
var soilProps = soilPropSoilType.Keys.Where(x => x.Item1 == item.Key).ToList();
|
||||||
@@ -263,21 +258,63 @@ namespace FarmMapsAPI.Carbon
|
|||||||
item.Value.OM_Corr = sumCorr;
|
item.Value.OM_Corr = sumCorr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var oM_corr_SoilType = new Dictionary<(string,string), double>();
|
||||||
|
foreach (var item in soilPropertiesField)
|
||||||
|
{
|
||||||
|
var soilOfItem = soilTypeData[item.Key].FirstOrDefault();
|
||||||
|
var initialSoilKey = historicalCropdata.Keys.FirstOrDefault(x => x.Item1 == item.Key && x.Item2 == year.First());
|
||||||
|
var initialSoil = historicalCropdata[initialSoilKey].FirstOrDefault();
|
||||||
|
var soilPropertyDepth10 = item.Value.Depth10;
|
||||||
|
if (initialSoil == "Temp_gras" && soilPropertyDepth10)
|
||||||
|
{
|
||||||
|
oM_corr_SoilType.Add((item.Key, soilOfItem), item.Value.OM_Cont * 0.97);
|
||||||
|
}
|
||||||
|
else if (cropSet.Grass_nat.Contains(initialSoil) && soilPropertyDepth10 && (soilOfItem == "Klei" || soilOfItem == "Zand"))
|
||||||
|
{
|
||||||
|
if (soilOfItem == "Klei")
|
||||||
|
{
|
||||||
|
oM_corr_SoilType.Add((item.Key, soilOfItem), item.Value.OM_Cont * 0.67);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
oM_corr_SoilType.Add((item.Key, soilOfItem), item.Value.OM_Cont * 0.81);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
oM_corr_SoilType.Add((item.Key, soilOfItem), item.Value.OM_Cont);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var oM_Corr = new Dictionary<string, double>();
|
||||||
|
foreach (var item in oM_corr_SoilType)
|
||||||
|
{
|
||||||
|
oM_Corr.Add(item.Key.Item1, item.Value);
|
||||||
|
}
|
||||||
|
|
||||||
// soilBulkDensities
|
// soilBulkDensities
|
||||||
Dictionary<string, SoilBulkDensityType> soilBulkDensities = GetSoilBulkDensities(soilPropertiesField, soilTypeData, soilPropSoilType);
|
Dictionary<string, SoilBulkDensityType> soilBulkDensities = GetSoilBulkDensities(soilPropertiesField, soilTypeData, soilPropSoilType, oM_corr_SoilType);
|
||||||
|
|
||||||
foreach (var soilBulkDensity in soilBulkDensities)
|
foreach (var soilBulkDensity in soilBulkDensities)
|
||||||
{
|
{
|
||||||
if (soilPropSoilType.ContainsKey((soilBulkDensity.Key, "Klei")))
|
if (soilPropSoilType.ContainsKey((soilBulkDensity.Key, "Klei")))
|
||||||
{
|
{
|
||||||
soilPropSoilType[(soilBulkDensity.Key, "Klei")].Bulk_Density = (1.0 / soilBulkDensity.Value.Clay);
|
soilPropSoilType[(soilBulkDensity.Key, "Klei")].Bulk_Density = (1.0 / soilBulkDensity.Value.Clay);
|
||||||
|
soilBulkDensity.Value.Clay = (1.0 / soilBulkDensity.Value.Clay);
|
||||||
}
|
}
|
||||||
if (soilPropSoilType.ContainsKey((soilBulkDensity.Key, "Zand")))
|
if (soilPropSoilType.ContainsKey((soilBulkDensity.Key, "Zand")))
|
||||||
{
|
{
|
||||||
soilPropSoilType[(soilBulkDensity.Key, "Zand")].Bulk_Density = (1.0 / soilBulkDensity.Value.Sand);
|
soilPropSoilType[(soilBulkDensity.Key, "Zand")].Bulk_Density = (1.0 / soilBulkDensity.Value.Sand);
|
||||||
|
soilBulkDensity.Value.Sand = (1.0 / soilBulkDensity.Value.Sand);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var bulkDens = new Dictionary<string, double>();
|
||||||
|
foreach (var soilBulkDensity in soilBulkDensities)
|
||||||
|
{
|
||||||
|
bulkDens.Add(soilBulkDensity.Key, (soilBulkDensity.Value.Clay + soilBulkDensity.Value.Sand));
|
||||||
|
}
|
||||||
|
|
||||||
foreach (var item in soilPropertiesField)
|
foreach (var item in soilPropertiesField)
|
||||||
{
|
{
|
||||||
var soilProps = soilPropSoilType.Keys.Where(x => x.Item1 == item.Key).ToList();
|
var soilProps = soilPropSoilType.Keys.Where(x => x.Item1 == item.Key).ToList();
|
||||||
@@ -295,8 +332,7 @@ namespace FarmMapsAPI.Carbon
|
|||||||
// loop rothc
|
// loop rothc
|
||||||
//////////////////////////////////////////
|
//////////////////////////////////////////
|
||||||
|
|
||||||
var soc_Field = new Dictionary<string, List<YearColumnValue>>();
|
var soc_Field = new Dictionary<string, List<YearColumnValue>>();
|
||||||
var year = GetYears(farmInputSet, farmInput);
|
|
||||||
|
|
||||||
var cropAreaField1 = new Dictionary<(string, int), List<ColumnValue>>();
|
var cropAreaField1 = new Dictionary<(string, int), List<ColumnValue>>();
|
||||||
var carbonInputs = new GamsThreeKeyParameter();
|
var carbonInputs = new GamsThreeKeyParameter();
|
||||||
@@ -710,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)
|
||||||
@@ -719,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)
|
||||||
@@ -729,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.ToLower() == crop.ToLower())?.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.ToLower() == crop.ToLower())?.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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -753,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.ToLower() == crop.ToLower())?.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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -798,7 +874,7 @@ namespace FarmMapsAPI.Carbon
|
|||||||
foreach (var field in cropAreaField1.Where(x => x.Key.Item2 == loopYear))
|
foreach (var field in cropAreaField1.Where(x => x.Key.Item2 == loopYear))
|
||||||
{
|
{
|
||||||
var valueList = new List<ColumnValue>();
|
var valueList = new List<ColumnValue>();
|
||||||
var result = parameterSet.LayerDepth * soilPropertiesField[field.Key.Item1].Bulk_Density * soilPropertiesField[field.Key.Item1].OM_Corr * 0.54;
|
var result = parameterSet.LayerDepth * bulkDens[field.Key.Item1] * oM_Corr[field.Key.Item1] * 0.54;
|
||||||
foreach (var crop in field.Value)
|
foreach (var crop in field.Value)
|
||||||
{
|
{
|
||||||
valueList.Add(new ColumnValue(crop.Key, result));
|
valueList.Add(new ColumnValue(crop.Key, result));
|
||||||
@@ -1544,18 +1620,18 @@ namespace FarmMapsAPI.Carbon
|
|||||||
summary.Initial = sum;
|
summary.Initial = sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var item in soilPropertiesField)
|
foreach(var item in bulkDens)
|
||||||
{
|
{
|
||||||
var result = item.Value.Bulk_Density;
|
var result = item.Value;
|
||||||
foreach (var lYear in allYears)
|
foreach (var lYear in allYears)
|
||||||
{
|
{
|
||||||
soc_Summary[(item.Key, lYear)].Add(new ColumnValue("Bulk_Density", result));
|
soc_Summary[(item.Key, lYear)].Add(new ColumnValue("Bulk_Density", result));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var item in soilPropertiesField)
|
foreach (var item in bulkDens)
|
||||||
{
|
{
|
||||||
var result = item.Value.Bulk_Density;
|
var result = item.Value;
|
||||||
foreach (var lYear in allYears)
|
foreach (var lYear in allYears)
|
||||||
{
|
{
|
||||||
var summaries = cropFieldSummary.Single(x => x.Name == item.Key);
|
var summaries = cropFieldSummary.Single(x => x.Name == item.Key);
|
||||||
@@ -1637,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 });
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1729,7 +1803,7 @@ namespace FarmMapsAPI.Carbon
|
|||||||
var soilPropertiesField = new Dictionary<string, SoilPropertyType>();
|
var soilPropertiesField = new Dictionary<string, SoilPropertyType>();
|
||||||
foreach (var field in farmInput.CropFields)
|
foreach (var field in farmInput.CropFields)
|
||||||
{
|
{
|
||||||
soilPropertiesField.Add(field.Name, new SoilPropertyType { OM_Cont = field.SoilProperty.OM_Const.Value, Clay_Content = field.SoilProperty.Clay_Content.Value, OM_Corr = field.SoilProperty.OM_Const.Value <= 20 ? field.SoilProperty.OM_Const.Value : 0 });
|
soilPropertiesField.Add(field.Name, new SoilPropertyType { OM_Cont = field.SoilProperty.OM_Const.Value, Clay_Content = field.SoilProperty.Clay_Content.Value, OM_Corr = field.SoilProperty.OM_Const.Value <= 20 ? field.SoilProperty.OM_Const.Value : 0, Depth10 = field.SoilProperty.Depth10.Value });
|
||||||
}
|
}
|
||||||
|
|
||||||
return soilPropertiesField;
|
return soilPropertiesField;
|
||||||
@@ -1772,7 +1846,7 @@ namespace FarmMapsAPI.Carbon
|
|||||||
return cropAreaField;
|
return cropAreaField;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Dictionary<string, SoilBulkDensityType> GetSoilBulkDensities(Dictionary<string, SoilPropertyType> soilPropertiesField, Dictionary<string, List<string>> soilTypeData, Dictionary<(string, string), SoilPropertyType> soilPropSoilType)
|
private Dictionary<string, SoilBulkDensityType> GetSoilBulkDensities(Dictionary<string, SoilPropertyType> soilPropertiesField, Dictionary<string, List<string>> soilTypeData, Dictionary<(string, string), SoilPropertyType> soilPropSoilType, Dictionary<(string, string), double> oM_corr_SoilType)
|
||||||
{
|
{
|
||||||
var soilBulkDensities = new Dictionary<string, SoilBulkDensityType>();
|
var soilBulkDensities = new Dictionary<string, SoilBulkDensityType>();
|
||||||
foreach (var item in soilPropertiesField)
|
foreach (var item in soilPropertiesField)
|
||||||
@@ -1781,15 +1855,17 @@ namespace FarmMapsAPI.Carbon
|
|||||||
if (soilTypeData[item.Key].Any(x => x == "Klei"))
|
if (soilTypeData[item.Key].Any(x => x == "Klei"))
|
||||||
{
|
{
|
||||||
var soilBulkDensityKey = soilPropSoilType.Keys.Single(x => x.Item1 == item.Key && x.Item2 == "Klei");
|
var soilBulkDensityKey = soilPropSoilType.Keys.Single(x => x.Item1 == item.Key && x.Item2 == "Klei");
|
||||||
|
|
||||||
var clay = (0.6117 + (0.003601 * item.Value.Clay_Content)) +
|
var clay = (0.6117 + (0.003601 * item.Value.Clay_Content)) +
|
||||||
(0.002172 * soilPropSoilType[soilBulkDensityKey].OM_Corr * soilPropSoilType[soilBulkDensityKey].OM_Corr) +
|
(0.002172 * oM_corr_SoilType[(item.Key, "Klei")] * oM_corr_SoilType[(item.Key, "Klei")]) +
|
||||||
(0.01715 * Math.Log(soilPropSoilType[soilBulkDensityKey].OM_Corr));
|
(0.01715 * Math.Log(oM_corr_SoilType[(item.Key, "Klei")]));
|
||||||
|
|
||||||
soilBulkDensities[item.Key].Clay = clay;
|
soilBulkDensities[item.Key].Clay = clay;
|
||||||
}
|
}
|
||||||
if (soilTypeData[item.Key].Any(x => x == "Zand"))
|
if (soilTypeData[item.Key].Any(x => x == "Zand"))
|
||||||
{
|
{
|
||||||
var soilBulkDensityKey = soilPropSoilType.Keys.Single(x => x.Item1 == item.Key && x.Item2 == "Zand");
|
var soilBulkDensityKey = soilPropSoilType.Keys.Single(x => x.Item1 == item.Key && x.Item2 == "Zand");
|
||||||
soilBulkDensities[item.Key].Sand = 0.667 + (0.021 * soilPropSoilType[soilBulkDensityKey].OM_Corr);
|
soilBulkDensities[item.Key].Sand = 0.667 + (0.021 * oM_corr_SoilType[(item.Key, "Zand")]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return soilBulkDensities;
|
return soilBulkDensities;
|
||||||
@@ -1876,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,12 +8,12 @@
|
|||||||
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
|
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
|
||||||
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
|
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
|
||||||
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
|
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
|
||||||
<Version>1.1.3</Version>
|
<Version>1.2.0</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Base.Core.Common" Version="1.0.5.33-prerelease" />
|
<PackageReference Include="Base.Core.Common" Version="1.2.2.10" />
|
||||||
<PackageReference Include="Base.Core.Common.Geometry" Version="1.0.12.2000-prerelease" />
|
<PackageReference Include="Base.Core.Common.Geometry" Version="1.4.0" />
|
||||||
<PackageReference Include="NetTopologySuite" Version="2.0.0" />
|
<PackageReference Include="NetTopologySuite" Version="2.0.0" />
|
||||||
<PackageReference Include="NetTopologySuite.IO.GeoJSON" Version="2.0.4" />
|
<PackageReference Include="NetTopologySuite.IO.GeoJSON" Version="2.0.4" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ namespace CarbonService.Models
|
|||||||
[Required]
|
[Required]
|
||||||
public int PostalCode { get; set; }
|
public int PostalCode { get; set; }
|
||||||
public List<CropField> CropFields { get; set; }
|
public List<CropField> CropFields { get; set; }
|
||||||
//public List<OrgManureApplied> OrgManureApplied { get; set; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class CropField
|
public class CropField
|
||||||
@@ -38,14 +37,17 @@ namespace CarbonService.Models
|
|||||||
{
|
{
|
||||||
public double? OM_Const { get; set; }
|
public double? OM_Const { get; set; }
|
||||||
public double? Clay_Content { get; set; }
|
public double? Clay_Content { get; set; }
|
||||||
|
public bool? Depth10 { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class OrgManureApplied
|
public class OrgManureApplied
|
||||||
{
|
{
|
||||||
|
double? yield;
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
public string Crop { get; set; }
|
public string Crop { get; set; }
|
||||||
public List<OrganicManureType> OrganicManures { get; set; }
|
public List<OrganicManureType> OrganicManures { get; set; }
|
||||||
public int? CropYield { get; set; }
|
public double? CropYield { get { return (int?)yield; } set { yield = value; } }
|
||||||
public bool CropRes { get; set; }
|
public bool CropRes { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,8 +63,6 @@ namespace CarbonService.Models
|
|||||||
{
|
{
|
||||||
[Required]
|
[Required]
|
||||||
public int Year { get; set; }
|
public int Year { get; set; }
|
||||||
//[Required]
|
|
||||||
//public List<string> Crops { get; set; }
|
|
||||||
[Required]
|
[Required]
|
||||||
public List<OrgManureApplied> Crops { get; set; }
|
public List<OrgManureApplied> Crops { get; set; }
|
||||||
}
|
}
|
||||||
@@ -80,7 +80,6 @@ namespace CarbonService.Models
|
|||||||
[Required]
|
[Required]
|
||||||
public string Type { get; set; }
|
public string Type { get; set; }
|
||||||
|
|
||||||
//public string Quality { get; set; }
|
|
||||||
[JsonConverter(typeof(StringEnumConverter))]
|
[JsonConverter(typeof(StringEnumConverter))]
|
||||||
public Quality Quality { get; set; }
|
public Quality Quality { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,8 +9,6 @@ namespace FarmMapsAPI.Carbon.Models
|
|||||||
{
|
{
|
||||||
[JsonProperty("cropField")]
|
[JsonProperty("cropField")]
|
||||||
public List<CropFieldSummary> CropField { get; set; }
|
public List<CropFieldSummary> CropField { get; set; }
|
||||||
//[JsonProperty("farmSummary")]
|
|
||||||
//public List<FarmYearSummary> FarmSummary { get; set; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class CropFieldSummary
|
public class CropFieldSummary
|
||||||
|
|||||||
@@ -15,5 +15,6 @@ namespace FarmMapsAPI.Carbon.Models
|
|||||||
public List<StrawCrp> StrawCrops { get; set; }
|
public List<StrawCrp> StrawCrops { get; set; }
|
||||||
public List<string> GreenManureType { get; set; }
|
public List<string> GreenManureType { get; set; }
|
||||||
public List<string> Perennial { get; set; }
|
public List<string> Perennial { get; set; }
|
||||||
|
public List<string> Grass_nat { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,11 +54,13 @@ namespace FarmMapsAPI.Carbon.Models
|
|||||||
|
|
||||||
public class CropData
|
public class CropData
|
||||||
{
|
{
|
||||||
|
double? yield;
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
public string CropCode { get; set; }
|
public string CropCode { get; set; }
|
||||||
public string MiterraCropName { get; set; }
|
public string MiterraCropName { get; set; }
|
||||||
public List<OrganicManureFarmMaps> OrganicManures { get; set; }
|
public List<OrganicManureFarmMaps> OrganicManures { get; set; }
|
||||||
public int? CropYield { get; set; }
|
public double? CropYield { get { return (int?)yield; } set { yield = value; } }
|
||||||
public bool CropRes { get; set; }
|
public bool CropRes { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,6 +76,7 @@ namespace FarmMapsAPI.Carbon.Models
|
|||||||
{
|
{
|
||||||
public double? OM_Const { get; set; }
|
public double? OM_Const { get; set; }
|
||||||
public double? Clay_Content { get; set; }
|
public double? Clay_Content { get; set; }
|
||||||
|
public bool Depth10 { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class GreenManureTypeFarmMaps
|
public class GreenManureTypeFarmMaps
|
||||||
|
|||||||
@@ -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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ namespace FarmMapsAPI.Carbon.Models
|
|||||||
public double Bulk_Density { get; set; }
|
public double Bulk_Density { get; set; }
|
||||||
public double Clay_Content { get; set; }
|
public double Clay_Content { get; set; }
|
||||||
public double Depth { get; set; }
|
public double Depth { get; set; }
|
||||||
|
public bool Depth10 { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
struct SoilTypePropertyKey
|
struct SoilTypePropertyKey
|
||||||
|
|||||||
@@ -122,56 +122,56 @@
|
|||||||
"Name": "Vegetables_root",
|
"Name": "Vegetables_root",
|
||||||
"DM_content": 0.099,
|
"DM_content": 0.099,
|
||||||
"FracR": 0.0,
|
"FracR": 0.0,
|
||||||
"C_input_CropRes": 9.92567356324928,
|
"C_input_CropRes": 1.61648275862069,
|
||||||
"HarvestIndex": 0.627333333333333
|
"HarvestIndex": 0.627333333333333
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Name": "Vegetables_leaf",
|
"Name": "Vegetables_leaf",
|
||||||
"DM_content": 0.04575,
|
"DM_content": 0.04575,
|
||||||
"FracR": 0.0,
|
"FracR": 0.0,
|
||||||
"C_input_CropRes": 1.68445934694249,
|
"C_input_CropRes": 0.704347826086956,
|
||||||
"HarvestIndex": 0.56125
|
"HarvestIndex": 0.56125
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Name": "Vegetables_cabbage",
|
"Name": "Vegetables_cabbage",
|
||||||
"DM_content": 0.0837058823529412,
|
"DM_content": 0.0837058823529412,
|
||||||
"FracR": 0.0,
|
"FracR": 0.0,
|
||||||
"C_input_CropRes": 5.214,
|
"C_input_CropRes": 2.75625,
|
||||||
"HarvestIndex": 0.472941176470588
|
"HarvestIndex": 0.472941176470588
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Name": "Vegetables_stem",
|
"Name": "Vegetables_stem",
|
||||||
"DM_content": 0.0752,
|
"DM_content": 0.0752,
|
||||||
"FracR": 0.0,
|
"FracR": 0.0,
|
||||||
"C_input_CropRes": 2.55076183390058,
|
"C_input_CropRes": 0.704347826086956,
|
||||||
"HarvestIndex": 0.602
|
"HarvestIndex": 0.602
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Name": "Pumpkin",
|
"Name": "Pumpkin",
|
||||||
"DM_content": 0.183,
|
"DM_content": 0.183,
|
||||||
"FracR": 0.0,
|
"FracR": 0.0,
|
||||||
"C_input_CropRes": 7.02589285714286,
|
"C_input_CropRes": 0.704347826086956,
|
||||||
"HarvestIndex": 0.56
|
"HarvestIndex": 0.56
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Name": "Chicory",
|
"Name": "Chicory",
|
||||||
"DM_content": 0.233,
|
"DM_content": 0.233,
|
||||||
"FracR": 0.0,
|
"FracR": 0.0,
|
||||||
"C_input_CropRes": 5.52344767793542,
|
"C_input_CropRes": 1.40869565217391,
|
||||||
"HarvestIndex": 0.6
|
"HarvestIndex": 0.6
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Name": "Courgette",
|
"Name": "Courgette",
|
||||||
"DM_content": 0.048,
|
"DM_content": 0.048,
|
||||||
"FracR": 0.0,
|
"FracR": 0.0,
|
||||||
"C_input_CropRes": 6.17457329509681,
|
"C_input_CropRes": 0.704347826086956,
|
||||||
"HarvestIndex": 0.40
|
"HarvestIndex": 0.40
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Name": "Other_veg",
|
"Name": "Other_veg",
|
||||||
"DM_content": 0.10967,
|
"DM_content": 0.10967,
|
||||||
"FracR": 0.0,
|
"FracR": 0.0,
|
||||||
"C_input_CropRes": 5.44269,
|
"C_input_CropRes": 1.22840281644892,
|
||||||
"HarvestIndex": 0.54622
|
"HarvestIndex": 0.54622
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -69,5 +69,10 @@
|
|||||||
"Miscanthus",
|
"Miscanthus",
|
||||||
"Switchgrass",
|
"Switchgrass",
|
||||||
"Willow"
|
"Willow"
|
||||||
|
],
|
||||||
|
"Grass_nat": [
|
||||||
|
"Perm_gras",
|
||||||
|
"Nat_gras",
|
||||||
|
"Gras"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -36,6 +36,22 @@
|
|||||||
"ManureSource_liv": "DIGEST",
|
"ManureSource_liv": "DIGEST",
|
||||||
"Description": "Digestaat"
|
"Description": "Digestaat"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"ManureSource_liv": "CHAMPOST",
|
||||||
|
"Description": "Champost"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ManureSource_liv": "SCHA_GEIT",
|
||||||
|
"Description": "Schapen/geitenmest"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ManureSource_liv": "VMPIG",
|
||||||
|
"Description": "Vaste varkensmest"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ManureSource_liv": "DM_ZEUG",
|
||||||
|
"Description": "Zeugendrijfmest"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"ManureSource_liv": "OVERIG",
|
"ManureSource_liv": "OVERIG",
|
||||||
"Description": "Overig"
|
"Description": "Overig"
|
||||||
|
|||||||
Reference in New Issue
Block a user