# Cocoa -- Source: from Technical Conversion Factors for Agricultural Commodities (http://countrystat.org/resources/documents/tcf.pdf)
# Assumptions: we just look at chocolate production from cocoa comodity tree up to 2nd level
# level: second level where available.
add_row(crop_cifos="cocoa_beans",proc_raw="Cocoa beans",proc_in="cocoa_for_chocolate",proc_out="cocoa_butter",value=0.47*.8,dietary_products="Cocoa Beans and products")%>%
add_row(crop_cifos="cocoa_beans",proc_raw="Cocoa beans",proc_in="cocoa_for_chocolate",proc_out="cocoa_powder_cake",value=0.53*.8,dietary_products="Cocoa Beans and products")%>%
add_row(crop_cifos="cocoa_beans",proc_raw="Cocoa beans",proc_in="cocoa_for_chocolate",proc_out="cocoa_husks",value=0.2,dietary_products="Cocoa Beans and products")%>%
drop_na()%>%
# Coconut -- Source: from Technical Conversion Factors for Agricultural Commodities (http://countrystat.org/resources/documents/tcf.pdf)
# Assumptions: It adds not up to 1 due to water loss
# levels: second level where available, no data for copra only!
# Cassava -- Source: from Technical Conversion Factors for Agricultural Commodities (http://countrystat.org/resources/documents/tcf.pdf); adjusted commodity tree.
# Levels: only one level in tcf doc!
add_row(crop_cifos="cassava",proc_raw="cassava",proc_in="cassava_flourin",proc_out="cassava_flour",value=0.3,dietary_products="Cassava and products")%>%
add_row(crop_cifos="cassava",proc_raw="cassava",proc_in="cassava_tapiocain",proc_out="cassava_tapioca",value=0.2,dietary_products="Cassava and products")%>%
add_row(crop_cifos="cassava",proc_raw="cassava",proc_in="cassava_dryin",proc_out="cassava_dry",value=0.35,dietary_products="Cassava and products")%>%
add_row(crop_cifos="cassava",proc_raw="cassava",proc_in="cassava_starchin",proc_out="cassava_starch",value=0.25,dietary_products="Cassava and products")%>%
# Pearl millet -- Source: from Technical Conversion Factors for Agricultural Commodities (http://countrystat.org/resources/documents/tcf.pdf); adjusted commodity tree; fractions from "cereals/millet"
# levels: only one level
add_row(crop_cifos="pearl_millet",proc_raw="pearl_millet",proc_in="pearl_millet_flourin",proc_out="pearl_millet_flour",value=0.86,dietary_products="Millet and products")%>%
add_row(crop_cifos="pearl_millet",proc_raw="pearl_millet",proc_in="pearl_millet_flourin",proc_out="pearl_millet_bran",value=0.10,dietary_products="Millet and products")%>%
add_row(crop_cifos="pearl_millet",proc_raw="pearl_millet",proc_in="pearl_millet_beerin",proc_out="pearl_millet_beer",value=4.5,dietary_products="Millet and products")%>%
# Oil palm -- Source: from Technical Conversion Factors for Agricultural Commodities (http://countrystat.org/resources/documents/tcf.pdf); adjusted commodity tree; fractions from "OIL PALM FRUIT"
# Assumption: oil_palm_kernels_fibre is just the difference of the sum of the listed categories to 1.
# Both kernels and fruits are always both processed
# levels, only level 1 used (level 2 does not make)
add_row(crop_cifos="sorghum",proc_raw="sorghum",proc_in="sorghum_flourin",proc_out="sorghum_flour",value=0.9,dietary_products="Sorghum and products")%>%
add_row(crop_cifos="sorghum",proc_raw="sorghum",proc_in="sorghum_flourin",proc_out="sorghum_bran",value=0.08,dietary_products="Sorghum and products")%>%
add_row(crop_cifos="sorghum",proc_raw="sorghum",proc_in="sorghum_beerin",proc_out="sorghum_beer",value=4.85,dietary_products="Sorghum and products")%>%#on first level
add_row(crop_cifos="sugar_cane",proc_raw="sugar_raw",proc_in="for_sugar_white",proc_out="sugar_white",value=0.935,dietary_products="Sugar (Raw Equivalent)")%>%# 2nd level of sugar raw
# add_row(crop_cifos = "sugar_cane" , proc_raw = "sugar_raw" , proc_in = "for_sugar_white", proc_out = "sugar_factorylime", value = 1-0.935, dietary_products = "Sugar (Raw Equivalent)") %>% # 2nd level of sugar raw
add_row(crop_cifos="other_crops",proc_raw="chilies_and_peppers_green",proc_in="chilies_and_peppers_green",proc_out="chilies_and_peppers_green",value=0.9,dietary_products="Pulses, Other and products")%>%# Commodity tree, from Egypt "Chillies, green"
add_row(crop_cifos="chick_peas",proc_raw="chick_peas",proc_in="chickpea_vegetablein",proc_out="chickpea_vegetable",value=0.95,dietary_products="Pulses, Other and products")%>%
add_row(crop_cifos="chick_peas",proc_raw="chick_peas",proc_in="chickpea_flourin",proc_out="chickpea_flour",value=0.72,dietary_products="Pulses, Other and products")%>%
add_row(crop_cifos="chick_peas",proc_raw="chick_peas",proc_in="chickpea_flourin",proc_out="chickpea_bran",value=0.23,dietary_products="Pulses, Other and products")%>%
# Beans dry
# Levels: all pulses only one level
add_row(crop_cifos="beans_dry",proc_raw="beans_dry",proc_in="beans_dry_vegetable",proc_out="beans_dry_vegetable",value=0.95,dietary_products="Pulses, Other and products")%>%
add_row(crop_cifos="beans_dry",proc_raw="beans_dry",proc_in="beans_dry_flourin",proc_out="beans_dry_flour",value=0.72,dietary_products="Pulses, Other and products")%>%
add_row(crop_cifos="beans_dry",proc_raw="beans_dry",proc_in="beans_dry_flourin",proc_out="beans_dry_bran",value=0.23,dietary_products="Pulses, Other and products")%>%
# Other pulses
# Levels: all pulses only one level
add_row(crop_cifos="other_pulses",proc_raw="other_pulses",proc_in="other_pulses_vegetable",proc_out="other_pulses_vegetable",value=0.95,dietary_products="Pulses, Other and products")%>%
add_row(crop_cifos="other_pulses",proc_raw="other_pulses",proc_in="other_pulses_flourin",proc_out="other_pulses_flour",value=0.72,dietary_products="Pulses, Other and products")%>%
add_row(crop_cifos="other_pulses",proc_raw="other_pulses",proc_in="other_pulses_flourin",proc_out="other_pulses_bran",value=0.23,dietary_products="Pulses, Other and products")%>%
# lentils
# Levels: all pulses only one level
add_row(crop_cifos="lentils",proc_raw="lentils",proc_in="lentils_vegetable",proc_out="lentils_vegetable",value=0.95,dietary_products="Pulses, Other and products")%>%
add_row(crop_cifos="lentils",proc_raw="lentils",proc_in="lentils_flourin",proc_out="lentils_flour",value=0.72,dietary_products="Pulses, Other and products")%>%
add_row(crop_cifos="lentils",proc_raw="lentils",proc_in="lentils_flourin",proc_out="lentils_bran",value=0.23,dietary_products="Pulses, Other and products")%>%
# pigeon_peas
# Levels: all pulses only one level
add_row(crop_cifos="pigeon_peas",proc_raw="pigeon_peas",proc_in="pigeon_peas_vegetable",proc_out="pigeon_peas_vegetable",value=0.95,dietary_products="Pulses, Other and products")%>%
add_row(crop_cifos="pigeon_peas",proc_raw="pigeon_peas",proc_in="pigeon_peas_flourin",proc_out="pigeon_peas_flour",value=0.72,dietary_products="Pulses, Other and products")%>%
add_row(crop_cifos="pigeon_peas",proc_raw="pigeon_peas",proc_in="pigeon_peas_flourin",proc_out="pigeon_peas_bran",value=0.23,dietary_products="Pulses, Other and products")%>%
# cow_peas_dry
# Levels: all pulses only one level
add_row(crop_cifos="cow_peas_dry",proc_raw="cow_peas_dry",proc_in="cow_peas_dry_vegetable",proc_out="cow_peas_dry_vegetable",value=0.95,dietary_products="Pulses, Other and products")%>%
add_row(crop_cifos="cow_peas_dry",proc_raw="cow_peas_dry",proc_in="cow_peas_dry_flourin",proc_out="cow_peas_dry_flour",value=0.72,dietary_products="Pulses, Other and products")%>%
add_row(crop_cifos="cow_peas_dry",proc_raw="cow_peas_dry",proc_in="cow_peas_dry_flourin",proc_out="cow_peas_dry_bran",value=0.23,dietary_products="Pulses, Other and products")%>%
add_row(crop_cifos="other_oil_crops",proc_raw="olives",proc_in="olive_oilin",proc_out="olive_oil",value=0.25,dietary_products="Olive Oil")%>%#virgine and residue oil mixed! Therfore 5% more oil
# temperate_fruit - assumption: Whole fruit is used and no losses occur
add_row(crop_cifos="temperate_fruit",proc_raw="temperate_fruit",proc_in="temperate_fruit_whole",proc_out="temperate_fruit_whole",value=mean(c(0.5,0.35,0.29,0.25)),dietary_products="Apples and products")%>%#tcf fao, fractions from apples, plums, apricots, raisins
add_row(crop_cifos="temperate_fruit",proc_raw="temperate_fruit",proc_in="temperate_fruit_juice",proc_out="temperate_fruit_juice",value=mean(c(0.22,0.75)),dietary_products="Apples and products")%>%#tcf fao, taken from apple, raisins
add_row(crop_cifos="temperate_fruit",proc_raw="temperate_fruit",proc_in="temperate_fruit_juice",proc_out="temperate_fruit_pulp",value=mean(c(0.4)),dietary_products="Apples and products")%>%#not in fao. taken from apple
# tropical_fruits - assumption: Whole fruit is used and no losses occur
add_row(crop_cifos="tropical_fruits",proc_raw="tropical_fruits",proc_in="tropical_fruits_juice",proc_out="tropical_fruits_juice",value=mean(c(0.1,0.1,0.2)),dietary_products="Oranges, Mandarines")%>%#tcf fao, mean of oranges, mango, pineapple
add_row(crop_cifos="tropical_fruits",proc_raw="tropical_fruits",proc_in="tropical_fruits_juice",proc_out="tropical_fruits_pulp",value=mean(c(0.4,0.55)),dietary_products="Oranges, Mandarines")%>%#tcf fao, mean of oranges, mango
add_row(crop_cifos="maize",proc_raw="maize_flour",proc_in="maize_flourin",proc_out="maize_flour",value=0.82,dietary_products="Maize and products")%>%
add_row(crop_cifos="maize",proc_raw="maize_flour",proc_in="maize_flourin",proc_out="maize_bran",value=0.11,dietary_products="Maize and products")%>%#for feed
add_row(crop_cifos="maize",proc_raw="maize_flour",proc_in="maize_flourin",proc_out="maize_germ",value=0.06,dietary_products="Maize and products")%>%
add_row(crop_cifos="maize",proc_raw="maize_germ",proc_in="maize_oilin",proc_out="maize_cake",value=0.52,dietary_products="Maize and products")%>%
## grass_arable - Prefereably this should represent a grass type like lollium ssp.
add_row(crop_cifos="grass_arable",proc_raw="grass_arable",proc_in="grass_arable_dry",proc_out="grass_arable_hay",value=0.88,dietary_products="Roughage")%>%# Timothy (Phleum pratense), hay (feedepedia)
add_row(crop_cifos="grass_arable",proc_raw="grass_arable",proc_in="grass_arable_fresh",proc_out="grass_arable_fresh",value=(1-0.86),dietary_products="Forage and silage, grasses nes")%>%# Source: https://doi.org/10.1111/j.1469-8137.1994.tb04036.x - I take the upper bound
add_row(crop_cifos="grass_pasture",proc_raw="grass_pasture",proc_in="grass_pasture_dry",proc_out="grass_pasture_hay",value=0.88,dietary_products="Roughage")%>%#Timothy (Phleum pratense), hay (feedepedia)
add_row(crop_cifos="grass_rangeland",proc_raw="grass_rangeland",proc_in="grass_rangeland_fresh",proc_out="grass_rangeland_fresh",value=0.30,dietary_products="Forage and silage, grasses nes")%>%# Source: https://doi.org/10.1111/j.1469-8137.1994.tb04036.x - I take the lower bound
# According to FAO this might relate to fast growing grass which is covered by grass already -- https://www.fao.org/es/faodef/fdef11e.htm -- RYE GRASS FOR FORAGE Italian ryegrass (Lolium multiflorum); English, perennial ryegrass (L. perenne) (feedepedia)
add_row(crop_cifos="ryefor",proc_raw="ryefor",proc_in="ryefor_dryin",proc_out="ryefor_hay",value=0.92,dietary_products="Forage and silage, legumes")%>%# Reference: Feedipedia: Rye straw (feedepedia)
add_row(crop_cifos="ryefor",proc_raw="ryefor",proc_in="ryefor_silage",proc_out="ryefor_silage",value=0.277,dietary_products="Forage and silage, legumes")%>%# #Red clover (Trifolium pratense), silage (feedepedia)
# fornesfor
add_row(crop_cifos="fornesfor",proc_raw="fornesfor_feed",proc_in="fornesfor_feedin",proc_out="fornesfor_plant",value=0.65,dietary_products="Forage products")%>%#comes from cabbage
# legumenesfor - Source: https://www.feedipedia.org/node/4926 --> Faba Bean taken as a proxy
# Levels: all pulses only one level
add_row(crop_cifos="legumenesfor",proc_raw="legumenesfor_feed",proc_in="legumenesfor_feedin",proc_out="legumenesfor_bean",value=0.866,dietary_products="Forage and silage, legumes")%>%# Faba bean (Vicia faba), all cultivars
# maizefor - https://www.feedipedia.org/node/13883 AND commodity tree FAO
add_row(crop_cifos="maizefor",proc_raw="maize_whole_feed",proc_in="maize_silagein",proc_out="maize_silage",value=0.325,dietary_products="Forage products")%>%# Reference: Maize silage, dry matter 30-35% from https://www.feedipedia.org/node/12871
add_row(crop_cifos="maizefor",proc_raw="maize_whole_feed",proc_in="maize_oilin",proc_out="maize_oil",value=0.45*0.06,dietary_products="Forage products")%>%# Reference: Commodidty tree fao same as with humans
add_row(crop_cifos="maizefor",proc_raw="maize_whole_feed",proc_in="maize_oil",proc_out="maize_cake",value=0.52*0.06,dietary_products="Forage products")%>%# Reference: Commodidty tree fao same as with humans
# oilseedfor - from Commodity tree (Soyabeans taken as a proxy)
# Here I change the existing processing products that are not according to FAO tcf document
# Barley from fao tcf document
add_row(crop_cifos="barley",proc_raw="barley",proc_in="barley_for_pearlin",proc_out="barley_pearl",value=0.72*0.55,dietary_products="Barley and products")%>%#
add_row(crop_cifos="barley",proc_raw="barley",proc_in="barley_for_pearlin",proc_out="barley_flour",value=0.72*.45,dietary_products="Barley and products")%>%#
add_row(crop_cifos="barley",proc_raw="barley",proc_in="barley_for_pearlin",proc_out="barley_bran",value=0.19,dietary_products="Barley and products")%>%#
add_row(crop_cifos="barley",proc_raw="barley",proc_in="barley_for_pearlin",proc_out="barley_hulls",value=0.07,dietary_products="Barley and products")%>%#
add_row(crop_cifos="barley",proc_raw="barley_malt",proc_in="for_beer",proc_out="barley_beer",value=8*0.8,dietary_products="Barley and products")%>%#
# Barley for feed
add_row(crop_cifos="barley",proc_raw="barley_malt",proc_in="barley_feed",proc_out="grain_barley",value=0.98,dietary_products="Barley and products")%>%#
#Wheat- tcf table
add_row(crop_cifos="wheat",proc_raw="wheat",proc_in="wheat_for_wholemeal",proc_out="wheat_wholemeal",value=0.85,dietary_products="Wheat and products")%>%
add_row(crop_cifos="wheat",proc_raw="wheat",proc_in="wheat_for_wholemeal",proc_out="wheat_wholemeal_germ",value=0.01,dietary_products="Wheat and products")%>%
add_row(crop_cifos="wheat",proc_raw="wheat",proc_in="wheat_for_wholemeal",proc_out="wheat_feedmeal",value=0.02,dietary_products="Wheat and products")%>%#
add_row(crop_cifos="wheat",proc_raw="wheat",proc_in="wheat_flour",proc_out="wheat_germ",value=0.02,dietary_products="Wheat and products")%>%#ref: slightly adjusted from tcf FAO so that it adds up to 88% DM
add_row(crop_cifos="wheat",proc_raw="wheat",proc_in="wheat_flour",proc_out="wheat_flour",value=0.75,dietary_products="Wheat and products")%>%
add_row(crop_cifos="wheat",proc_raw="wheat",proc_in="wheat_flour",proc_out="wheat_branh",value=0.11,dietary_products="Wheat and products")%>%
add_row(crop_cifos="wheat",proc_raw="wheat",proc_in="wheat_feed",proc_out="grain_wheat",value=0.88,dietary_products="Wheat and products")%>%#wheat harvested ca 12 %DM
add_row(crop_cifos="wheat",proc_raw="wheat",proc_in="wheat_flourba",proc_out="wheat_flour",value=0.73,dietary_products="Wheat and products")%>%
add_row(crop_cifos="wheat",proc_raw="wheat",proc_in="wheat_flourba",proc_out="wheat_feedmeal",value=0.02,dietary_products="Wheat and products")%>%
add_row(crop_cifos="wheat",proc_raw="wheat",proc_in="wheat_flourba",proc_out="wheat_brana",value=0.12,dietary_products="Wheat and products")%>%#
# Rapeseed- tcf table
add_row(crop_cifos="rapeseed",proc_raw="rapeseed",proc_in="rapeseed_oil",proc_out="rapeseed_oil",value=0.38,dietary_products="Rape and Mustard Oil")%>%
add_row(crop_cifos="rapeseed",proc_raw="rapeseed",proc_in="rapeseed_oil",proc_out="rapeseed_cake",value=0.6,dietary_products="Rape and Mustardseed")%>%
# potatoes - tcf table
add_row(crop_cifos="potatoes",proc_raw="potatoes",proc_in="potatoes_whole",proc_out="potatoes_dry",value=0.17,dietary_products="Potatoes and products")%>%
add_row(crop_cifos="potatoes",proc_raw="potatoes",proc_in="potatoes_whole",proc_out="tuber_peel",value=0.02,dietary_products="Potatoes and products")%>%
add_row(crop_cifos="potatoes",proc_raw="potatoes",proc_in="potatoes_flour",proc_out="potatoes_flour",value=0.2,dietary_products="Potatoes and products")%>%
add_row(crop_cifos="potatoes",proc_raw="potatoes",proc_in="potatoes_flour",proc_out="tuber_peel",value=0.02,dietary_products="Potatoes and products")%>%
add_row(crop_cifos="potatoes",proc_raw="potatoes",proc_in="potatoes_starch",proc_out="potatoes_starch",value=0.19,dietary_products="Potatoes and products")%>%
add_row(crop_cifos="potatoes",proc_raw="potatoes",proc_in="potatoes_starch",proc_out="tuber_peel",value=0.02,dietary_products="Potatoes and products")%>%
add_row(crop_cifos="arabica_coffee",proc_raw="coffee_green",proc_in="coffee_green",proc_out="coffee_roasted",value=0.8,dietary_products="Coffee and products")%>%
add_row(crop_cifos="arabica_coffee",proc_raw="coffee_green",proc_in="coffee_green",proc_out="coffee_hulls",value=0.2,dietary_products="Cocoa Beans and products")%>%#fraction comes from the cocoa husk. Could be improbved
# Sesame
add_row(crop_cifos="sesame",proc_raw="sesame",proc_in="sesame_seed",proc_out="sesame_oil",value=0.42,dietary_products="Sesameseed Oil")%>%#ref from old processing sheet
add_row(crop_cifos="bananas",proc_raw="bananas",proc_in="bananas",proc_out="bananas",value=1,dietary_products="Bananas")%>%#ref from old processing sheet
dat_procout_to_find_demi=dat_procout_all%>%dplyr::filter(is.na(original_id))%>%# this needs to be checked for in the old human nutrition sheet
write_csv("Input_data/humNutr_demitofind.csv")
# Manual Mapping Human Nutrition ------------------------------------------
# Careful -- Manual mapping -- Which procout is in the old human nutrition sheet that was not detected by the join above. Also mapping for non-human food procouts
# function that subsets the cvb data sheets based on the row headers (caution: indexed subsetting did not work due to differences in rownumbers between sheets)
# # in processing sheet > remove everything that is not used in the model. All products can have a max of three functions(animal feed, human food, fertilizer)
# 2. FAO_crops > Proc_Raw (processing_sheet(ProcRaw matched with crops --> Only put in crops that get a value >> delete them))
# 3. Proc_raw > ProcIn (supply_sheets FAO)
# 4. ProcIn > ProcOut
# 5. ProcOutc > Dietary_product (group of the FAO >> that is matched to Food groups (Fruits, vegetables, fibres,...))
# # each Proc_out have to have a or many functions (feed, fertilizer, etc.)