Skip to content

Commit

Permalink
Merge pull request #457 from orichters/rawdata
Browse files Browse the repository at this point in the history
also fix Rawdata prices on reference run
  • Loading branch information
orichters authored Sep 8, 2023
2 parents 98ad22e + 095f5e5 commit f419182
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions R/reportPrices.R
Original file line number Diff line number Diff line change
Expand Up @@ -682,11 +682,6 @@ reportPrices <- function(gdx, output=NULL, regionSubsetList=NULL,
getNames(out.rawdata) <- paste0(unitsplit(getNames(out.rawdata))$variable, "|Rawdata (",
unitsplit(getNames(out.rawdata))$unit, ")")

## apply lowpass filter to receive moving average prices
out.lowpass <- lowpass(out)
getNames(out.lowpass) <- paste0(unitsplit(getNames(out.lowpass))$variable, "|Moving Avg (",
unitsplit(getNames(out.lowpass))$unit, ")")

## calculate reporting prices
out.reporting <- pmax(out, 0) # avoid negative prices

Expand All @@ -703,12 +698,19 @@ reportPrices <- function(gdx, output=NULL, regionSubsetList=NULL,
priceRef <- try(reportPrices(gdx_ref, output = NULL, regionSubsetList = regionSubsetList, t = t))
fixedyears <- getYears(out)[getYears(out, as.integer = TRUE) < cm_startyear]
if (! inherits(priceRef, "try-error") && length(fixedyears) > 0) {
joinedNames <- intersect(getNames(out), getNames(priceRef))
joinedNamesRep <- intersect(getNames(out), getNames(priceRef))
joinedRegions <- intersect(getRegions(priceRef), getRegions(out))
out.reporting[joinedRegions, fixedyears, joinedNames] <- priceRef[joinedRegions, fixedyears, joinedNames]
out.reporting[joinedRegions, fixedyears, joinedNamesRep] <- priceRef[joinedRegions, fixedyears, joinedNamesRep]
joinedNamesRaw <- intersect(getNames(out.rawdata), getNames(priceRef))
out.rawdata[joinedRegions, fixedyears, joinedNamesRaw] <- priceRef[joinedRegions, fixedyears, joinedNamesRaw]
}
}

## apply lowpass filter to receive moving average prices
out.lowpass <- lowpass(out)
getNames(out.lowpass) <- paste0(unitsplit(getNames(out.lowpass))$variable, "|Moving Avg (",
unitsplit(getNames(out.lowpass))$unit, ")")

## bind all prices together
out <- mbind(out.rawdata, out.lowpass, out.reporting)

Expand Down

0 comments on commit f419182

Please sign in to comment.