Skip to content

Commit

Permalink
Merge pull request #451 from orichters/smallfix
Browse files Browse the repository at this point in the history
cleanup FE prices in cs2
  • Loading branch information
orichters authored Sep 11, 2023
2 parents f419182 + 9caaccd commit df09717
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 126 deletions.
14 changes: 7 additions & 7 deletions R/readPopulation.R
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
#' Read Population from GDX file
#'
#'
#' Read Population data from a GDX file into a magpie object.
#'
#'
#'
#'
#' @param gdx a GDX list as created by readGDX, or the file name of a gdx
#' file(file name is recommended as this speeds up the code)
#' @author Lavinia Baumstark
#' @examples
#'
#'
#' \dontrun{gdp <- readPopulation(gdx)}
#'
#'
#' @export
#' @importFrom gdx readGDX
#' @importFrom magclass getNames<-
readPopulation <- function(gdx){
pop <- readGDX(gdx, name=c('pm_pop','pm_datapop'), format="first_found") * 1000
readPopulation <- function(gdx) {
pop <- readGDX(gdx, name = c("pm_pop", "pm_datapop"), format = "first_found") * 1000
getNames(pop) <- "population [million]"
return(pop)
}
140 changes: 21 additions & 119 deletions inst/markdown/compareScenarios2/cs2_02_macro.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ items <- c(
"Internal|CES Function|Value|entrp",
"Internal|CES Function|Value|enb",
"Internal|CES Function|Value|ue_industry")
showAreaAndBarPlots(data, items, tot, scales = "fixed")
```

Expand All @@ -101,7 +101,7 @@ tot <- "Internal|CES Function|Value|enb"
items <- c(
"Internal|CES Function|Value|enhb",
"Internal|CES Function|Value|feelcb")
showAreaAndBarPlots(data, items, tot, scales = "fixed")
```

Expand All @@ -116,7 +116,7 @@ items <- c(
"Internal|CES Function|Value|ue_cement",
"Internal|CES Function|Value|ue_chemicals",
"Internal|CES Function|Value|ue_otherInd")
showAreaAndBarPlots(data, items, tot, scales = "fixed")
```

Expand Down Expand Up @@ -168,129 +168,31 @@ vars <-
walk(vars, showLinePlots, data = dPrice, scale = "fixed")
```

### FE Prices
### FE|Buildings Prices

```{r FE Prices}
vars <-
levels(dPrice$variable) %>%
str_subset("^Price\\|Final Energy\\|") %>%
str_subset(
"\\|Moving Avg|\\|Total LCOE|\\|Fuel Cost|\\|Transport and Distribution|\\|Carbon Price Component|\\|Other Taxes$",
negate = TRUE)
vars %>%
str_subset("Liquids") %>%
walk(showLinePlots, data = dPrice, scale = "fixed")
vars %>%
str_subset("Gases") %>%
walk(showLinePlots, data = dPrice, scale = "fixed")
vars %>%
str_subset("Solids") %>%
walk(showLinePlots, data = dPrice, scale = "fixed")
vars %>%
str_subset("Electricity") %>%
walk(showLinePlots, data = dPrice, scale = "fixed")
vars %>%
str_subset("Hydrogen") %>%
walk(showLinePlots, data = dPrice, scale = "fixed")
vars %>%
str_subset("Heat") %>%
walk(showLinePlots, data = dPrice, scale = "fixed")
```

### FE LCOE Prices Transport

```{r FE LCOE Prices Transport}
groups <- c(
"Price|Final Energy|Transport|Liquids|Petroleum",
"Price|Final Energy|Transport|Liquids|Diesel",
"Price|Final Energy|Transport|Liquids|Biomass",
"Price|Final Energy|Transport|Liquids|Efuel",
"Price|Final Energy|Transport|Gases|Natural Gas",
"Price|Final Energy|Transport|Gases|Efuel",
"Price|Final Energy|Transport|Electricity",
"Price|Final Energy|Transport|Hydrogen"
)
for (g in groups) {
items <- c(
paste0(g, "|Fuel Cost"),
paste0(g, "|Transport and Distribution"),
paste0(g, "|Carbon Price Component"),
paste0(g, "|Other Taxes")
)
tot <- paste0(g, "|Total LCOE")
showAreaAndBarPlots(dPrice, intersect(items, unique(dPrice$variable)), tot)
}
```{r FE Buildings Prices}
carriers <- c("Solids", "Liquids", "Gases", "Hydrogen", "Heat", "Electricity")
vars <- intersect(paste0("Price|Final Energy|Buildings|", carriers),
levels(dPrice$variable))
walk(vars, showLinePlots, data = dPrice, scale = "fixed")
```

### FE LCOE Prices Buildings

```{r FE LCOE Prices Buildings}
groups <- c(
"Price|Final Energy|Buildings|Liquids|Oil",
"Price|Final Energy|Buildings|Liquids|Biomass",
"Price|Final Energy|Buildings|Liquids|Efuel",
"Price|Final Energy|Buildings|Gases|Natural Gas",
"Price|Final Energy|Buildings|Gases|Biomass",
"Price|Final Energy|Buildings|Gases|Efuel",
"Price|Final Energy|Buildings|Solids|Biomass",
"Price|Final Energy|Buildings|Electricity",
"Price|Final Energy|Buildings|Heat",
"Price|Final Energy|Buildings|Hydrogen"
)
for (g in groups) {
items <- c(
paste0(g, "|Fuel Cost"),
paste0(g, "|Transport and Distribution"),
paste0(g, "|Carbon Price Component"),
paste0(g, "|Other Taxes")
)
### FE|Industry Prices

tot <- paste0(g, "|Total LCOE")
showAreaAndBarPlots(dPrice, intersect(items, unique(dPrice$variable)), tot)
}
```{r FE Industry Prices}
carriers <- c("Solids", "Liquids", "Gases", "Hydrogen", "Heat", "Electricity")
vars <- intersect(paste0("Price|Final Energy|Industry|", carriers),
levels(dPrice$variable))
walk(vars, showLinePlots, data = dPrice, scale = "fixed")
```

### FE LCOE Prices Industry

```{r FE LCOE Prices Industry}
groups <- c(
"Price|Final Energy|Industry|Liquids|Oil",
"Price|Final Energy|Industry|Liquids|Biomass",
"Price|Final Energy|Industry|Liquids|Efuel",
"Price|Final Energy|Industry|Gases|Natural Gas",
"Price|Final Energy|Industry|Gases|Biomass",
"Price|Final Energy|Industry|Gases|Efuel",
"Price|Final Energy|Industry|Solids|Coal",
"Price|Final Energy|Industry|Solids|Biomass",
"Price|Final Energy|Industry|Electricity",
"Price|Final Energy|Industry|Heat",
"Price|Final Energy|Industry|Hydrogen"
)
### FE|Transport Prices

for (g in groups) {
items <- c(
paste0(g, "|Fuel Cost"),
paste0(g, "|Transport and Distribution"),
paste0(g, "|Carbon Price Component"),
paste0(g, "|Other Taxes")
)
tot <- paste0(g, "|Total LCOE")
showAreaAndBarPlots(dPrice, intersect(items, unique(dPrice$variable)), tot)
}
```{r FE Transport Prices}
carriers <- c("Solids", "Liquids", "Gases", "Hydrogen", "Heat", "Electricity")
vars <- intersect(paste0("Price|Final Energy|Transport|", carriers),
carrierslevels(dPrice$variable))
walk(vars, showLinePlots, data = dPrice, scale = "fixed")
```

## Trade
Expand Down

0 comments on commit df09717

Please sign in to comment.