Commit c8e21941 authored by Simon, Wolfram's avatar Simon, Wolfram
Browse files

worked on procssing, human nutrition sheet.

parent 69cadd1e
......@@ -906,18 +906,21 @@ dat_map_processing = dat_proc_asf %>% dplyr::select(proc_out) %>%
# Comparing different processing sheets ----------------------------------
dat_proc_rec = read_excel("D:/GAMS/EU_model_Feb2022/European_CiFoS_model_data.xlsx", sheet = "Processing_Fraction" )
# dat_proc_rec = read_excel("D:/GAMS/EU_model_Feb2022/European_CiFoS_model_data.xlsx", sheet = "Processing_Fraction" )
dat_proc_comp = Processing_sheet_final %>% left_join(dat_proc_rec %>% select(proc_out, Utilization), by="proc_out") %>%
mutate(Utilization = case_when(proc_out == "barleyfor" ~ "FeedOnly",
proc_out == "wheatfor" ~ "FeedOnly",
TRUE ~ Utilization)) %>%
dplyr::select(-dietary_products) %>% clean_names()
write_csv(dat_proc_comp, "Input_data/processing_sheet_17_02_22.csv")
# dat_proc_comp = Processing_sheet_final %>% left_join(dat_proc_rec %>% select(proc_out, Utilization), by="proc_out") %>%
# mutate(Utilization = case_when(proc_out == "barleyfor" ~ "FeedOnly",
# proc_out == "wheatfor" ~ "FeedOnly",
# TRUE ~ Utilization)) %>%
# dplyr::select(-dietary_products) %>% clean_names()
#
# write_csv(dat_proc_comp, "Input_data/processing_sheet_17_02_22.csv")
# Removing duplicates 22.2.22 ----------------------------------------------------
dat_proc_dup = read_excel("D:/GAMS/EU_model_Feb2022/European_CiFoS_model_data.xlsx", sheet = "Processing_Fraction" )
dat_proc_dup %>% distinct() %>% write_csv("Input_data/processing_sheet_no_dup.csv")
# Human nutrition sheet ---------------------------------------------------
# Human nutrtion sheet
dat_humnutr = read_excel("Input_data/Copy of European_CiFoS_model_data_ANITANov21.xlsx", sheet = "Human_Nutr")
......@@ -1108,6 +1111,26 @@ hum_nutr_all_FG = hum_nutr_all %>% dplyr::select(-FoodGroup) %>%
# check = full_join(hum_nutr_all, proc_new, by = c("product"="proc_out"))
write_csv(hum_nutr_all_FG, "Input_data/hum_nutr_all.csv")
# Comparing versions - Demi NAs filling --------------------------------------
hum_food_22.2.22 = read_xlsx('Input_data/Human_Food_Demi_22.2.22.xlsx', sheet = "Sheet1")
hum_food_latest = read_excel("D:/GAMS/EU_model_Feb2022/European_CiFoS_model_data.xlsx", sheet = "Human_Food_Nutr" )
# Consistency checks - Are the same products in both of the sheets
# - Number of rows are identical 139
# # both sheets have the same products. Sheet can be directly replaced by demis sheet!
hum_food_22.2.22$Product[!hum_food_22.2.22$Product %in% hum_food_latest$Product]
hum_food_latest$Product[!hum_food_latest$Product %in% hum_food_22.2.22$Product]
# Minor transformation and N calclation
hum_food_updated = hum_food_22.2.22 %>% dplyr::select(-USDA_Code) %>%
type.convert() %>%
dplyr::mutate(N = case_when(is.na(N) ~ Protein/6.25,
TRUE ~ N))
write_csv(hum_food_updated, "Input_data/Human_food_update_22_2_22.csv")
# Animal nutrition new ----------------------------------------------------
# Cifos sheet
dat_animnutr = readxl::read_excel("Input_data/Copy of European_CiFoS_model_data_ANITANov21.xlsx", sheet = "Animal_Nutr")
......@@ -1296,7 +1319,6 @@ FunAnimDatExtract = function(dat, cvb_code, cvb_name, product){
# Calculations
#[F.H11] GE (kJ/kg) = 24.14 x CP + 36.57 x CFAT + 20.92 x CF + 16.99 x NFE - 0.63 x SUG*
dplyr::mutate(
ge = case_when(
sug > 80 ~ round((cp*24.14+cfat*36.57+cf*13.81+nfe*16.99-0.63*sug)/1000,1),
sug <= 80 ~ round((cp*24.14+cfat*36.57+cf*13.81+nfe*16.99-0.63)/1000,1)),
......@@ -2002,6 +2024,17 @@ ani_nutr_v7.2.22=animal_nutrition_all_old %>% dplyr::select(c(product)) %>%
write_csv(animal_nutrition_all, "Input_data/animal_nutrition_all.csv")
read_csv("Input_data/animal_nutrition_all.csv")
}
# Update - 22.2.22 -------------------------------------------------------
dat_aninutr_recent = read_excel("D:/GAMS/EU_model_Feb2022/European_CiFoS_model_data.xlsx", sheet = "Animal_Feed_Nutr" )
dat_aninutr_updated = dat_aninutr_recent %>% dplyr::select(-Origin) %>%
distinct(Product, .keep_all = T)
write_csv(dat_aninutr_updated, "Input_data/dat_ani_nutr_update_22_2_22.csv")
# Loss fraction sheet ----------------------------------------------------
dat_lossfrac = read_excel("Input_data/Copy of European_CiFoS_model_data_ANITANov21.xlsx", sheet = "Loss_Fraction_New")
dat_lossfrac_join= dat_lossfrac %>% dplyr::select(c(1:10)) %>% janitor::row_to_names(1)%>% select(-ProdCat ,-Fam_SPAM) %>%
......@@ -2614,6 +2647,15 @@ CropFert =
write_csv(CropFert, "Input_data/cropfert_inter.csv")
# Fert_Nutr ---------------------------------------------------------------
# Sheet contains the products (procraw and procout) with NPK values on DM basis
proc_recent = read_excel("D:/GAMS/EU_model_Feb2022/European_CiFoS_model_data.xlsx", sheet = "Processing" )
dat_aninutr_updated = dat_aninutr_recent %>% dplyr::select(-Origin) %>%
distinct(Product, .keep_all = T)
write_csv(dat_aninutr_updated, "Input_data/dat_ani_nutr_update_22_2_22.csv")
# Data maps ---------------------------------------------------------------
# Anitas excel -- differs a bit to mine
data_map = read_excel("Input_data/Copy of European_CiFoS_model_data_ANITANov21.xlsx", sheet = "Data_Map")
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment