|
138 | 138 |
|
139 | 139 | # Production of Cropland, Livestock, and Semi natural agroecosystems --------- |
140 | 140 | # Merge items with biomasses |
| 141 | +# @keywords internal |
141 | 142 | .merge_items_biomass <- function(crop_area_npp_ygpit_all, npp_ygpit_csv, |
142 | 143 | codes_coefs) { |
143 | 144 | crop_area_npp_merged <- crop_area_npp_ygpit_all |> |
|
161 | 162 | } |
162 | 163 |
|
163 | 164 | # Crops Production and Residues ---------------------------------------------- |
| 165 | +# @keywords internal |
164 | 166 | .summarise_crops_residues <- function(crop_area_npp_ygpitr_no_fallow) { |
165 | 167 | crop_area_npp_prod_residue <- crop_area_npp_ygpitr_no_fallow |> |
166 | 168 | dplyr::select( |
|
194 | 196 |
|
195 | 197 |
|
196 | 198 | # Combining crops, residues, feed (grass, fallow) production ----------------- |
| 199 | +# @keywords internal |
197 | 200 | .aggregate_grazed_cropland <- function(npp_ygpit_merged, |
198 | 201 | crop_area_npp_prod_residue) { |
199 | 202 | grazed_data <- npp_ygpit_merged |> |
|
256 | 259 | #' |
257 | 260 | #' @return A tibble filtered and transformed with selected columns for |
258 | 261 | #' semi-natural agroecosystems. |
259 | | -#' |
| 262 | +#' @keywords internal |
260 | 263 | .aggregate_seminatural_system <- function(npp_ygpit_merged) { |
261 | 264 | semi_natural_agroecosystems <- npp_ygpit_merged |> |
262 | 265 | dplyr::ungroup() |> |
|
272 | 275 |
|
273 | 276 | #' Livestock Production ------------------------------------------------------- |
274 | 277 | #' @param livestock_prod_ygps A data frame including livestock production data. |
275 | | -#' |
| 278 | +#' @keywords internal |
276 | 279 | .prepare_livestock_production <- function(livestock_prod_ygps) { |
277 | 280 | livestock <- livestock_prod_ygps |> |
278 | 281 | dplyr::select( |
|
290 | 293 | } |
291 | 294 |
|
292 | 295 | # Combine Cropland, Semi_natural_agroecosystems and Livestock ---------------- |
| 296 | +# @keywords internal |
293 | 297 | .combine_production_boxes <- function(crops_residues_grazed, |
294 | 298 | semi_natural_agroecosystems, livestock) { |
295 | 299 | grafs_prod_combined <- dplyr::bind_rows( |
|
313 | 317 | } |
314 | 318 |
|
315 | 319 | # Seed production per province, based on the national seed share per Area ---- |
| 320 | +# @keywords internal |
316 | 321 | .remove_seeds_from_system <- function(crop_area_npp_ygpit_all, |
317 | 322 | pie_full_destinies_fm, |
318 | 323 | grafs_prod_combined) { |
|
367 | 372 | # Structuring dataset (GrazedWeeds und Used_Residues in ProductionFM) -------- |
368 | 373 | # Rename Prod_Residue_Product_Mg to Production_FM and replace Production_FM |
369 | 374 | # with GrazedWeeds_MgDM (for Fallow) |
| 375 | +# @keywords internal |
370 | 376 | .adding_grass_wood <- function(grafs_prod_combined_no_seeds, biomass_coefs) { |
371 | 377 | grafs_prod_structured <- grafs_prod_combined_no_seeds |> |
372 | 378 | dplyr::rename(Production_FM = Prod_Residue_Product_Mg) |> |
|
462 | 468 |
|
463 | 469 | # Processed Items ------------------------------------------------------------ |
464 | 470 | # Summarise processed items by Year, Province, Biomass, Item, and ProcessedItem |
| 471 | +# @keywords internal |
465 | 472 | .prepare_processed_data <- function(processed_prov_fixed) { |
466 | 473 | processed_data <- processed_prov_fixed |> |
467 | 474 | dplyr::group_by(Year, Province_name, Name_biomass, Item, ProcessedItem) |> |
|
480 | 487 | } |
481 | 488 |
|
482 | 489 | # Match structure of grafs_prod_combined_no_seeds ---------------------------- |
| 490 | +# @keywords internal |
483 | 491 | .prepare_prod_data <- function(grafs_prod_added_grass_wood, |
484 | 492 | processed_data, codes_coefs_items_full) { |
485 | 493 | added_grass_wood_prepared <- grafs_prod_added_grass_wood |> |
|
509 | 517 | # Convert Fresh Matter (FM) to Dry Matter (DM) and finally to Nitrogen (N) --- |
510 | 518 | # Define a list of special items that require using the primary biomass name |
511 | 519 | # for selecting conversion coefficients |
| 520 | +# @keywords internal |
512 | 521 | .convert_fm_dm_n <- function(added_grass_wood_merged, |
513 | 522 | biomass_coefs) { |
514 | 523 | special_items <- c( |
|
572 | 581 | # Province_name and Item |
573 | 582 | # Comment!!! Feed from all animals are summed together, also from pets. |
574 | 583 | # Do they have to be assigned to humans? |
| 584 | +# @keywords internal |
575 | 585 | .adding_feed <- function(feed_intake) { |
576 | 586 | feed_intake <- feed_intake |> |
577 | 587 | dplyr::select(Year, Province_name, Item, FM_Mg) |> |
|
584 | 594 | # Popoulation: use column Pop_Mpeop_yg. Calculate the share of population ---- |
585 | 595 | # (population in each province divided through whole population in |
586 | 596 | # Spain to get the share) |
| 597 | +# @keywords internal |
587 | 598 | .calculate_population_share <- function(population_share) { |
588 | 599 | population_share <- population_share |> |
589 | 600 | dplyr::select(Year, Province_name, Pop_Mpeop_yg) |> |
|
600 | 611 |
|
601 | 612 | # Food ----------------------------------------------------------------------- |
602 | 613 | # Sum all Elements for Food and multiply with population share |
| 614 | +# @keywords internal |
603 | 615 | .adding_food <- function(pie_full_destinies_fm, population_share) { |
604 | 616 | total_food <- pie_full_destinies_fm |> |
605 | 617 | dplyr::filter(Destiny == "Food", Element == "Domestic_supply") |> |
|
623 | 635 |
|
624 | 636 | # Other_uses ----------------------------------------------------------------- |
625 | 637 | # Sum all Elements for Other_uses and multiply with population share |
| 638 | +# @keywords internal |
626 | 639 | .adding_other_uses <- function(pie_full_destinies_fm, population_share) { |
627 | 640 | other_uses_with_share <- pie_full_destinies_fm |> |
628 | 641 | dplyr::filter(Destiny == "Other_uses", Element == "Domestic_supply") |> |
|
639 | 652 | } |
640 | 653 |
|
641 | 654 | # Putting all together ------------------------------------------------------- |
| 655 | +# @keywords internal |
642 | 656 | .combine_destinies <- function(grafs_prod_item, feed_intake, food_with_share, |
643 | 657 | other_uses_with_share) { |
644 | 658 | grafs_prod_item_combined <- grafs_prod_item |> |
|
658 | 672 | } |
659 | 673 |
|
660 | 674 | # Converting Item and Name_biomass again and converting FM to DM, and DM to N |
| 675 | +# @keywords internal |
661 | 676 | .convert_to_items_n <- function(grafs_prod_item_combined, |
662 | 677 | codes_coefs_items_full, biomass_coefs) { |
663 | 678 | grafs_prod_item_n <- grafs_prod_item_combined |> |
|
692 | 707 | } |
693 | 708 |
|
694 | 709 | # Calculating Consumption and Trade ------------------------------------------ |
| 710 | +# @keywords internal |
695 | 711 | .calculate_trade <- function(grafs_prod_item_n) { |
696 | 712 | grafs_prod_item_trade <- grafs_prod_item_n |> |
697 | 713 | dplyr::group_by(Year, Province_name, Item, Name_biomass, Box) |> |
|
711 | 727 | } |
712 | 728 |
|
713 | 729 | # Adding missing Boxes for Imports ------------------------------------------- |
| 730 | +# @keywords internal |
714 | 731 | .finalize_prod_destiny <- function(grafs_prod_item_trade, |
715 | 732 | codes_coefs_items_full) { |
716 | 733 | grafs_prod_destiny <- grafs_prod_item_trade |> |
|
0 commit comments