Add Demo
This commit is contained in:
parent
eaa19d9e9d
commit
5fb5ad0d79
207
Demo.ipynb
Normal file
207
Demo.ipynb
Normal file
@ -0,0 +1,207 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import math"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Data form AC"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"mmo = 0.87\n",
|
||||
"weight = 248.7\n",
|
||||
"alt = 300\n",
|
||||
"ci = 80"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Get reference data"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"290 300 310 0.5\n",
|
||||
"240 248.7 250 0.8699999999999989\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"alts = [250, 270, 290, 310, 330, 350, 370, 390, 410, 430]\n",
|
||||
"weights = [140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290]\n",
|
||||
"\n",
|
||||
"lowerAlt = [_alt for _alt in alts if _alt <= alt][-1]\n",
|
||||
"upperAlt = [_alt for _alt in alts if _alt >= alt][0]\n",
|
||||
"ratioAlt = (alt - lowerAlt) / 20.0\n",
|
||||
"print(lowerAlt, alt, upperAlt, ratioAlt)\n",
|
||||
"\n",
|
||||
"lowerWeight = [_weight for _weight in weights if _weight <= weight][-1]\n",
|
||||
"upperWeight = [_weight for _weight in weights if _weight >= weight][0]\n",
|
||||
"ratioWeight = (weight - lowerWeight) / 10.0\n",
|
||||
"print(lowerWeight, weight, upperWeight, ratioWeight)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Using Curves directly"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"matrix = {}\n",
|
||||
"file = open(f\"curve_params_{mmo}.data\", 'r')\n",
|
||||
"lines = file.readlines()\n",
|
||||
"file.close()\n",
|
||||
"\n",
|
||||
"for i in range(0, len(lines)):\n",
|
||||
" line = lines[i].split(\";\")\n",
|
||||
" for j in range(0, len(weights)):\n",
|
||||
" try:\n",
|
||||
" matrix[alts[i]][weights[j]] = line[j].strip().split(\",\")\n",
|
||||
" except KeyError:\n",
|
||||
" matrix[alts[i]] = {}\n",
|
||||
" matrix[alts[i]][weights[j]] = line[j].strip().split(\",\")\n",
|
||||
" except IndexError:\n",
|
||||
" pass"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"0.821 0.821 0.823 0.824\n",
|
||||
"0.821 0.824 0.823\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"def func_root(a, b, c, CI):\n",
|
||||
" return float(a) * math.sqrt(CI) + float(b) * CI + float(c)\n",
|
||||
"\n",
|
||||
"lowerAltLowerWeightMach = round(func_root(*matrix[lowerAlt][lowerWeight], ci), 3)\n",
|
||||
"lowerAltUpperWeightMach = round(func_root(*matrix[lowerAlt][upperWeight], ci), 3)\n",
|
||||
"upperAltLowerWeightMach = round(func_root(*matrix[upperAlt][lowerWeight], ci), 3)\n",
|
||||
"upperAltUpperWeightMach = round(func_root(*matrix[upperAlt][upperWeight], ci), 3)\n",
|
||||
"print(lowerAltLowerWeightMach, lowerAltUpperWeightMach, upperAltLowerWeightMach, upperAltUpperWeightMach)\n",
|
||||
"\n",
|
||||
"ratioedLowerAltMach = round(lowerAltLowerWeightMach + (lowerAltUpperWeightMach - lowerAltLowerWeightMach) * ratioWeight, 3)\n",
|
||||
"ratioedUpperAltMach = round(upperAltLowerWeightMach + (upperAltUpperWeightMach - upperAltLowerWeightMach) * ratioWeight, 3)\n",
|
||||
"ratioedMach = round(ratioedLowerAltMach + (ratioedUpperAltMach - ratioedLowerAltMach) * ratioAlt, 3)\n",
|
||||
"print(ratioedLowerAltMach, ratioedUpperAltMach, ratioedMach)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Using LUTs"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"lowerAltMatrix = {}\n",
|
||||
"upperAltMatrix = {}\n",
|
||||
"\n",
|
||||
"file = open(f\"ci2mach_{lowerAlt}_{mmo}.data\")\n",
|
||||
"lines = file.readlines()\n",
|
||||
"\n",
|
||||
"for i in range(0, len(lines)):\n",
|
||||
" line = lines[i].strip().split(\",\")\n",
|
||||
" lowerAltMatrix[weights[i]] = line\n",
|
||||
"\n",
|
||||
"file = open(f\"ci2mach_{upperAlt}_{mmo}.data\")\n",
|
||||
"lines = file.readlines()\n",
|
||||
"\n",
|
||||
"for i in range(0, len(lines)):\n",
|
||||
" line = lines[i].strip().split(\",\")\n",
|
||||
" upperAltMatrix[weights[i]] = line"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 7,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"0.821 0.821 0.823 0.824\n",
|
||||
"0.821 0.824 0.823\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"lowerAltLowerWeightMach = float(lowerAltMatrix[lowerWeight][ci])\n",
|
||||
"lowerAltUpperWeightMach = float(lowerAltMatrix[upperWeight][ci])\n",
|
||||
"upperAltLowerWeightMach = float(upperAltMatrix[lowerWeight][ci])\n",
|
||||
"upperAltUpperWeightMach = float(upperAltMatrix[upperWeight][ci])\n",
|
||||
"print(lowerAltLowerWeightMach, lowerAltUpperWeightMach, upperAltLowerWeightMach, upperAltUpperWeightMach)\n",
|
||||
"\n",
|
||||
"ratioedLowerAltMach = round(lowerAltLowerWeightMach + (lowerAltUpperWeightMach - lowerAltLowerWeightMach) * ratioWeight, 3)\n",
|
||||
"ratioedUpperAltMach = round(upperAltLowerWeightMach + (upperAltUpperWeightMach - upperAltLowerWeightMach) * ratioWeight, 3)\n",
|
||||
"ratioedMach = round(ratioedLowerAltMach + (ratioedUpperAltMach - ratioedLowerAltMach) * ratioAlt, 3)\n",
|
||||
"print(ratioedLowerAltMach, ratioedUpperAltMach, ratioedMach)"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.11.9"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 2
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user