-
Notifications
You must be signed in to change notification settings - Fork 47
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
Implement explicit scenario choice across package. #633
Conversation
|
||
scenarios <- list(SSPs = paste0("SSP", 1:5), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you talk about read- and convertStationaryy with @fbenke-pik ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, ist there a something I should know @fbenke-pik ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it will be removed at some point, but for now we need to keep it.
8c78faf
to
3ac80ff
Compare
3ac80ff
to
aa97c52
Compare
aa97c52
to
d28b69d
Compare
Side note:
|
R/calcFEShares.R
Outdated
fe_demand <- calcOutput("FEdemand", aggregate = FALSE)[, , "SSP1"] | ||
fe_demand <- calcOutput("FEdemand", scenario = "SSP1", aggregate = FALSE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Disables the madrat
cache for this call. See pik-piam/mrindustry#30 (comment) and pik-piam/mrindustry#30 (comment). Should be fixed for the benefit of run times and disk space. And is probably an issue across related changes in other packages.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean it doesn't use a potential cache, in which the SSP1 scenario could be available right? I don't see a way around this without keeping a "default" set of scenarios, which is exactly what we want to get rid of. (Do you have any ideas?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
calcFEShares()
is called by fullREMIND()
, and that knows what scenarios are going to be calculated. Just pass the scenario
[sic] parameter passed to e.g. calcFEdemand()
to calcFEshares()
too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok! Thanks, will implement this right away.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for pointing this out, Michaja.
I just tested and noticed that madrat even does not recognize when you pass the same scenarios but in different order and will recalculate (so my point is we need to be aware of these things when passing additional arguments to heavy calc functions).
48b1ab0
to
340fe5f
Compare
Introduce a scenario argument to calcCapital, calcFeDemand, calcFeDemandBuildings, calcFloorspace, calcTheil, and calcEmiTarget. The larger picture is the attempt to step away from a default set of scenarios. The choice of scenarios should be explicit. In the case of the input data pipeline, it is made in fullREMIND and then passed on to the different calcOutput functions. Hopefully this will help us control/drop/introduce new scenarios more easily in the future. Move SSP2_NAV_all duplication to mrindustry. Set NAs in CO2 prices from ExpertGuess to 0. Drop unused sources argument in calcEmiTarget. Drop unused scenario_proj argument in calcFE. General refactoring.
340fe5f
to
2c06008
Compare
35d3593
to
75a0888
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@johanneskoch94 asked me to approve this as a technicality.
#' @param x MAgPIE object returned from readStationary | ||
#' @param subset A string, or vector of string designating the entries for the scenario dimension. If possible, | ||
#' passed to [mrdrivers::calcGDP()]. Unspecified scenarios receive SSP2 data. | ||
convertStationary <- function(x, subset) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@johanneskoch94 moving read and convert into the same file is a big no for mrremind. Please don't do that.
@@ -9,7 +9,6 @@ | |||
#' pre final energy category \item \code{subsidies_bulk}: subsidy rate per final | |||
#' energy category \item \code{energy}: final energy quantities per category } | |||
#' @return magpie object of the IIASA_subs_taxes data | |||
#' @author Christoph Bertram |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WHy did you remove the Author here? This is useful and important info, even if the person is no longer at PIK.
ceds <- ceds[, pmin(getYears(x), max(getYears(ceds))), ] | ||
getYears(ceds) <- getYears(x) | ||
|
||
return(list( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We agreed as a team to not use that rule and switched off that linter. Therefore, I don't think it makes sense to go through legacy code to change it. Probably not worth changing it back now, either. So this is just a remark for future changes.
#' @description The capacity targets (GW) at regional level are produced from two different databases- | ||
#' UNFCCC_NDC database, an update of the Rogelj 2017 paper (see readme in inputdata), and REN21 Global Renewables report | ||
#' The UNFCCC_NDC capacity targets are further broken down to conditional and unconditional targets. | ||
#' @author Aman Malik, Oliver Richters |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please bring back all the @author
tags. They are useful to evaluate who to ask for help and if the function is rather new or legacy code.
#' a <- convertIIASA_subs_taxes(x) | ||
#' } | ||
#' | ||
convertIIASA_subs_taxes <- function(x, subtype) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be brought back as an individual file
@@ -9,59 +9,26 @@ | |||
#' described in the article. The country codes are the World Bank codes. | |||
#' | |||
#' @return magpie object of the Gini data | |||
#' @author Bjoern Soergel |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please bring back author
There are several files with only stylistic changes. In future PRs, please make a separate PR for these. When doing complex refactorings, as in |
This is a known issue, occurs when running some aggregations on magclass objects where NAs in weights (or possibly other reasons) cause the sum to be not equal to its parts. Needs to be addressed per case and is a task in the RSE backlog. |
#' @importFrom readxl read_xlsx | ||
#' @importFrom dplyr select | ||
#' Emissions_2023_cond (or 2018/2021/2022 or uncond) for Emissions targets | ||
#' @param subset A string (or vector of strings) designating the scenario(s) to be returned. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add a remark that it is needed for the convert function, as it is not used directly in the read function
} | ||
|
||
|
||
convertEdgeBuildings <- function(x, subtype, subset) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
readEdgeBuildings
does not have the param 'subset`. Does it work then? If so, this is inconsistent with readUNFCCCC_NDR.R where you add the param to the read function (probably because you want to use it in the convert function).
!! Still waiting for my input data test to run through (/p/tmp/jokoch/pre-processing, output at /p/projects/rd3mod/inputdata/output_1.27/rev7.22johannes_test7_62eff8f7_remind) but tagged in the reviewers so that the revision can start.
Connected to this PR in mrindustry.