Add charging cycles to battery deltas
parent
d249bcf3f2
commit
c9764d322c
|
@ -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]])
|
||||
|
|
Loading…
Reference in New Issue