Package 'm4fsdp'

Title: MAgPIE outputs R package for MAgPIE version 4.x to create outputs for FSDP project
Description: Output routines for extracting results from the MAgPIE framework (versions 4.x) for the FSDP project.
Authors: Benjamin Leon Bodirsky [aut, cre], David Chen [aut], Michael Crawford [aut], Debbora Leip [aut], Patrick von Jeetze [aut], Felicitas Beier [aut], Edna Molina Bacca [aut], Jan Philipp Dietrich [aut], Florian Humpenoeder [aut]
Maintainer: Benjamin Leon Bodirsky <[email protected]>
License: LGPL-3 | file LICENSE
Version: 0.58.3
Built: 2024-11-25 16:27:22 UTC
Source: https://github.com/pik-piam/m4fsdp

Help Index


m4fsdp: MAgPIE outputs R package for MAgPIE version 4.x to create outputs for FSDP project

Description

Output routines for extracting results from the MAgPIE framework (versions 4.x) for the FSDP project.

Author(s)

Maintainer: Benjamin Leon Bodirsky [email protected]

Authors:

See Also

Useful links:


appendReportHealthImpacts

Description

Reads in the results from Marco Springmann's health impacts model, filters them down to the FSEC-relevant variables, and saves them to the selected scenarios' report.mif.

Usage

appendReportHealthImpacts(gdx, scenario, dir = ".")

Arguments

gdx

full pathname of the health impacts dataset

scenario

name of the scenario

dir

scenario output directory

Author(s)

Michael Crawford


appendReportMAGICC7

Description

Reads in the results from the MAGICC7 AR6 probabilistic scenarios

Usage

appendReportMAGICC7(resultsPath, scenario, dir = ".")

Arguments

resultsPath

full file path of the excel with the for MAGICC7 results

scenario

name of the scenario

dir

scenario output directory

Author(s)

Michael Crawford


validationFSDP

Description

Validation for FSDP MAgPIE runs written by openAI chatbot. The command was: "Please write a function in R. It should receive a vector of scenario_names. In the function, there is a mapping that assigns each element of potential_names to an individual color. The function checks which elements of scenario_names are in potential_names and returns the respective colors as a vector of colors.

Usage

assignScenarioColors(scenario_names)

Arguments

scenario_names

scenario names to be checked for their colorcode.

Author(s)

openAI, Benjamin Bodirsky


assignScenarioLinetype

Description

Line Type for FSDP MAgPIE runs

Usage

assignScenarioLinetype(scenario_names)

Arguments

scenario_names

scenario names to be checked for their colorcode.

Author(s)

Florian Humpenoeder


bundlesFSDP

Description

FDSP plot with single measure and bundles

Usage

bundlesFSDP(repReg, regionSel = "GLO", file = NULL)

Arguments

repReg

rds file or data.frame with all MAgPIE runs, produced with FSDP_collect.R output script.

regionSel

Region that should be plotted

file

file name (e.g. BundleFSDP.pdf or BundleFSDP.jpg) or NULL

Details

plot with single measure and bundles

Value

depends on file argument. If file==NULL, the default, the plot is returned. If a filename is provided the plot is saved as file

Author(s)

Florian Humpenoeder


convertReportFSDP

Description

reads in FSDP reporting file

Usage

convertReportFSDP(rep, scengroup = NULL, subset = FALSE, varlist = NULL)

Arguments

rep

reporting .rds file (produced by FDSP_collect.R output script)

scengroup

options: FSECa, FSECb, FSECc, FSECd

subset

TRUE returns "BAU 2020","BAU 2050","FSDP 2050". FALSE returns all scenarios. "FSTssp2_minus_BASEssp2" or "FSTsdp_minus_BASEssp2" returns the allFSM or FSDP scenario minus the BAU scenario in 2050.

varlist

file name for plain text variable list (e.g. "var_names.csv")

Details

blub

Value

if file is NULL a ggplot2 object will be return

Author(s)

Florian Humpenoeder


dashboardFSDP

Description

FDSP dashboard

Usage

dashboardFSDP(
  repReg,
  repIso,
  repGrid,
  regionSel = "GLO",
  outputDir = "",
  file = "dashboardFSDP.html"
)

Arguments

repReg

rds file or data.frame with regional data from all MAgPIE runs, produced with FSDP_collect.R output script.

repIso

rds file or data.frame with country-level data from all MAgPIE runs, produced with FSDP_collect.R output script.

repGrid

rds file or data.frame with gridded data from all MAgPIE runs, produced with FSDP_collect.R output script.

regionSel

Region that should be plotted

outputDir

output directory

file

file name

Details

FDSP dashboard

Value

html file

Author(s)

Florian Humpenoeder


getScenarios

Description

Scenarios for FSDP plotting

Usage

getScenarios(tableType = NULL, oldformat = FALSE)

Arguments

tableType

