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

readGCPT('emissions') is broken #376

Open
0UmfHxcvx5J7JoaOhFSs5mncnisTJJ6q opened this issue Mar 22, 2023 · 0 comments
Open

readGCPT('emissions') is broken #376

0UmfHxcvx5J7JoaOhFSs5mncnisTJJ6q opened this issue Mar 22, 2023 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@0UmfHxcvx5J7JoaOhFSs5mncnisTJJ6q
Copy link
Member

Does not seem to be used in mrremind::fullREMIND(), s it's not urgent. But it should either be fixed, or the subtype removed if it is not used anymore.
The problem is here:

mrremind/R/readGCPT.R

Lines 966 to 970 in baa8d38

#Calculate committed emissions
# Select necessary columns from plant-level database
emi_data <- retire %>% select(Country,`Plant Age`,`Capacity (MW)`,Status,`Heat rate`,`Emission factor`,`Combustion technology`,RETIRED,Year) %>%
filter(!(Status %in% c("Retired","Cancelled","retired","cancelled")) & !is.na(`Capacity (MW)`) & is.na(RETIRED) & !is.na(`Emission factor`)) %>%
left_join(avgRetAge,by="Country") %>% mutate(Brown_Ret_Age=Avg_Ret_Age+5) %>% mutate(Norm_Ret_Age=40)

There is no column Emission factor factor anymore, but one called Emission factor (kg of CO2 per TJ) , probably due to the data update.

One gets a rather cryptic error

Error in `filter()` at magrittr/R/pipe.R:136:2:
ℹ In argument: `... & !is.na(`Emission factor`)`.
Caused by error:
! `..1` must be of size 13641 or 1, not size 0.

because filter(), not being able to find a Emission factor column, checks against Emission factor in the environment, where one was handily deposited, but with the value NULL, which is of length zero.

I suggest to get rid of this entire section

mrremind/R/readGCPT.R

Lines 57 to 108 in baa8d38

`Announced + Pre-permit + Permitted` <- NULL
. <- NULL
H2.2014 <- NULL
H2.2015 <- NULL
H2.2016 <- NULL
H2.2017 <- NULL
H2.2018 <- NULL
H2.2019 <- NULL
H2.2020 <- NULL
H2.2021 <- NULL
Jan15 <- NULL
Jan16 <- NULL
Jan17 <- NULL
Jan18 <- NULL
Jan19 <- NULL
Jan20 <- NULL
Jul20 <- NULL
Country <- NULL
CountryCode <- NULL
MW <- NULL
`2015` <- NULL
`2016` <- NULL
`2017` <- NULL
`2018` <- NULL
`2019` <- NULL
`2020` <- NULL
`Plant Age` <- NULL
`Capacity (MW)` <- NULL
Status <- NULL
RETIRED <- NULL
`Planned Retire` <- NULL
Avg_Ret_Age <- NULL
`Heat rate` <- NULL
`Emission factor` <- NULL
`Combustion technology` <- NULL
Year <- NULL
Period <- NULL
Cap_Factor <- NULL
green_5yr_emi <- NULL
bau_5yr_emi <- NULL
brown_5yr_emi <- NULL
norm_5yr_emi <- NULL
BAU_emi <- NULL
All_total_emi <- NULL
Value <- NULL
BAU_total_emi <- NULL
green_total_emi <- NULL
brown_total_emi <- NULL
norm_total_emi <- NULL
brown_emi <- NULL
green_emi <- NULL
norm_emi <- NULL

and use explicit pronouns for data masking functions (e.g. filter(!is.na(.data$Emission factor)).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants