diff --git a/test/extract_saved_voltages.jl b/test/extract_saved_voltages.jl index 281ba7ba..afb651e1 100644 --- a/test/extract_saved_voltages.jl +++ b/test/extract_saved_voltages.jl @@ -1,10 +1,11 @@ using FileIO +using DataFrames # Loading single file - will loop to load all eventually data = load("/Users/achesebro/Downloads/sim0003.jld2") df = data["df"] all_voltages = select(df, r"₊V") -time = select(df, :timestamp)[:, 1] +time_vec = select(df, :timestamp)[:, 1] # Get all region names @@ -21,8 +22,8 @@ unique_names = unique(unique_names) # Get unique time indices (not originally unique because of the callbacks) time_indices = Vector{Int}() -for i in eachindex(time) - if i == 1 || time[i] != time[i-1] +for i in eachindex(time_vec) + if i == 1 || time_vec[i] != time_vec[i-1] push!(time_indices, i) end end @@ -32,10 +33,11 @@ regions = zeros(length(time_indices), length(unique_names)) for i in eachindex(unique_names) name = unique_names[i] - region = select(df, Regex(name)) + region = select(all_voltages, Regex(name)) temp = reduce(+, eachcol(region)) ./ ncol(region) + println(size(region)) regions[:, i] = temp[time_indices] end using Plots -plot(time[time_indices], regions, xlabel="Time", ylabel="Voltage", title="Average Voltage in Each Region") \ No newline at end of file +plot(time_vec[time_indices], regions, xlabel="Time", ylabel="Voltage", title="Average Voltage in Each Region") \ No newline at end of file