Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Calibration reporting and plotting #4

Merged
merged 9 commits into from
May 28, 2024

Conversation

ricardarosemann
Copy link
Contributor

This pull request includes a reporting function for the calibration and a corresponding plotting routine.

The function reportCalibration reports relevant quantities from the Brick calibration by doing the following:

  • Read quantities of interest from gdx files of each iteration
  • Compute deviations from historic values for stock and flow variables
  • Aggregate the computed deviations and potentially other quantities
  • Write all results to one csv-file.

The plotting routine consists of the function plotBRICKCalib and the R markdown plotsCalibration.Rmd.

  • The function plotBRICKCalib assembles the paths to the files to be read in (usually output of reportCalibration) and renders the markdown file
  • In the markdown file, the data is read in and several plots are created.
  • Currently, the procedure still contains the option to save all plots as png files; this will potentially be removed in the future.
  • The plotting routine can either evaluate a single calibration run or compare several runs.

Copy link
Collaborator

@robinhasse robinhasse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, Ricarda. Looks good to me. Just some minor in-line suggestions.

R/plotBRICKcalib.R Outdated Show resolved Hide resolved
R/plotBRICKcalib.R Outdated Show resolved Hide resolved
R/plotBRICKcalib.R Show resolved Hide resolved
DESCRIPTION Outdated Show resolved Hide resolved
R/reportCalibration.R Outdated Show resolved Hide resolved
R/reportCalibration.R Outdated Show resolved Hide resolved
R/reportCalibration.R Outdated Show resolved Hide resolved
R/reportCalibration.R Outdated Show resolved Hide resolved
R/reportCalibration.R Outdated Show resolved Hide resolved
R/reportCalibration.R Outdated Show resolved Hide resolved

out[["flowDevHsRel"]] <- .computeRelDev(out[["flowDevHs"]], list(p_constructionHist, p_renovationHist),
tCalib, notInHist = "hsr")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I modified the computation of the relative deviations by heating system - the idea is that the denominator is computed as the sum of the squares of the historic stock/flow of all heating systems, not just the heating system we are looking at. Therefore, the column hsr is excluded from the grouping when computing the sum of the squares.

.computeRelDev <- function(dfDev, dfHist, tCalib, notInHist = NULL) {

# Determine the reported columns in the calibration data
rprt <- setdiff(colnames(dfDev), c("iteration", "value", notInHist))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function was adapted to allow for the modified computation of relative deviations by hs.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking good

@ricardarosemann
Copy link
Contributor Author

I adapted the computation of relative deviations by heating system a little, see also the comments in the code. Therefore a brief review would be great.

.computeRelDev <- function(dfDev, dfHist, tCalib, notInHist = NULL) {

# Determine the reported columns in the calibration data
rprt <- setdiff(colnames(dfDev), c("iteration", "value", notInHist))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking good

@ricardarosemann ricardarosemann merged commit 3d11010 into pik-piam:main May 28, 2024
2 checks passed
@ricardarosemann ricardarosemann deleted the calibration-reporting branch May 29, 2024 10:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants