write A1 yield & strawYield to output

update definitions
update TODO.txt
master
Pepijn van Oort 2024-03-11 14:35:03 +01:00
parent 67014e20f5
commit ffbb45894a
6 changed files with 89 additions and 75 deletions

View File

@ -403,50 +403,50 @@ namespace FarmmapsKPI
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<string>
// {
// 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<string>
// {
// 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")
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<string>
{
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
// TtD 20240311: note elements of A1 are in the data structure elements of kpio.data and not as below for B1, B2, etc as kpio.data.values
string elementValue = (string)kpio.data.GetType().GetProperty(elementName).GetValue(kpio.data, null);
dataList = new List<string>
{
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")
{
//Make a new dataList = new line to be written
//Fill the datalist with this kpi

View File

@ -145,8 +145,8 @@
"soilName": "Sand",
"cropTypeCode": "1010101", //From codelist CL263
"cropTypeName": "Potato", //From codelist CL263
"productionPurposeCode": "003", //From codelist CL251. For testing, see case with consumption & starch potato
"productionPurposeName": "consumption" //From codelist CL251
"productionPurposeCode": "002", //From codelist CL251. For testing, see case with consumption & starch potato
"productionPurposeName": "starch" //From codelist CL251
},
"CropRecordingItemCode": "", // could contain for example this: "314aa1b6480b493ba28a5f55039a01d4" if this is the CropRecordingItemCode of the provided CropfieldItemCode. And then if useExistingCropfieldWithChildren = true, this would be used
"OperationItemCodes": [], // could contain for example this: ["4d1a6f28ea3f414180663baa4b08c60f"] or ["4d1a6f28ea3f414180663baa4b08c60f","21e08386f0454ad79acfebf78649d59b"] if these are the operations of the provided CropRecordingItemCode. And then if useExistingCropfieldWithChildren = true, these would be used

View File

@ -1,26 +1,25 @@
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,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,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"
KPIid,KPIvariable,Description,,
A1,yield,observed yield (user input),,
A1,strawYield,straw yield (user input; value 0 or not filled in = straw remains in field; value > 0 means straw was exported),,
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,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,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.
C1,cropLeftoversEom,Effective organic matter added through crop residues of main product and (when relevant) straw. Calculated KPI internal model & parameters.
D1,pesticides,"kg/ha of active ingredient. Sum over kg a.i. of the different crop protection agents applied, with concentration (kg a.i. / kg or litre) of crop protection agents retrieved from CTBG"
E1,mpb,"milieubelastingspunten. For each pesticide applied show 3 sub-mbp's: aquaticLife, groundWater, soilLife"
E1,mpb,
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
C1,greenManureEom,Effective organic matter added through green manure (also called cover crop). Calculated KPI internal model & parameters and from user input: cover crop.,,
C1,cropLeftoversEom,Effective organic matter added through crop residues of main product and (when relevant) straw. Calculated KPI internal model & parameters.,,
D1,pesticides,"kg/ha of active ingredient. Sum over kg a.i. of the different crop protection agents applied, with concentration (kg a.i. / kg or litre) of crop protection agents retrieved from CTBG",,
E1,mpb,"milieubelastingspunten. For each pesticide applied show 3 sub-mbp's: aquaticLife, groundWater, soilLife",,
E1,mpb,,,
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,,

Can't render this file because it has a wrong number of fields in line 16.

View File

@ -0,0 +1,9 @@
KPIid,KPIvariable,KPItargetvalue,KPIthresholdValue
A1,yield,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,no threshold for this KPI
B1,nitrogen,etc,
B2,phosphate,,
C1,effective organic matter supply,,
D1,pesticides,,
E1,mpb,,
F1,greenness,,
F2,rotationindex,,
1 KPIid KPIvariable KPItargetvalue KPIthresholdValue
2 A1 yield 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 no threshold for this KPI
3 B1 nitrogen etc
4 B2 phosphate
5 C1 effective organic matter supply
6 D1 pesticides
7 E1 mpb
8 F1 greenness
9 F2 rotationindex

View File

@ -34,6 +34,9 @@ namespace FarmmapsKPI.Models
public string area { get; set; }
public string cropTypeCode { get; set; }
public string cropTypeName { get; set; }
public string yield { get; set; }
public string strawYield { get; set; }
public KPIelementsOfBalance values { get; set; }
public KPIenvironmentMeasureData[] environmentMeasureData { get; set; }

View File

@ -40,12 +40,17 @@ KPIelementsOfBalance: Tamara
d. for phosporous B2 rename from pFertilizerNKgHa to pFertilizerPKgHa COMPLETED
e. idem sowPlantingNKgHa COMPLETED
f. add straw for N & P in output COMPLETED
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
###################################################################################################
# 2. Pending
###################################################################################################
Testing:
productionPurposeCode: different result depending on starch or consumption potato (different N contents in tubers)?
nContentFactor seems not to be adjusted by productionPurposeCode. Tamara check with Francisco
idem for pContentFactor
DONE (using KPIinput.json): surprisingly no effect?
dataOperations: "operationCode": "7" & "8":
@ -57,7 +62,5 @@ dataOperations: "status": "3":
b. using KPIinput.json: does it have an effect on KPI outcomes? NOT YET TESTED
KPIelementsOfBalance: Tamara
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'
j. for C1 rename 'cropLeftoversEom' to 'cropResiduesEom' GEPARKEERD
k. fill in new file KPIdefinitionsTargetsThresholds.csv with definitions of targets & thresholds per KPI element (A1, B1, etc)