Title: | Reporting package for BRICK |
---|---|
Description: | This package contains BRICK-specific routines to report model results. The main functionality is to generate a mif-file from a given BRICK model run folder. |
Authors: | Robin Hasse [aut, cre] , Ricarda Rosemann [aut] |
Maintainer: | Robin Hasse <[email protected]> |
License: | LGPL-3 |
Version: | 0.7.1 |
Built: | 2024-11-09 05:55:09 UTC |
Source: | https://github.com/pik-piam/reportbrick |
Add carrier dimesion based on heating system technology
.addCarrierDimension(v_stock, hsCarrier)
.addCarrierDimension(v_stock, hsCarrier)
v_stock |
MagPIE object, BRICK variable |
hsCarrier |
data.frame, mapping between heating technology and energy carrier |
MagPIE object with additional carrier dimension
Aggregate
.agg(x, agg, silent = TRUE)
.agg(x, agg, silent = TRUE)
x |
MagPIE object, BRICK object |
agg |
named vector of dimensions to aggregate. |
silent |
logical, suppress warnings and printing of dimension mapping |
aggregated MagPIE objects without sub dimensions in dim 3
All Combinations of dimension elements
.combinations(lst)
.combinations(lst)
lst |
names list of dimension entries |
character vector with all combinations of the dimension elements
each separated by .
Robin Hasse
Compute the deviation to historical data
.computeDeviation(df, dfHist)
.computeDeviation(df, dfHist)
df |
data frame, containing data from calibration run |
dfHist |
data frame, containing historical data |
data frame where the value column contains the deviation from historical data
Compute the sum of construction and renovation flow values
.computeFlowSum(con, ren)
.computeFlowSum(con, ren)
con |
data frame, contains construction flow quantities |
ren |
data frame, contains renovation flow quantities |
data frame with the sum in the value column
Compute the relative deviation to historical data as the relative euclidean distance
.computeRelDev(dfDev, dfHist, tCalib, notInHist = NULL)
.computeRelDev(dfDev, dfHist, tCalib, notInHist = NULL)
dfDev |
data frame, containing deviation between calibration and historical data |
dfHist |
data frame or a list of one or two data frames, containing historical data. The option to pass two data frames is used to combine construction and renovation flows. If two data frames are passed, the first one is assumed to be construction, the second renovation |
tCalib |
numerical/factor, calibration time periods to filter historical data |
notInHist |
character vector, pass columns that historical data should not be grouped by when computing the sum of the squares |
data frame with relative deviation in value column
Compute the sum of the squares in a data frame
.computeSumSq(df, rprt = "")
.computeSumSq(df, rprt = "")
df |
data frame, containing the data to be evaluated |
rprt |
character, column names for which the sum of the squares should be reported separately |
data frame sum of squares as value column
Construct dimension mapping (either aggregation or reporting) with explicit set elements for each dimension
.constructDimMapping(agg, rprt, brickSets, silent)
.constructDimMapping(agg, rprt, brickSets, silent)
agg |
named vector of dimensions to aggregate |
rprt |
named vector of dimensions to report individually |
brickSets |
named list with definition of common set elements |
silent |
logical, suppress warnings and printing of dimension mapping |
nested named list with dimension mapping
Extend dimensions of a data frame by adding NA entries, add variable name
.expandDims(df, varName, allSets)
.expandDims(df, varName, allSets)
df |
data frame to be extended |
varName |
character, variable name to be added |
allSets |
character, sets that need to be included as column names |
data frame
Find inconsistencies in set elements between reporting template and gdx
.findInconsistenSetElements(brickSets, gdx)
.findInconsistenSetElements(brickSets, gdx)
brickSets |
character, BRICK reporting template |
gdx |
file path to a BRICK gdx |
named list of missing and surplus sets elements
Find all tags in name escaped in curly brackets
.findTags(name)
.findTags(name)
name |
character, variable name |
vector of tags in name, NULL if there are none
List any missing elements in any given dimension
.missingElements(x, dimLst)
.missingElements(x, dimLst)
x |
MagPIE object, BRICK object |
dimLst |
named vector, dimension ans names and elements as values |
vector of missing dimension elements in x
Read a symbol from several gdx files and combine in one data frame
.readGdxIter( gdx, symbol, maxIter, asMagpie = TRUE, ttotFilter = NULL, replaceVar = FALSE )
.readGdxIter( gdx, symbol, maxIter, asMagpie = TRUE, ttotFilter = NULL, replaceVar = FALSE )
gdx |
Path to gdx files; all gdx file names are assumed to be numbered and
adhere to the structure: If |
symbol |
Symbol to be read from the gdxes |
maxIter |
Last iteration to be read |
asMagpie |
logical, convert to magpie object? |
ttotFilter |
numeric/factor, time periods to filter for |
replaceVar |
logical, replace column names |
data frame of all results read in
bs
and hs
by bsr
and hsr
Replace column names bs
and hs
by bsr
and hsr
.replaceVarName(df)
.replaceVarName(df)
df |
data frame |
data frame where column names have been replaced
This is a wrapper around magclass::mselect
that also allows the
selection of combinations of multiple dimensions.
.select(x, ...)
.select(x, ...)
x |
MAgPIE object |
... |
entry selection. Combined dimensions have to be seperated with
|
MAgPIE object containing only selected entries
Wrapper around setNames
.setNames(object, nm)
.setNames(object, nm)
object |
MAgPIE object |
nm |
a vector of names current names should be replaced with. If only one data element exists you can also set the name to NULL. |
NULL if object is NULL else object with manipulated names
Split each entry of a character vector and return one unnested character vector.
.split(x, split = "\\.")
.split(x, split = "\\.")
x |
character vector |
split |
character used to split |
character vector with each dimension as an own entry
Robin Hasse
Escape dimension name in curly brackets
.tag(dim)
.tag(dim)
dim |
character dimension name |
character, dimension tag
Read in all information from GDX file that was generated with BRICK and create the *.mif reporting
convGDX2MIF( gdx, tmpl = NULL, file = NULL, scenario = "default", t = NULL, silent = TRUE )
convGDX2MIF( gdx, tmpl = NULL, file = NULL, scenario = "default", t = NULL, silent = TRUE )
gdx |
file path to a BRICK gdx |
tmpl |
character, BRICK reporting template. There has to be a brickSets
mapping named with the same suffix: |
file |
name of the mif file which will be written, if no name is provided a magpie object containing all the reporting information is returned |
scenario |
scenario name that is used in the *.mif reporting |
t |
numeric vector of reporting periods (years) |
silent |
boolean, suppress warnings and printing of dimension mapping |
Robin Hasse
Crop MagPIE object to given periods and fill missing periods
extendPeriods(x, periods, fill = NA)
extendPeriods(x, periods, fill = NA)
x |
MagPIE object |
periods |
numeric vector with target periods |
fill |
value to fill missing period values |
MagPIE object with given periods in temporal dimension
Robin Hasse
Renders the file plotCalibration.Rmd to create the plots for the BRICK calibration
plotBRICKCalib( path = ".", cal = "BRICK_calibration_report.csv", outName = "", scenNames = NULL, savePlots = FALSE )
plotBRICKCalib( path = ".", cal = "BRICK_calibration_report.csv", outName = "", scenNames = NULL, savePlots = FALSE )
path |
(named) character vector, path(s) to output directories. If several paths are given, the names can be used to pass short scenario names. |
cal |
character vector, name(s) of file(s) with calibration reporting results |
outName |
character, string added to the pdf file name and names of additionally saved plots |
scenNames |
character vector, scenario names for different paths.
Needs to be specified if |
savePlots |
logical, whether all plots should additionally be saved as png |
Ricarda Rosemann
This function creates an explicit named list with the elements of all BRICK dimensions and corresponding reporting names.
readBrickSets(tmpl = NULL)
readBrickSets(tmpl = NULL)
tmpl |
character, BRICK reporting template |
named list with definition of common set elements
Robin Hasse
Read symbol from gams container
readGdxSymbol( gdx, symbol, field = "level", asMagpie = TRUE, stringAsFactor = TRUE )
readGdxSymbol( gdx, symbol, field = "level", asMagpie = TRUE, stringAsFactor = TRUE )
gdx |
character, file path to GDX file |
symbol |
character, name of gams object |
field |
character, field to read (only relevant for variables) |
asMagpie |
boolean, return Magpie object |
stringAsFactor |
logical, keep default factors from gams |
MagPIE object with data of symbol
Robin Hasse
Report aggregated quantities
reportAgg( x, name, brickSets = readBrickSets(NULL), agg = NULL, rprt = NULL, silent = TRUE )
reportAgg( x, name, brickSets = readBrickSets(NULL), agg = NULL, rprt = NULL, silent = TRUE )
x |
MagPIE object, BRICK object |
name |
character, name of reporting variable. reported dimensions passed
with |
brickSets |
named list, BRICK reporting template |
agg |
named vector of dimensions to aggregate. Names are dimension names
of |
rprt |
named vector of dimensions to report individually. Names are
dimension names of |
silent |
boolean, suppress warnings and printing of dimension mapping |
To consider specific combinations of dimensions in both agg
or
rprt
, the combination can be given just like one dimension
separated by .
.
Robin Hasse
Report quantities describing the stock of buildings
reportBuildingStock(gdx, brickSets = NULL, silent = TRUE)
reportBuildingStock(gdx, brickSets = NULL, silent = TRUE)
gdx |
gams transfer container of the BRICK GDX |
brickSets |
character, BRICK reporting template |
silent |
boolean, suppress warnings and printing of dimension mapping |
Robin Hasse
Read in model results from calibration for each iteration, calculate deviation
reportCalibration(gdx)
reportCalibration(gdx)
gdx |
path to a gdx; it is assumed that for each iteration a gdx is present with this path and the iteration number inserted at the end. |
Ricarda Rosemann
Report quantities describing the construction of new buildings
reportConstruction(gdx, brickSets = NULL, silent = TRUE)
reportConstruction(gdx, brickSets = NULL, silent = TRUE)
gdx |
gams transfer container of the BRICK GDX |
brickSets |
character, BRICK reporting template |
silent |
boolean, suppress warnings and printing of dimension mapping |
Robin Hasse
Report quantities describing the demolition of buildings
reportDemolition(gdx, brickSets = NULL, silent = TRUE)
reportDemolition(gdx, brickSets = NULL, silent = TRUE)
gdx |
gams transfer container of the BRICK GDX |
brickSets |
character, BRICK reporting template |
silent |
boolean, suppress warnings and printing of dimension mapping |
Robin Hasse
Report final and useful energy demand for space heating
reportEnergy(gdx, brickSets = NULL, silent = TRUE)
reportEnergy(gdx, brickSets = NULL, silent = TRUE)
gdx |
gams transfer container of the BRICK GDX |
brickSets |
character, BRICK reporting template |
silent |
boolean, suppress warnings and printing of dimension mapping |
Robin Hasse
Report quantities describing the renovation of new buildings
reportRenovation(gdx, brickSets = NULL, silent = TRUE)
reportRenovation(gdx, brickSets = NULL, silent = TRUE)
gdx |
gams transfer container of the BRICK GDX |
brickSets |
character, BRICK reporting template |
silent |
boolean, suppress warnings and printing of dimension mapping |
Ricarda Rosemann