#' Read in GDX and calculate emissions, used in convGDX2MIF.R for the reporting
#'
#' Create fictitious variables to ensure symetry of the magpie object, information used in convGDX2MIF.R
#' for the reporting
#'
#'
#' @param gdx a GDX object as created by readGDX, or the path to a gdx
#' @param output a magpie object containing all needed variables generated by other report*.R functions
#' @return MAgPIE object - contains the emission variables
#' @author Sebastian Osorio, Renato Rodrigues
#' @seealso \code{\link{convGDX2MIF}}
#' @examples
#'
#' \dontrun{reportFictitiousVars(gdx)}
#'
#' @importFrom gdx readGDX
#' @importFrom magclass mbind setNames dimSums getSets getSets<- as.magpie getItems
#' @export
#'
reportFictitiousVars <- function(gdx,output=NULL) {
if(is.null(output)){
stop("please provide a file containing all needed information")
}
# read sets and parameters
AggVarPath <- system.file("extdata","AggregateVariables.csv",package="limes")
# reading mapping file
AggVarfile <- read.csv(AggVarPath,sep=";")
# write the *.mif or give back the magpie opject output
AggVars <- paste0(as.vector(AggVarfile$LIMES)," (",as.vector(AggVarfile$UnitLIMES) , ")")
#Depending on the configuration, some variables might have national values and thus should be extracted from the fictitious variables
AggVars <- setdiff(AggVars,getNames(output))
#Generate matrix with NA for all fictitious variables
o_fictitious <- new.magpie(cells_and_regions = getItems(output, dim = 1), years = getYears(output), names = AggVars,
fill = NA, sort = FALSE, sets = NULL)
tmp <- o_fictitious
return(tmp)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.