aw5598, 5599, 5600, 5601: several carbon changes
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:
@@ -239,6 +239,8 @@ namespace FarmMapsAPI.Carbon
|
||||
|
||||
var year = GetYears(farmInputSet, farmInput);
|
||||
|
||||
var carbon_organicmatter_factor = 0.54;
|
||||
|
||||
//////////////////////////////////////////////
|
||||
// precalculations
|
||||
//////////////////////////////////////////////
|
||||
@@ -266,6 +268,10 @@ namespace FarmMapsAPI.Carbon
|
||||
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 (item.Value.Depth.HasValue && item.Value.Depth.Value == 10)
|
||||
{
|
||||
soilPropertyDepth10 = true;
|
||||
}
|
||||
//FSA todo: different corrections for depth10 (10, 25, 30 cm)
|
||||
if (initialSoil == "Temp_gras" && soilPropertyDepth10)
|
||||
{
|
||||
@@ -781,7 +787,17 @@ namespace FarmMapsAPI.Carbon
|
||||
smdMaxValue = smdMax[climateItem.Key] / 1.8;
|
||||
}
|
||||
//fsa todo: add precipitation
|
||||
var result = climateItem.Value[i].Precipitation - climateItem.Value[i].Evapotranspiration;
|
||||
var irrigation = 0;
|
||||
var irrigations = farmInput.CropFields[0].HistoricalCropData.SingleOrDefault(x => x.Year == loopYear).Crops[0].Irrigation;
|
||||
if (!string.IsNullOrEmpty(irrigations))
|
||||
{
|
||||
var irrigationArray = irrigations.Split(',');
|
||||
if (irrigationArray.Length > i)
|
||||
{
|
||||
irrigation = string.IsNullOrEmpty(irrigationArray[i]) ? 0 : Convert.ToInt16(irrigationArray[i]);
|
||||
}
|
||||
}
|
||||
var result = climateItem.Value[i].Precipitation - climateItem.Value[i].Evapotranspiration + irrigation;
|
||||
result = result < 0 ? result : 0;
|
||||
result = result < smdMaxValue ? smdMaxValue : result;
|
||||
valueList.Add(new ColumnValue("M1", result));
|
||||
@@ -801,7 +817,17 @@ namespace FarmMapsAPI.Carbon
|
||||
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 irrigation = 0;
|
||||
var irrigations = farmInput.CropFields[0].HistoricalCropData.SingleOrDefault(x => x.Year == loopYear).Crops[0].Irrigation;
|
||||
if (!string.IsNullOrEmpty(irrigations))
|
||||
{
|
||||
var irrigationArray = irrigations.Split(',');
|
||||
if (irrigationArray.Length > i)
|
||||
{
|
||||
irrigation = string.IsNullOrEmpty(irrigationArray[i]) ? 0 : Convert.ToInt16(irrigationArray[i]);
|
||||
}
|
||||
}
|
||||
var result = climateItem.Value[i].Precipitation - climateItem.Value[i].Evapotranspiration + valueList.SingleOrDefault(x => x.Key == $"M{i}").Value + irrigation;
|
||||
result = result < 0 ? result : 0;
|
||||
result = result < smdMaxValue ? smdMaxValue : result;
|
||||
valueList.Add(new ColumnValue($"M{i + 1}", result));
|
||||
@@ -876,7 +902,7 @@ namespace FarmMapsAPI.Carbon
|
||||
foreach (var field in cropAreaField1.Where(x => x.Key.Item2 == loopYear))
|
||||
{
|
||||
var valueList = new List<ColumnValue>();
|
||||
var result = parameterSet.LayerDepth * bulkDens[field.Key.Item1] * oM_Corr[field.Key.Item1] * 0.54;
|
||||
var result = parameterSet.LayerDepth * bulkDens[field.Key.Item1] * oM_Corr[field.Key.Item1] * carbon_organicmatter_factor;// 0.54;
|
||||
foreach (var crop in field.Value)
|
||||
{
|
||||
valueList.Add(new ColumnValue(crop.Key, result));
|
||||
@@ -1685,7 +1711,7 @@ namespace FarmMapsAPI.Carbon
|
||||
var iniValue = item.Value.SingleOrDefault(x => x.Key == "IniCcontent")?.Value ?? 0;
|
||||
var balanceValue = item.Value.SingleOrDefault(x => x.Key == "Balance")?.Value ?? 0;
|
||||
|
||||
var resultOmIni = iniValue / 0.54;
|
||||
var resultOmIni = iniValue / carbon_organicmatter_factor;// 0.54;
|
||||
var resultCo2 = balanceValue * (44.0 / 12.0);
|
||||
|
||||
item.Value.Add(new ColumnValue("OM_ini", resultOmIni));
|
||||
@@ -1704,7 +1730,7 @@ namespace FarmMapsAPI.Carbon
|
||||
var greenManure = item.SOC_CarbonGreenManure;
|
||||
var compost = item.SOC_CarbonCompost;
|
||||
|
||||
item.OM_ini = iniValue / 0.54;
|
||||
item.OM_ini = iniValue / carbon_organicmatter_factor;// 0.54;
|
||||
item.CO2seq = balanceValue * (44.0 / 12.0);
|
||||
|
||||
var emision = -1 * (manure + residues + greenManure + compost - balanceValue);
|
||||
@@ -1758,7 +1784,7 @@ namespace FarmMapsAPI.Carbon
|
||||
var resultBal = sumBal / farmArea.Total_crop_area;
|
||||
var resultIni = sumIni / farmArea.Total_crop_area;
|
||||
var resultiniCc = sumInicc / farmArea.Total_crop_area;
|
||||
var resultOm_Ini = resultiniCc / 0.54;
|
||||
var resultOm_Ini = resultiniCc / carbon_organicmatter_factor;// 0.54;
|
||||
var resultCo2 = resultBal * (44.0 / 12.0);
|
||||
var resultCo2Tot = resultCo2 * farmArea.Total_crop_area;
|
||||
|
||||
@@ -1805,7 +1831,7 @@ namespace FarmMapsAPI.Carbon
|
||||
var soilPropertiesField = new Dictionary<string, SoilPropertyType>();
|
||||
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, Depth10 = field.SoilProperty.Depth10.Value });
|
||||
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, Depth = field.SoilProperty.Depth });
|
||||
}
|
||||
|
||||
return soilPropertiesField;
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace FarmMapsAPI.Carbon.Models
|
||||
public double OM_Corr { get; set; }
|
||||
public double Bulk_Density { get; set; }
|
||||
public double Clay_Content { get; set; }
|
||||
public double Depth { get; set; }
|
||||
public int? Depth { get; set; }
|
||||
public bool Depth10 { get; set; }
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user