From 7f2956e357137e3eab029694348e932dd82b3c82 Mon Sep 17 00:00:00 2001 From: agchesebro <76024790+agchesebro@users.noreply.github.com> Date: Mon, 26 Aug 2024 14:22:17 -0400 Subject: [PATCH] Remove voltage utilities Spinning this off into separate utility functions per discussion with Haris, so will not merge with this PR. --- test/extract_saved_voltages.jl | 43 ---------------------------------- 1 file changed, 43 deletions(-) delete mode 100644 test/extract_saved_voltages.jl diff --git a/test/extract_saved_voltages.jl b/test/extract_saved_voltages.jl deleted file mode 100644 index afb651e1..00000000 --- a/test/extract_saved_voltages.jl +++ /dev/null @@ -1,43 +0,0 @@ -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_vec = select(df, :timestamp)[:, 1] - -# Get all region names - -all_names = names(all_voltages) -unique_names = Vector{String}() - -for i in eachindex(all_names) - name_temp = all_names[i] - name = split(name_temp, "₊")[1] - push!(unique_names, name) -end - -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_vec) - if i == 1 || time_vec[i] != time_vec[i-1] - push!(time_indices, i) - end -end - -# Extract the voltages at the unique time indices -regions = zeros(length(time_indices), length(unique_names)) - -for i in eachindex(unique_names) - name = unique_names[i] - 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_vec[time_indices], regions, xlabel="Time", ylabel="Voltage", title="Average Voltage in Each Region") \ No newline at end of file