Add charging cycles to battery deltas

replace/bdac4feebe33e4c73c224fe7a495adf8ca39ba79
JulioV 2019-11-05 11:35:01 -05:00
parent d249bcf3f2
commit c9764d322c
1 changed files with 2 additions and 2 deletions

View File

@ -7,7 +7,7 @@ battery <- read.csv(snakemake@input[[1]])
consumption <- battery %>%
mutate(group = ifelse(lag(battery_status) != battery_status, 1, 0) %>% coalesce(0),
group_id = cumsum(group) + 1) %>%
filter(battery_status == 3) %>%
filter(battery_status == 2 || battery_status == 3) %>%
group_by(group_id) %>%
summarize(battery_diff = first(battery_level) - last(battery_level),
time_diff = (last(timestamp) - first(timestamp)) / (1000 * 60 * 60),
@ -16,6 +16,6 @@ consumption <- battery %>%
local_start_date = first(local_date),
local_end_date = last(local_date)) %>%
select(-group_id) %>%
filter(time_diff > 0.1) # Avoids including quick discharge cycles
filter(time_diff > 0.1) # Avoids including quick cycles
write.csv(consumption, snakemake@output[[1]])