select the scenarios based on csv file figureTableType.csv in inst/extdata folder. NULL (default) returns scenario names.

oldformat

return in format modelrun::bundle|scenarioname

Details

includes scenarios and their grouping into bundles

Value

named vector

Author(s)

Benjamin Bodirsky


getVariables

Description

Variables for FSDP plotting

Usage

getVariables(reportVariables = NULL)

Arguments

reportVariables

Variables in report file

Details

includes information about unit, variable group, rounding etc

Value

named vector

Author(s)

Florian Humpenoeder


heatmapFSDP

Description

creates a heatmap for FSDP MAgPIE runs

Usage

heatmapFSDP(
  repReg,
  regionSel = "GLO",
  tableType = 1,
  file = NULL,
  width = 10.5,
  height = 9
)

Arguments

repReg

rds file or data.frame with all MAgPIE runs, produced with FSDP_collect.R output script.

regionSel

Region that should be plotted. select "IND" for India plots

tableType

options: 1, 2, 3

file

file name (e.g. FSDP_heatmap.pdf or FSDP_heatmap.jpg) or NULL

width

width

height

height

Details

blub

Value

if file is NULL a ggplot2 object will be return

Author(s)

Florian Humpenoeder, Vartika Singh


lineplotFSDP

Description

Line plots FSDP

Usage

lineplotFSDP(repReg, val, regionSel = "GLO", file = NULL, scens = "bundles")

Arguments

repReg

rds file or data.frame with all MAgPIE runs, produced with FSDP_collect.R output script.

val

rds file or data.frame with validation data

regionSel

Region that should be plotted (e.g. c("IND","EUR","GLO")). Aggregate will return LIR, MIR and HIR.

file

file name

scens

if "BAU_FSEC", BAU and FSEC scenarios are plotted, with "central" plots the core scenarios, "extended" plot the core scenarios and all ssps.

Details

creates validation for FSDP MAgPIE runs

Author(s)

Florian Humpenoeder


lineplotFSDPIndia

Description

Line plots FSDP

Usage

lineplotFSDPIndia(
  repReg,
  val,
  regionSel = "IND",
  file = NULL,
  scens = "bundles"
)

Arguments

repReg

rds file or data.frame with all MAgPIE runs, produced with FSDP_collect.R output script.

val

rds file or data.frame with validation data

regionSel

Region that should be plotted (e.g. c("IND","EUR","GLO")). Aggregate will return LIR, MIR and HIR.

file

file name

scens

if "BAU_FSEC", BAU and FSEC scenarios are plotted, with "central" plots the core scenarios, "extended" plot the core scenarios and all ssps.

Details

creates validation for FSDP MAgPIE runs

Author(s)

Florian Humpenoeder


milestoneTable

Description

Creates csv with values for SI table on milestones

Usage

milestoneTable(scenarioFolder, outFolder = NULL, file = NULL)

Arguments

scenarioFolder

outputfolder of a specific MAgPIE run (should be an FSECe_FSDP run for SI table)

outFolder

main outputfolder, where output csv will be saved

file

name to save table as csv


plotFSDP

Description

Creates all FSDP plots

Usage

plotFSDP(
  outputfolder = "output",
  reg = NULL,
  iso = NULL,
  grid = NULL,
  val = NULL,
  reg2iso = NULL,
  rev = NULL,
  dirFsdp = NULL
)

Arguments

outputfolder

output folder

reg

rds file or data.frame with all MAgPIE runs, produced with FSDP_collect.R output script. NULL will automatically detect the most recent version.

iso

rds file or data.frame with all MAgPIE runs, produced with FSDP_collect.R output script. NULL will automatically detect the most recent version.

grid

rds file or data.frame with all MAgPIE runs, produced with FSDP_collect.R output script. NULL will automatically detect the most recent version.#' @details uses the most recent vXX_reg/grid/iso.rds files in the "output" folder by default

val

rds file or data.frame with all MAgPIE runs, produced with FSDP_collect.R output script. NULL will automatically detect the most recent version.#' @return plots in "output" folder

reg2iso

rds file or data.frame with Mapping, produced with FSDP_collect.R output script. NULL will automatically detect the most recent version.#' @author Florian Humpenoeder

rev

revision (e.g. "v28"). NULL will automatically detect the most recent version.

dirFsdp

path to outputfolder of the FSDP run (to create the milestones table). NULL will automatically detect the most recent version


spatialMapsAllFSMDiffmap

Description

creates a spatial diffmap between allFSM scneario and reference

Usage

spatialMapsAllFSMDiffmap(
  repReg,
  repIso,
  repGrid,
  reg2iso,
  file = NULL,
  subset = c("FSTsdp_minus_BASEssp2")
)

Arguments

repReg

reporting .rds file or data.frame with regional results (produced by FDSP_collect.R output script)

repIso

reporting .rds file or data.frame with country level results (produced by FDSP_collect.R output script)

