2024-09-27 09:52:35 +02:00

208 lines
5.7 KiB
Plaintext

{
"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 = 244.25\n",
"alt = 310\n",
"ci = 200"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Get reference data"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"310 310 310 0.0\n",
"240 244.25 250 0.425\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.831 0.833 0.831 0.833\n",
"0.832 0.832 0.832\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.831 0.833 0.831 0.833\n",
"0.832 0.832 0.832\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
}