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

option zeroWeight=setNA for toolAggregate? #214

Closed
orichters opened this issue Aug 13, 2024 · 1 comment · Fixed by #215
Closed

option zeroWeight=setNA for toolAggregate? #214

orichters opened this issue Aug 13, 2024 · 1 comment · Fixed by #215
Labels

Comments

@orichters
Copy link
Contributor

Example data:

  scenario region variable value period   unit  model
1     scen    CAZ       FE     0   2010 US$/EJ REMIND
2     scen    CAZ Price|FE     1   2010 US$/EJ REMIND
3     scen    USA       FE     0   2010 US$/EJ REMIND
4     scen    USA Price|FE     5   2010 US$/EJ REMIND

Now, if you run toolAggregate Price|FE with FE as weight and zeroWeight = "allow", it happily returns 0:

library(madrat)
library(magclass)
library(quitte)
library(tidyverse)
d <- data.frame(scenario = "scen", region = c("CAZ", "CAZ", "USA", "USA"), variable = c("FE", "Price|FE"), value = c(0, 1, 0, 5), period = 2010, unit = "US$/EJ", model = "REMIND") %>% as.quitte() %>% as.magpie()
int2ext <- setNames("Price|FE", "FE")

map <- data.frame(region=getRegions(d), world="GLO", stringsAsFactors=FALSE)

toolAggregate(d[,,1], rel = map, weight = d[map$region,,int2ext[1]], zeroWeight = "allow")

I wonder whether it would make sense to either just return NA for zeroWeight = allow, or add a new options zeroWeight = setNA which basically set weight2 to NA here (or just drops the + 10^-100)? This would be useful for price aggregation in remind2, where the World value currently is just set to 0, see pik-piam/remind2#642

Any preference, @tscheypidi?

@pascal-sauer
Copy link
Contributor

just returning NA would break a lot of usages, but I don't see a problem with adding a setNA option

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants