code to process data before matlab

This commit is contained in:
2022-02-13 15:15:44 -07:00
parent 43ee4f4994
commit 259a133f11
4 changed files with 1266 additions and 0 deletions

1155
prep/Manifest.toml Normal file

File diff suppressed because it is too large Load Diff

6
prep/Project.toml Normal file
View File

@@ -0,0 +1,6 @@
[deps]
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
DataFramesMeta = "1313f7d8-7da2-5740-9ea0-a2ca25f37964"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
StatsPlots = "f3b207a7-027a-5e70-b257-86293d7955fd"

60
prep/prep.jl Normal file
View File

@@ -0,0 +1,60 @@
using DataFrames
using LinearAlgebra
using CSV
using DataFramesMeta
using Plots
using StatsPlots
begin
df = CSV.read("compiled.csv", DataFrame)
df.bb_volume = df.bb_length .* df.bb_width .* df.bb_height
@eachrow! df begin
@newcol :Ix::Vector{Float64}
@newcol :Iy::Vector{Float64}
@newcol :Iz::Vector{Float64}
@newcol :Ibar::Vector{Float64}
I = [
:Ixx :Ixy :Ixz
:Iyx :Iyy :Iyz
:Izx :Izy :Izz
]
(:Ix, :Iy, :Iz) = eigvals(I)
:Ibar = :Ix^2 + :Iy^2 + :Iz^2 |> sqrt
end
# Convert material to scalar
begin
kv = Dict(reverse.(enumerate(Set(df.material_name))))
mats = []
for material in df.material_name
push!(mats, kv[material])
end
df.material_index = mats
end
# Remove columns not needed for analysis
df = df[!, [:mass, :volume, :density, :area, :bb_volume, :Ibar]]
# Remove outliers
df = df[df.bb_volume.<1e6, :]
df = df[df.mass.<1000, :]
end
@df df cornerplot(cols(1:4), compact = true)
# plot(df.mass)
# histogram(df.mass)
scatter(df.mass, df.volume)
CSV.write("prepped.csv", df)