From 62911c98a198e039fcc51c5a06cf541edad2a6a1 Mon Sep 17 00:00:00 2001 From: Eduardo Ibanez Date: Thu, 21 May 2015 14:03:25 -0600 Subject: [PATCH] Raw output in calculate_metrics now shows zeros --- R/calculate_metrics.R | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/R/calculate_metrics.R b/R/calculate_metrics.R index 8b906c6..f54971a 100644 --- a/R/calculate_metrics.R +++ b/R/calculate_metrics.R @@ -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),