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

fix warning: The naming option = 'indicator.scenario' is deprecated... #51

Merged
merged 4 commits into from
Nov 19, 2024

Conversation

pascal-sauer
Copy link
Contributor

see b838c93 for actual changes, the rest is linter/formatting, but note I removed an unused variable

years = paste0("y", c(2005, seq(2010, 2100, by = 10))),
round = 6)
pop <- collapseNames(pop[,,"SSP2"])
pop <- collapseNames(calcOutput("Population",
Copy link
Member

Choose a reason for hiding this comment

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

You can drop "collapseNames" entirely :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No that would lead to different output:

> waldo::compare(a,b)
`names(dimnames([email protected]))`: "iso" "year" "scenario.variable"
`names(dimnames([email protected]))`: "iso" "year" "scenario"         

`dimnames([email protected])$scenario.variable` is a character vector ('SSP2.pop_SSP2', 'SSP2_SPA2_26I_D.pop_SSP2')
`dimnames([email protected])$scenario.variable` is absent

`dimnames([email protected])$scenario` is absent
`dimnames([email protected])$scenario` is a character vector ('SSP2', 'SSP2_SPA2_26I_D')

comment(old) vs comment(new)
- " origin: readSource(type = \"S4Nproject_input\", subtype = \"bioenergy\", convert = \"onlycorrect\") (madrat 3.15.3 | mrland 0.65.1)"
+ " origin: readSource(type = \"S4Nproject_input\", subtype = \"bioenergy\", convert = \"onlycorrect\") (madrat 3.15.3 | mrland 0.65.0)"
- " creation date: Mon Nov 18 16:29:58 2024"
+ " creation date: Mon Nov 18 14:49:35 2024"

`names(dimnames(old))`: "iso" "year" "scenario.variable"
`names(dimnames(new))`: "iso" "year" "scenario"         

`dimnames(old)$scenario.variable` is a character vector ('SSP2.pop_SSP2', 'SSP2_SPA2_26I_D.pop_SSP2')
`dimnames(new)$scenario.variable` is absent

`dimnames(old)$scenario` is absent
`dimnames(new)$scenario` is a character vector ('SSP2', 'SSP2_SPA2_26I_D')

Copy link
Member

Choose a reason for hiding this comment

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

Did you run the comparison with scenario = "SSP2"?

Copy link
Member

Choose a reason for hiding this comment

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

Ok, I see... collapseNames deletes the data name, if only 1 data dimension exists.

Comment on lines +79 to +89
popReg <- toolAggregate(pop, rel = regionmapping, weight = NULL)
popReg <- as.data.frame(popReg)
popReg <- data.frame(Region = popReg$Region,
year = as.character(popReg$Year),
Value = popReg$Value,
stringsAsFactors = FALSE)
popReg <- merge(popReg, regionmapping, "Region")
popReg <- collapseNames(as.magpie(data.frame(iso = popReg$iso, year = popReg$year, Value = popReg$Value)))

# country population share
pop_shr <- pop/pop_reg

# bioenergy demand weighted by population
x <- x * pop/pop_reg
x <- x * pop / popReg
Copy link
Member

Choose a reason for hiding this comment

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

Just a comment, but can't one simply do x <- toolAggregate(x, rel = regionmapping, from = "Region", to = "iso", weight = pop) to disaggregate x?
(I didn't test this!)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems reasonable, but I didn't want to change more than necessary (to fix the warning + linter), so I don't need to test more than necessary 😉

@pascal-sauer pascal-sauer merged commit cff5509 into pik-piam:master Nov 19, 2024
2 checks passed
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