repGrid

reporting .rds file or data.frame with grid level results (produced by FDSP_collect.R output script)

reg2iso

mapping file or data.frame with regions and countries (produced by FDSP_collect.R output script)

file

file name (e.g. FSDP_spatialmaps.pdf or FSDP_spatialmaps.pdf) or NULL

subset

"FSTssp2_minus_BASEssp2" or "FSTsdp_minus_BASEssp2" returns diffmaps for allFSM or FSDP scenario minus the BAU scenario in 2050.

Details

blub

Value

if file is NULL a ggplot2 object will be return

Author(s)

Florian Humpenoeder


spatialMapsFSDP

Description

creates a spatial mapsfor FSDP MAgPIE runs

Usage

spatialMapsFSDP(
  repReg,
  repIso,
  repGrid,
  reg2iso,
  file = NULL,
  recalcPolygons = FALSE
)

Arguments

repReg

reporting .rds file or data.frame with regional results (produced by FDSP_collect.R output script)

repIso

reporting .rds file or data.frame with country level results (produced by FDSP_collect.R output script)

repGrid

reporting .rds file or data.frame with grid level results (produced by FDSP_collect.R output script)

reg2iso

mapping file or data.frame with regions and countries (produced by FDSP_collect.R output script)

file

file name (e.g. FSDP_spatialmaps.pdf or FSDP_spatialmaps.pdf) or NULL

recalcPolygons

recalculate polygons for cartogram projections (FALSE / TRUE)

Details

blub

Value

if file is NULL a ggplot2 object will be return

Author(s)

Florian Humpenoeder


SupplPlotsCropShr

Description

Creates crop share plot

Usage

SupplPlotsCropShr(
  outFolder,
  file = NULL,
  scenarios = c("BAU", "FSDP"),
  plotyears = c("2020", "2050"),
  panel = "row",
  combined = TRUE,
  HR = TRUE
)

Arguments

outFolder

output folder

file

Name of file output

scenarios

scenarios used for plotting

plotyears

years for the plot

panel

plot regions as "row" or as "matrix"

combined

whether regional and global plots should be combined

HR

using high resolution data or low resolution data

Details

blub

Value

Crop share on the y-axis and cropland area in each cluster on the x-axis.

Author(s)

Patrick v. Jeetze, Benjamin Bodirsky


SupplPlotsFSDP

Description

creates supplementary plots for FSDP MAgPIE runs

Usage

SupplPlotsFSDP(
  repReg,
  scenarioType = "manuscript",
  outFolder,
  calorieSupply = TRUE,
  caseRegion = NULL
)

Arguments

repReg

rds file or data.frame with all MAgPIE runs, produced with FSDP_collect.R output script.

scenarioType

options: all, or one of the a-e groupings

outFolder

output folder to save to

calorieSupply

parameter to set if calorie figures needed for calories supply or calorie intake, set FALSE for Intake

caseRegion

set to a particular region (i.e. "IND") if plots are being used for country case studies

Value

if file is NULL a ggplot2 object will be return

Author(s)

David M Chen, Vartika Singh


SupplPlotsLandConsv

Description

Creates land conservation map

Usage

SupplPlotsLandConsv(
  outFolder,
  file = "suppPlotsLandConsv.png",
  gdxFolder = NULL
)

Arguments

outFolder

output folder

file

Name of file output

gdxFolder

Run folder

Details

Produces map of land targeted in the food system measure LandConservation

Value

Map with cell share included in land conservation measure

Author(s)

Patrick v. Jeetze


themeSupplFood

Description

creates supplementary themes for FSDP MAgPIE runs

Usage

themeSupplFood(base_size = 16)

Arguments

base_size

base size of plot


themeSupplFood

Description

creates supplementary themes for FSDP MAgPIE runs

Usage

themeSupplReg(
  base_size = 11,
  base_family = "",
  rotate_x = FALSE,
  panel.spacing = 3
)

Arguments

base_size

plot settings

base_family

plot settings

rotate_x

plot settings

panel.spacing

plot settings


validationFSDP

Description

Validation for FSDP MAgPIE runs

Usage

validationFSDP(
  repReg,
  val,
  regionSel = "aggregate",
  folder = "output",
  scens = "BAU_FSEC",
  showHistLegend = TRUE
)

Arguments

repReg

rds file or data.frame with all MAgPIE runs, produced with FSDP_collect.R output script.

val

rds file or data.frame with validation data

regionSel

Region that should be plotted (e.g. c("IND","EUR","GLO")). Aggregate will return LIR, MIR and HIR.

folder

output folder

scens

if "BAU_FSEC", BAU and FSEC scenarios are plotted, with "central" plots the core scenarios, "extended" plot the core scenarios and all ssps.

showHistLegend

show legend for historic data sets. TRUE / FALSE

Details

creates validation for FSDP MAgPIE runs

Author(s)

Florian Humpenoeder