2022-04-24 21:40:17 -07:00

237 lines
10 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "129f639c",
"metadata": {},
"outputs": [],
"source": [
"import IJulia\n",
"\n",
"# The julia kernel has built in support for Revise.jl, so this is the \n",
"# recommended approach for long-running sessions:\n",
"# https://github.com/JuliaLang/IJulia.jl/blob/9b10fa9b879574bbf720f5285029e07758e50a5e/src/kernel.jl#L46-L51\n",
"\n",
"# Users should enable revise within .julia/config/startup_ijulia.jl:\n",
"# https://timholy.github.io/Revise.jl/stable/config/#Using-Revise-automatically-within-Jupyter/IJulia-1\n",
"\n",
"# clear console history\n",
"IJulia.clear_history()\n",
"\n",
"# Intialize Plots w/ default fig width/height\n",
"try\n",
" fig_width = 7\n",
" fig_height = 5\n",
" fig_format = :retina\n",
" fig_dpi = 96\n",
" # no retina format type, use svg for high quality type/marks\n",
" if fig_format == :retina\n",
" fig_format = :svg\n",
" # IJulia doesn't support PDF output so use png (if the DPI \n",
" # remains the default of 300 then set to 96)\n",
" elseif fig_format == :pdf\n",
" fig_format = :png\n",
" fig_dpi = 96\n",
" end\n",
" # convert inches to pixels\n",
" fig_width = fig_width * fig_dpi\n",
" fig_height = fig_height * fig_dpi\n",
" using Plots\n",
" gr(size=(fig_width, fig_height), fmt = fig_format, dpi = fig_dpi)\n",
"catch e\n",
" # @warn \"Plots init\" exception=(e, catch_backtrace())\n",
"end\n",
"\n",
"# Set run_path if specified\n",
"try\n",
" run_path = \"\"\n",
" if !isempty(run_path)\n",
" cd(run_path)\n",
" end\n",
"catch e\n",
" @warn \"Run path init:\" exception=(e, catch_backtrace())\n",
"end\n",
"\n",
"# don't return kernel dependencies (b/c Revise should take care of dependencies)\n",
"nothing\n"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "8b15e8a8",
"metadata": {},
"outputs": [],
"source": [
"#| code-fold: true\n",
"#| output: false\n",
"\n",
"using FileIO\n",
"using MeshIO\n",
"\n",
"using stlProcess\n",
"\n",
"using CSV\n",
"using DataFrames\n",
"\n",
"using LinearAlgebra"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "f40c9594",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div class=\"data-frame\"><p>0 rows × 8 columns (omitted printing of 1 columns)</p><table class=\"data-frame\"><thead><tr><th></th><th>surface_area</th><th>characteristic_length</th><th>sbx</th><th>sby</th><th>sbz</th><th>Ix</th><th>Iy</th></tr><tr><th></th><th title=\"Float64\">Float64</th><th title=\"Float64\">Float64</th><th title=\"Float64\">Float64</th><th title=\"Float64\">Float64</th><th title=\"Float64\">Float64</th><th title=\"Float64\">Float64</th><th title=\"Float64\">Float64</th></tr></thead><tbody></tbody></table></div>"
],
"text/latex": [
"\\begin{tabular}{r|cccccccc}\n",
"\t& surface\\_area & characteristic\\_length & sbx & sby & sbz & Ix & Iy & \\\\\n",
"\t\\hline\n",
"\t& Float64 & Float64 & Float64 & Float64 & Float64 & Float64 & Float64 & \\\\\n",
"\t\\hline\n",
"\\end{tabular}\n"
],
"text/plain": [
"\u001b[1m0×8 DataFrame\u001b[0m"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"#| code-fold: true\n",
"#| output: false\n",
"\n",
"# local path to https://gitlab.com/orbital-debris-research/fake-satellite-dataset\n",
"dataset_path = raw\"C:\\Coding\\fake-satellite-dataset\"\n",
"\n",
"folders = [\"1_5U\", \"assembly1\", \"cubesat\"]\n",
"\n",
"df = DataFrame(;\n",
" surface_area=Float64[],\n",
" characteristic_length=Float64[],\n",
" sbx=Float64[],\n",
" sby=Float64[],\n",
" sbz=Float64[],\n",
" Ix=Float64[],\n",
" Iy=Float64[],\n",
" Iz=Float64[],\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "bb8f7086",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Processing Path: C:\\Coding\\fake-satellite-dataset\\1_5U\n",
"Processing Path: C:\\Coding\\fake-satellite-dataset\\assembly1\n",
"Processing Path: C:\\Coding\\fake-satellite-dataset\\cubesat\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"┌ Warning: Characteristic Length Algorithm failed to converge, this usually means stl is flat. Setting length in dir to 0.\n",
"└ @ stlProcess C:\\Users\\albig\\.julia\\packages\\stlProcess\\8rsc7\\src\\stlProcess.jl:153\n"
]
}
],
"source": [
"for path in dataset_path * \"\\\\\" .* folders\n",
" println(\"Processing Path: \", path)\n",
" Threads.@threads for file in readdir(path)\n",
" stl = load(path * \"\\\\\" * file)\n",
" scale = find_scale(stl)\n",
" props = get_mass_properties(stl; scale=scale)\n",
"\n",
" eigs = eigvals(props.inertia)\n",
" sort_index = sortperm(eigs)\n",
" Ix, Iy, Iz = eigs[sort_index]\n",
" sbx, sby, sbz = props.sb_values[sort_index]\n",
"\n",
" push!(\n",
" df,\n",
" [props.surface_area, props.characteristic_length, sbx, sby, sbz, Ix, Iy, Iz],\n",
" )\n",
" end\n",
"end"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "a51a601f",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div class=\"data-frame\"><p>8 rows × 7 columns</p><table class=\"data-frame\"><thead><tr><th></th><th>variable</th><th>mean</th><th>min</th><th>median</th><th>max</th><th>nmissing</th><th>eltype</th></tr><tr><th></th><th title=\"Symbol\">Symbol</th><th title=\"Float64\">Float64</th><th title=\"Float64\">Float64</th><th title=\"Float64\">Float64</th><th title=\"Float64\">Float64</th><th title=\"Int64\">Int64</th><th title=\"DataType\">DataType</th></tr></thead><tbody><tr><th>1</th><td>surface_area</td><td>25.2002</td><td>5.60865</td><td>13.3338</td><td>159.406</td><td>0</td><td>Float64</td></tr><tr><th>2</th><td>characteristic_length</td><td>79.5481</td><td>0.158521</td><td>1.55816</td><td>1582.23</td><td>0</td><td>Float64</td></tr><tr><th>3</th><td>sbx</td><td>1.40222</td><td>0.0417367</td><td>0.967078</td><td>10.0663</td><td>0</td><td>Float64</td></tr><tr><th>4</th><td>sby</td><td>3.3367</td><td>0.0125824</td><td>2.68461</td><td>9.68361</td><td>0</td><td>Float64</td></tr><tr><th>5</th><td>sbz</td><td>3.91184</td><td>0.29006</td><td>1.8185</td><td>14.7434</td><td>0</td><td>Float64</td></tr><tr><th>6</th><td>Ix</td><td>1.58725</td><td>0.0311782</td><td>0.23401</td><td>11.1335</td><td>0</td><td>Float64</td></tr><tr><th>7</th><td>Iy</td><td>3.74345</td><td>0.178598</td><td>1.01592</td><td>24.6735</td><td>0</td><td>Float64</td></tr><tr><th>8</th><td>Iz</td><td>5.20207</td><td>0.178686</td><td>1.742</td><td>32.0083</td><td>0</td><td>Float64</td></tr></tbody></table></div>"
],
"text/latex": [
"\\begin{tabular}{r|ccccccc}\n",
"\t& variable & mean & min & median & max & nmissing & eltype\\\\\n",
"\t\\hline\n",
"\t& Symbol & Float64 & Float64 & Float64 & Float64 & Int64 & DataType\\\\\n",
"\t\\hline\n",
"\t1 & surface\\_area & 25.2002 & 5.60865 & 13.3338 & 159.406 & 0 & Float64 \\\\\n",
"\t2 & characteristic\\_length & 79.5481 & 0.158521 & 1.55816 & 1582.23 & 0 & Float64 \\\\\n",
"\t3 & sbx & 1.40222 & 0.0417367 & 0.967078 & 10.0663 & 0 & Float64 \\\\\n",
"\t4 & sby & 3.3367 & 0.0125824 & 2.68461 & 9.68361 & 0 & Float64 \\\\\n",
"\t5 & sbz & 3.91184 & 0.29006 & 1.8185 & 14.7434 & 0 & Float64 \\\\\n",
"\t6 & Ix & 1.58725 & 0.0311782 & 0.23401 & 11.1335 & 0 & Float64 \\\\\n",
"\t7 & Iy & 3.74345 & 0.178598 & 1.01592 & 24.6735 & 0 & Float64 \\\\\n",
"\t8 & Iz & 5.20207 & 0.178686 & 1.742 & 32.0083 & 0 & Float64 \\\\\n",
"\\end{tabular}\n"
],
"text/plain": [
"\u001b[1m8×7 DataFrame\u001b[0m\n",
"\u001b[1m Row \u001b[0m│\u001b[1m variable \u001b[0m\u001b[1m mean \u001b[0m\u001b[1m min \u001b[0m\u001b[1m median \u001b[0m\u001b[1m max \u001b[0m\u001b[1m nmis\u001b[0m ⋯\n",
"\u001b[1m \u001b[0m│\u001b[90m Symbol \u001b[0m\u001b[90m Float64 \u001b[0m\u001b[90m Float64 \u001b[0m\u001b[90m Float64 \u001b[0m\u001b[90m Float64 \u001b[0m\u001b[90m Int6\u001b[0m ⋯\n",
"─────┼──────────────────────────────────────────────────────────────────────────\n",
" 1 │ surface_area 25.2002 5.60865 13.3338 159.406 ⋯\n",
" 2 │ characteristic_length 79.5481 0.158521 1.55816 1582.23\n",
" 3 │ sbx 1.40222 0.0417367 0.967078 10.0663\n",
" 4 │ sby 3.3367 0.0125824 2.68461 9.68361\n",
" 5 │ sbz 3.91184 0.29006 1.8185 14.7434 ⋯\n",
" 6 │ Ix 1.58725 0.0311782 0.23401 11.1335\n",
" 7 │ Iy 3.74345 0.178598 1.01592 24.6735\n",
" 8 │ Iz 5.20207 0.178686 1.742 32.0083\n",
"\u001b[36m 2 columns omitted\u001b[0m"
]
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"describe(df)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Julia 1.8.0-beta3",
"language": "julia",
"name": "julia-1.8"
}
},
"nbformat": 4,
"nbformat_minor": 5
}