diff --git a/FarmmapsKPI/KPIApplication.cs b/FarmmapsKPI/KPIApplication.cs index e76b07f..c25acc2 100644 --- a/FarmmapsKPI/KPIApplication.cs +++ b/FarmmapsKPI/KPIApplication.cs @@ -401,8 +401,51 @@ namespace FarmmapsKPI if (kpio.id != null) { if (kpio.id != kpioPrevious.id) - { + { KPIelementsOfBalance kPIelementsOfBalance = kpio.data.values; + //if (kpio.id == "A1") //TtD not functional + //{ + // //Make a new dataList = new line to be written + // //Fill the datalist with this kpi + // dataList = new List + // { + // kpio.parentName, + // cropfieldItem.Code, + // kpio.data.area, + // kpio.data.cropTypeCode, + // kpio.data.cropTypeName, + // kpio.id, + // kpio.quantity, // in KPI output quantity is what we call KPIvariable in headerlist of csv file + // kpio.value, + // kpio.unit, + // kpio.targetValue, + // kpio.thresholdValue + // }; + // //Write the datalist to a line to the streamwrieter sw for the output csv file + // sw.WriteLine(string.Join(",", dataList)); + // foreach (string elementName in kpio.A1elements) + // { + // // get A1element from the element called values + // string elementValue = (string)kPIelementsOfBalance.GetType().GetProperty(elementName).GetValue(kPIelementsOfBalance, null); + // dataList = new List + // { + // kpio.parentName, + // cropfieldItem.Code, + // kpio.data.area, + // kpio.data.cropTypeCode, + // kpio.data.cropTypeName, + // kpio.id, + // elementName, // specific output variable name for A1 element + // elementValue, // specific output value name for A1 element + // kpio.unit, + // "", + // "" + // }; + // //Write the datalist to a line to the streamwrieter sw for the output csv file + // sw.WriteLine(string.Join(",", dataList)); + // } + //} + //else if (kpio.id == "B1") if (kpio.id == "B1") { //Make a new dataList = new line to be written diff --git a/FarmmapsKPI/KPIdefinitions.csv b/FarmmapsKPI/KPIdefinitions.csv index f6f2ac6..b832ccd 100644 --- a/FarmmapsKPI/KPIdefinitions.csv +++ b/FarmmapsKPI/KPIdefinitions.csv @@ -1,15 +1,17 @@ KPIid,KPIvariable,Description A1,yield,observed yield (user input) B1,nitrogen,Nitrogen surplus = N artifical fertilizer + N manure+ N atmospheric deposition + N fixation by crop + N from seed potatoes - N removal through harvested product. Calculated KPI internal model & parameters and from user input: yield and fertilizer/manure applications. -B1,disposal, N removal through harvested product. Calculated KPI internal model & parameters and from user input: yield. +B1,nHarvestedKgHa, N removal through harvested product. Calculated KPI internal model & parameters and from user input: yield. +B1,nHarvestedStrawKgHa, N removal through harvested product. Calculated KPI internal model & parameters and from user input: yieldStraw. B1,nFixationNKgHa, N fixated by crop (legumes only). Calculated KPI internal model & parameters and from user input: planting date B1,nDepositionNKgHa, N deposition based on RIVM maps. B1,nFertilizerNKgHa, N from artifical fertilizers and manure.Calculated KPI internal model & parameters and from user input: fertilizer/manure applications. B1,sowPlantingNKgHa, N from seed potatoes (potatoes only). Calculated KPI internal model & parameters and from user input: amount of planted seed potatoes B2,phosphate,Phosphate surplus = P fertilizer + P from seed potatoes - P removal through harvested product. Calculated KPI internal model & parameters and from user input: yield and fertilizer applications -B2,disposal, P2O5 removal through harvested product. Calculated KPI internal model & parameters and from user input: yield -B2,pFertillizerNKgHa, P2O5 from artifical fertilizers and manure.Calculated KPI internal model & parameters and from user input: fertilizer/manure applications. -B2,sowPlantingNKgHa, P2O5 from seeds potatoes (potatoes only). Calculated KPI internal model & parameters and from user input: amount of planted seed potatoes +B2,pHarvestedKgHa, P2O5 removal through harvested product. Calculated KPI internal model & parameters and from user input: yield +B2,pHarvestedStrawKgHa, P2O5 removal through harvested product. Calculated KPI internal model & parameters and from user input: yieldStraw +B2,pFertillizerPKgHa, P2O5 from artifical fertilizers and manure.Calculated KPI internal model & parameters and from user input: fertilizer/manure applications. +B2,sowPlantingPKgHa, P2O5 from seeds potatoes (potatoes only). Calculated KPI internal model & parameters and from user input: amount of planted seed potatoes C1,effective organic matter supply,"Organic matter supply = Organic matter from manure + Crop residues to soil + organic matter from green manure. Calculated KPI internal model & parameters and from user input: yield and manure applications. ""Effective"" means netto, after correction for carbon respiration by soil microbial activity" C1,fertilizerEom,Effective organic matter added through fertilizer (animal manure, compost, etc). Calculated KPI internal model & parameters and from user input: manure applications. C1,greenManureEom,Effective organic matter added through green manure (also called cover crop). Calculated KPI internal model & parameters and from user input: cover crop. @@ -21,4 +23,4 @@ E1,mpb,? F1,greenness, time of year that the field was covered. Based on NDVI data from AgroDataCube. F2,rotationindex, index of diversity of crops over time. Calculated in AgroDataCube ,KPItargetvalue,target value as in benchmark value for same crop in same region. E.g. cropyield target is from Central Bureau of Statistics (CBS) for same crop in region in which the cropfield (geometry) is located -,KPIthresholdValue,threshold from ??? Ask farmmaps. Surplus nitrogen / phosphate / pesticides must not be above threshold. Surplus organic matter supply must be above threshold +,KPIthresholdValue,threshold from ??? Ask farmmaps. Surplus nitrogen / phosphate / pesticides must not be above threshold. Surplus organic matter supply must be above threshold \ No newline at end of file diff --git a/FarmmapsKPI/Models/KPIoutput.cs b/FarmmapsKPI/Models/KPIoutput.cs index b7dd992..6a8255a 100644 --- a/FarmmapsKPI/Models/KPIoutput.cs +++ b/FarmmapsKPI/Models/KPIoutput.cs @@ -16,16 +16,17 @@ namespace FarmmapsKPI.Models public string parentName { get; set; } public string targetValue { get; set; } public string thresholdValue { get; set; } - + + public List A1elements; //TtD public List B1elements; public List B2elements; - public List C1elements; //TtD + public List C1elements; public KPIOutput() { - this.B1elements = new List() { "disposal", "nFixationNKgHa", "nDepositionNKgHa","nFertilizerNKgHa","sowPlantingNKgHa" }; //TODO Tamara: rename disposal to nHarvestedNKgHa - this.B2elements = new List() { "disposal", "pFertillizerNKgHa", "sowPlantingNKgHa" }; //TODO Tamara: rename from pFertilizerNKgHa to pFertilizerPKgHa; rename disposal to pHarvestedPKgHa - this.C1elements = new List() { "fertilizerEom", "greenManureEom", "cropLeftoversEom" }; //TtD - + this.A1elements = new List() { "yield", "strawYield" }; //TtD + this.B1elements = new List() { "nHarvestedKgHa", "nHarvestedStrawKgHa", "nFixationNKgHa", "nDepositionNKgHa","nFertilizerNKgHa","sowPlantingNKgHa" }; //TtD + this.B2elements = new List() { "pHarvestedKgHa", "pHarvestedStrawKgHa", "pFertillizerPKgHa", "sowPlantingPKgHa" }; //TtD + this.C1elements = new List() { "fertilizerEom", "greenManureEom", "cropLeftoversEom" }; //TtD to do rename } } public class KPIOutputData @@ -50,18 +51,20 @@ namespace FarmmapsKPI.Models } public class KPIelementsOfBalance { - public string disposal { get; set; } //TODO Tamara: rename this one + public string yield { get; set; } //TtD + public string strawYield { get; set; } //TtD + public string nHarvestedKgHa { get; set; } //TtD + public string nHarvestedStrawKgHa { get; set; } //TtD public string nFixationNKgHa { get; set; } public string nDepositionNKgHa { get; set; } public string nFertilizerNKgHa { get; set; } public string sowPlantingNKgHa { get; set; } - public string pFertillizerNKgHa { get; set; } //TODO Tamara: delete this one after renaming - public string pFertilizerPKgHa { get; set; } - public string sowPlantingPKgHa { get; set; } + public string pHarvestedKgHa { get; set; } //TtD + public string pHarvestedStrawKgHa { get; set; } //TtD + public string pFertillizerPKgHa { get; set; } //TtD + public string sowPlantingPKgHa { get; set; } //TtD public string fertilizerEom { get; set; } //TtD public string greenManureEom { get; set; } //TtD - public string cropLeftoversEom { get; set; } //TtD - - + public string cropLeftoversEom { get; set; } //TtD tamara: rename } } \ No newline at end of file diff --git a/FarmmapsKPI/TODO.txt b/FarmmapsKPI/TODO.txt index dbf7b7a..f08ace5 100644 --- a/FarmmapsKPI/TODO.txt +++ b/FarmmapsKPI/TODO.txt @@ -30,8 +30,16 @@ Effect of soiltype (e.g. different N concents in crop depending on soiltype? (CL Effect of location (e.g. different atmospheric N deposition). DONE (using KPIinput.json): slightly different N balance + "DataCropfieldCharacteristic": { + "code": "860619", //PO20231004: so what does this code mean? Can we see the code list somewhere? COMPLETED code comes from codelist CL265. 860619 refers to cropyield in ton/ha + KPIelementsOfBalance: Tamara a. define elements for C1 organic matter supply + b. for nitrogen B1 rename disposal to nHarvestedNKgHa COMPLETED + c. for phosporous B2 rename disposal to pHarvestedPKgHa COMPLETED + d. for phosporous B2 rename from pFertilizerNKgHa to pFertilizerPKgHa COMPLETED + e. idem sowPlantingNKgHa COMPLETED + f. add straw for N & P in output COMPLETED ################################################################################################### # 2. Pending @@ -48,15 +56,8 @@ dataOperations: "status": "3": a. which codelist? What does it mean? NOT YET TESTED b. using KPIinput.json: does it have an effect on KPI outcomes? NOT YET TESTED -"DataCropfieldCharacteristic": { - "code": "860619", //PO20231004: so what does this code mean? Can we see the code list somewhere? NOT YET TESTED - KPIelementsOfBalance: Tamara - b. for nitrogen B1 rename disposal to nHarvestedNKgHa PARTLY - c. for phosporous B2 rename disposal to pHarvestedPKgHa PARTLY - d. for phosporous B2 rename from pFertilizerNKgHa to pFertilizerPKgHa PARTLY - e. idem sowPlantingNKgHa PARTLY - f. add straw for N & P in output - g. add 2 examples in KPIinput.json: straw yes/no removed. Bijv. nStrawLeftInField EN nStrawRemoved - h. update KPIdefinitions.csv PARTLY - i. for C1 rename 'cropLeftoversEom' to 'cropResiduesEom' \ No newline at end of file + g. add 2 examples in KPIinput.json: straw yes/no removed. Bijv. nStrawLeftInField EN nStrawRemoved COMPLETED but not yet fully functional + h. add amount of removed straw in A1 + i. update KPIdefinitions.csv PARTLY + j. for C1 rename 'cropLeftoversEom' to 'cropResiduesEom' \ No newline at end of file