aw3567: added 10cm depth measurement
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:
@@ -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)
|
||||||
@@ -242,6 +242,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 +252,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 +264,64 @@ 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>();
|
||||||
|
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 +339,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();
|
||||||
@@ -798,7 +841,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 +1587,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);
|
||||||
@@ -1729,7 +1772,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 +1815,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 +1824,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;
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ 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
|
||||||
|
|||||||
@@ -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; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,6 +74,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
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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