Skip to content

Commit

Permalink
Raw output in calculate_metrics now shows zeros
Browse files Browse the repository at this point in the history
  • Loading branch information
eibanez committed May 21, 2015
1 parent b1228c4 commit 62911c9
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions R/calculate_metrics.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,15 @@ calculate_metrics_area <- function(time.data, outage.table, raw = FALSE) {
# Convert time.data into a new data.table and sort by Level, Area and NetLoad
time.data.dt <- data.table(time.data, key = "Level,Area,NetLoad")

# Perform the lookup of time.data on the outage table (and summarize if appropriate)
# Perform the lookup of time.data on the outage table
out <- outage.table[time.data.dt, roll = TRUE]
out <- na.omit(out)
out[is.na(Capacity2), Capacity2 := 0]
out[is.na(Prob), Prob := 0]
out[is.na(LOLP), LOLP := 0]
out[is.na(BaseEUE), BaseEUE := 0]
out[, EUE := BaseEUE + LOLP * (Capacity - Capacity2)]

# Summarize results if requested
if (!raw) {
# Aggregate up to the hour first (in case there is a sliding window)
out <- out[, list(LOLP = sum(LOLP * WinProb, na.rm = TRUE),
Expand Down

0 comments on commit 62911c9

Please sign in to comment.