Files
Masterprojekt/conversions_test.ipynb
2026-01-18 22:29:29 +01:00

1215 lines
29 KiB
Plaintext

{
"cells": [
{
"metadata": {},
"cell_type": "code",
"source": [
"%load_ext autoreload\n",
"%autoreload 2"
],
"id": "746c5b9e4c0226e7",
"outputs": [],
"execution_count": null
},
{
"cell_type": "code",
"id": "initial_id",
"metadata": {
"collapsed": true,
"ExecuteTime": {
"end_time": "2026-01-18T15:16:41.874660Z",
"start_time": "2026-01-18T15:16:41.342891Z"
}
},
"source": [
"%reload_ext autoreload\n",
"%autoreload 2\n",
"import pickle\n",
"import numpy as np\n",
"import winkelumrechnungen as wu\n",
"from itertools import product\n",
"import pandas as pd\n",
"from ellipsoide import EllipsoidTriaxial\n",
"import plotly.graph_objects as go"
],
"outputs": [],
"execution_count": 19
},
{
"metadata": {
"ExecuteTime": {
"end_time": "2026-01-18T15:16:42.413245Z",
"start_time": "2026-01-18T15:16:41.883595Z"
}
},
"cell_type": "code",
"source": [
"# ellips = \"KarneyTest2024\"\n",
"# ellips = \"BursaSima1980\"\n",
"ellips = \"Fiction\"\n",
"ell: EllipsoidTriaxial = EllipsoidTriaxial.init_name(ellips)"
],
"id": "7b05ca89fcd7b331",
"outputs": [],
"execution_count": 20
},
{
"metadata": {
"ExecuteTime": {
"end_time": "2026-01-18T15:16:42.846215Z",
"start_time": "2026-01-18T15:16:42.422038Z"
}
},
"cell_type": "code",
"source": [
"def deg_range(start, stop, step):\n",
" return [float(x) for x in range(start, stop + step, step)]\n",
"\n",
"def asymptotic_range(start, direction=\"up\", max_decimals=4):\n",
" values = []\n",
" for d in range(0, max_decimals + 1):\n",
" step = 10 ** -d\n",
" if direction == \"up\":\n",
" values.append(start + (1 - step))\n",
" else:\n",
" values.append(start - (1 - step))\n",
" return values"
],
"id": "61a6b14fef0180ad",
"outputs": [],
"execution_count": 21
},
{
"metadata": {
"ExecuteTime": {
"end_time": "2026-01-18T15:16:43.226892Z",
"start_time": "2026-01-18T15:16:42.854231Z"
}
},
"cell_type": "code",
"source": [
"beta_5_85 = deg_range(5, 85, 5)\n",
"lambda_5_85 = deg_range(5, 85, 5)\n",
"beta_5_90 = deg_range(5, 90, 5)\n",
"lambda_5_90 = deg_range(5, 90, 5)\n",
"beta_0_90 = deg_range(0, 90, 5)\n",
"lambda_0_90 = deg_range(0, 90, 5)\n",
"beta_90 = [90.0]\n",
"lambda_90 = [90.0]\n",
"beta_0 = [0.0]\n",
"lambda_0 = [0.0]\n",
"beta_asym_89 = asymptotic_range(89.0, direction=\"up\")\n",
"lambda_asym_0 = asymptotic_range(1.0, direction=\"down\")"
],
"id": "f7184980a4b930b7",
"outputs": [],
"execution_count": 22
},
{
"metadata": {
"ExecuteTime": {
"end_time": "2026-01-18T15:16:43.693549Z",
"start_time": "2026-01-18T15:16:43.235422Z"
}
},
"cell_type": "code",
"source": [
"groups = {\n",
" 1: list(product(beta_5_85, lambda_5_85)),\n",
" 2: list(product(beta_0, lambda_0_90)),\n",
" 3: list(product(beta_5_85, lambda_0)),\n",
" 4: list(product(beta_90, lambda_5_90)),\n",
" 5: list(product(beta_asym_89, lambda_asym_0)),\n",
" 6: list(product(beta_5_85, lambda_90)),\n",
" 7: list(product(lambda_asym_0, lambda_0_90)),\n",
" 8: list(product(beta_0_90, lambda_asym_0)),\n",
" 9: list(product(beta_asym_89, lambda_0_90)),\n",
" 10: list(product(beta_0_90, beta_asym_89)),\n",
"}"
],
"id": "cea9fd9cce6a4fd1",
"outputs": [],
"execution_count": 23
},
{
"metadata": {
"ExecuteTime": {
"end_time": "2026-01-18T15:16:44.192383Z",
"start_time": "2026-01-18T15:16:43.708461Z"
}
},
"cell_type": "code",
"source": [
"for nr, points in groups.items():\n",
" points_cart = []\n",
" for point in points:\n",
" beta, lamb = point\n",
" cart = ell.ell2cart(wu.deg2rad(beta), wu.deg2rad(lamb))\n",
" points_cart.append(cart)\n",
" groups[nr] = points_cart"
],
"id": "17a6a130782a89ce",
"outputs": [],
"execution_count": 24
},
{
"metadata": {
"ExecuteTime": {
"end_time": "2026-01-18T15:16:45.414815Z",
"start_time": "2026-01-18T15:16:44.202558Z"
}
},
"cell_type": "code",
"source": [
"results = {}\n",
"\n",
"for nr, points in groups.items():\n",
" group_results = {\"ell\": [],\n",
" \"para\": [],\n",
" \"geod\": []}\n",
" for point in points:\n",
" elli = ell.cart2ell(point)\n",
" cart_elli = ell.ell2cart(elli[0], elli[1])\n",
" group_results[\"ell\"].append(np.linalg.norm(point - cart_elli, axis=-1))\n",
"\n",
" para = ell.cart2para(point)\n",
" cart_para = ell.para2cart(para[0], para[1])\n",
" group_results[\"para\"].append(np.linalg.norm(point - cart_para, axis=-1))\n",
"\n",
" if point[0] == 2503658.1932679387:\n",
" pass\n",
" geod = ell.cart2geod(point, \"ligas3\")\n",
" cart_geod = ell.geod2cart(geod[0], geod[1], geod[2])\n",
" if np.linalg.norm(point - cart_geod) > 1:\n",
" pass\n",
" group_results[\"geod\"].append(np.linalg.norm(point - cart_geod, axis=-1))\n",
"\n",
" group_results[\"ell\"] = np.array(group_results[\"ell\"])\n",
" group_results[\"para\"] = np.array(group_results[\"para\"])\n",
" group_results[\"geod\"] = np.array(group_results[\"geod\"])\n",
" results[nr] = group_results"
],
"id": "c3298ea233bca274",
"outputs": [],
"execution_count": 25
},
{
"metadata": {
"ExecuteTime": {
"end_time": "2026-01-18T15:16:46.249826Z",
"start_time": "2026-01-18T15:16:45.881679Z"
}
},
"cell_type": "code",
"source": [
"with open(f\"conversion_results_{ellips}.pkl\", \"wb\") as f:\n",
" pickle.dump(results, f)"
],
"id": "e1285860be416ad3",
"outputs": [],
"execution_count": 26
},
{
"metadata": {
"ExecuteTime": {
"end_time": "2026-01-18T15:16:46.683803Z",
"start_time": "2026-01-18T15:16:46.259031Z"
}
},
"cell_type": "code",
"source": [
"df = pd.DataFrame({\n",
" \"Gruppe\": [nr for nr in results.keys()],\n",
" \"max_Δr_ell\": [f\"{max(result[\"ell\"]):.3g}\" for result in results.values()],\n",
" \"max_Δr_para\": [f\"{max(result[\"para\"]):.3g}\" for result in results.values()],\n",
" \"max_Δr_geod\": [f\"{max(result[\"geod\"]):.3g}\" for result in results.values()]\n",
"})"
],
"id": "4e2e55e4699ec81e",
"outputs": [],
"execution_count": 27
},
{
"metadata": {
"ExecuteTime": {
"end_time": "2026-01-18T15:19:58.855909Z",
"start_time": "2026-01-18T15:19:54.770124Z"
}
},
"cell_type": "code",
"source": [
"fig = go.Figure(data=[go.Table(\n",
" header=dict(\n",
" values=list(df.columns),\n",
" fill_color=\"lightgrey\",\n",
" align=\"left\"\n",
" ),\n",
" cells=dict(\n",
" values=[df[col] for col in df.columns],\n",
" align=\"left\"\n",
" )\n",
")])\n",
"fig.update_layout(\n",
" template=\"simple_white\",\n",
" width=650,\n",
" height=len(groups)*20+80,\n",
" margin=dict(l=20, r=20, t=20, b=20))\n",
"\n",
"fig.show()\n",
"fig.write_image(f\"conversion_results_{ellips}.png\", width=650, height=len(groups)*20+80, scale=2)"
],
"id": "c2fa82afef2d6e0e",
"outputs": [
{
"data": {
"application/vnd.plotly.v1+json": {
"data": [
{
"cells": {
"align": "left",
"values": [
[
1,
2,
3,
4,
5,
6,
7,
8,
9,
10
],
[
"1.49e-09",
"3.49e-10",
"1.07e-09",
"0",
"1.16e-09",
"5.21e-10",
"9.31e-10",
"1.86e-09",
"1.04e-09",
"5.21e-10"
],
[
"1.95e-09",
"9.31e-10",
"1.04e-09",
"3.67e-10",
"1.04e-09",
"9.73e-10",
"1.88e-09",
"1.92e-09",
"2.37e-09",
"1.29e-09"
],
[
"2.83e-09",
"1.04e-09",
"1.92e-09",
"1.2e-09",
"1.88e-09",
"1.75e-09",
"1.86e-09",
"1.92e-09",
"3.39e-09",
"2.33e-09"
]
]
},
"header": {
"align": "left",
"fill": {
"color": "lightgrey"
},
"values": [
"Gruppe",
"max_Δr_ell",
"max_Δr_para",
"max_Δr_geod"
]
},
"type": "table"
}
],
"layout": {
"template": {
"data": {
"barpolar": [
{
"marker": {
"line": {
"color": "white",
"width": 0.5
},
"pattern": {
"fillmode": "overlay",
"size": 10,
"solidity": 0.2
}
},
"type": "barpolar"
}
],
"bar": [
{
"error_x": {
"color": "rgb(36,36,36)"
},
"error_y": {
"color": "rgb(36,36,36)"
},
"marker": {
"line": {
"color": "white",
"width": 0.5
},
"pattern": {
"fillmode": "overlay",
"size": 10,
"solidity": 0.2
}
},
"type": "bar"
}
],
"carpet": [
{
"aaxis": {
"endlinecolor": "rgb(36,36,36)",
"gridcolor": "white",
"linecolor": "white",
"minorgridcolor": "white",
"startlinecolor": "rgb(36,36,36)"
},
"baxis": {
"endlinecolor": "rgb(36,36,36)",
"gridcolor": "white",
"linecolor": "white",
"minorgridcolor": "white",
"startlinecolor": "rgb(36,36,36)"
},
"type": "carpet"
}
],
"choropleth": [
{
"colorbar": {
"outlinewidth": 1,
"tickcolor": "rgb(36,36,36)",
"ticks": "outside"
},
"type": "choropleth"
}
],
"contourcarpet": [
{
"colorbar": {
"outlinewidth": 1,
"tickcolor": "rgb(36,36,36)",
"ticks": "outside"
},
"type": "contourcarpet"
}
],
"contour": [
{
"colorbar": {
"outlinewidth": 1,
"tickcolor": "rgb(36,36,36)",
"ticks": "outside"
},
"colorscale": [
[
0.0,
"#440154"
],
[
0.1111111111111111,
"#482878"
],
[
0.2222222222222222,
"#3e4989"
],
[
0.3333333333333333,
"#31688e"
],
[
0.4444444444444444,
"#26828e"
],
[
0.5555555555555556,
"#1f9e89"
],
[
0.6666666666666666,
"#35b779"
],
[
0.7777777777777778,
"#6ece58"
],
[
0.8888888888888888,
"#b5de2b"
],
[
1.0,
"#fde725"
]
],
"type": "contour"
}
],
"heatmap": [
{
"colorbar": {
"outlinewidth": 1,
"tickcolor": "rgb(36,36,36)",
"ticks": "outside"
},
"colorscale": [
[
0.0,
"#440154"
],
[
0.1111111111111111,
"#482878"
],
[
0.2222222222222222,
"#3e4989"
],
[
0.3333333333333333,
"#31688e"
],
[
0.4444444444444444,
"#26828e"
],
[
0.5555555555555556,
"#1f9e89"
],
[
0.6666666666666666,
"#35b779"
],
[
0.7777777777777778,
"#6ece58"
],
[
0.8888888888888888,
"#b5de2b"
],
[
1.0,
"#fde725"
]
],
"type": "heatmap"
}
],
"histogram2dcontour": [
{
"colorbar": {
"outlinewidth": 1,
"tickcolor": "rgb(36,36,36)",
"ticks": "outside"
},
"colorscale": [
[
0.0,
"#440154"
],
[
0.1111111111111111,
"#482878"
],
[
0.2222222222222222,
"#3e4989"
],
[
0.3333333333333333,
"#31688e"
],
[
0.4444444444444444,
"#26828e"
],
[
0.5555555555555556,
"#1f9e89"
],
[
0.6666666666666666,
"#35b779"
],
[
0.7777777777777778,
"#6ece58"
],
[
0.8888888888888888,
"#b5de2b"
],
[
1.0,
"#fde725"
]
],
"type": "histogram2dcontour"
}
],
"histogram2d": [
{
"colorbar": {
"outlinewidth": 1,
"tickcolor": "rgb(36,36,36)",
"ticks": "outside"
},
"colorscale": [
[
0.0,
"#440154"
],
[
0.1111111111111111,
"#482878"
],
[
0.2222222222222222,
"#3e4989"
],
[
0.3333333333333333,
"#31688e"
],
[
0.4444444444444444,
"#26828e"
],
[
0.5555555555555556,
"#1f9e89"
],
[
0.6666666666666666,
"#35b779"
],
[
0.7777777777777778,
"#6ece58"
],
[
0.8888888888888888,
"#b5de2b"
],
[
1.0,
"#fde725"
]
],
"type": "histogram2d"
}
],
"histogram": [
{
"marker": {
"line": {
"color": "white",
"width": 0.6
}
},
"type": "histogram"
}
],
"mesh3d": [
{
"colorbar": {
"outlinewidth": 1,
"tickcolor": "rgb(36,36,36)",
"ticks": "outside"
},
"type": "mesh3d"
}
],
"parcoords": [
{
"line": {
"colorbar": {
"outlinewidth": 1,
"tickcolor": "rgb(36,36,36)",
"ticks": "outside"
}
},
"type": "parcoords"
}
],
"pie": [
{
"automargin": true,
"type": "pie"
}
],
"scatter3d": [
{
"line": {
"colorbar": {
"outlinewidth": 1,
"tickcolor": "rgb(36,36,36)",
"ticks": "outside"
}
},
"marker": {
"colorbar": {
"outlinewidth": 1,
"tickcolor": "rgb(36,36,36)",
"ticks": "outside"
}
},
"type": "scatter3d"
}
],
"scattercarpet": [
{
"marker": {
"colorbar": {
"outlinewidth": 1,
"tickcolor": "rgb(36,36,36)",
"ticks": "outside"
}
},
"type": "scattercarpet"
}
],
"scattergeo": [
{
"marker": {
"colorbar": {
"outlinewidth": 1,
"tickcolor": "rgb(36,36,36)",
"ticks": "outside"
}
},
"type": "scattergeo"
}
],
"scattergl": [
{
"marker": {
"colorbar": {
"outlinewidth": 1,
"tickcolor": "rgb(36,36,36)",
"ticks": "outside"
}
},
"type": "scattergl"
}
],
"scattermapbox": [
{
"marker": {
"colorbar": {
"outlinewidth": 1,
"tickcolor": "rgb(36,36,36)",
"ticks": "outside"
}
},
"type": "scattermapbox"
}
],
"scattermap": [
{
"marker": {
"colorbar": {
"outlinewidth": 1,
"tickcolor": "rgb(36,36,36)",
"ticks": "outside"
}
},
"type": "scattermap"
}
],
"scatterpolargl": [
{
"marker": {
"colorbar": {
"outlinewidth": 1,
"tickcolor": "rgb(36,36,36)",
"ticks": "outside"
}
},
"type": "scatterpolargl"
}
],
"scatterpolar": [
{
"marker": {
"colorbar": {
"outlinewidth": 1,
"tickcolor": "rgb(36,36,36)",
"ticks": "outside"
}
},
"type": "scatterpolar"
}
],
"scatter": [
{
"fillpattern": {
"fillmode": "overlay",
"size": 10,
"solidity": 0.2
},
"type": "scatter"
}
],
"scatterternary": [
{
"marker": {
"colorbar": {
"outlinewidth": 1,
"tickcolor": "rgb(36,36,36)",
"ticks": "outside"
}
},
"type": "scatterternary"
}
],
"surface": [
{
"colorbar": {
"outlinewidth": 1,
"tickcolor": "rgb(36,36,36)",
"ticks": "outside"
},
"colorscale": [
[
0.0,
"#440154"
],
[
0.1111111111111111,
"#482878"
],
[
0.2222222222222222,
"#3e4989"
],
[
0.3333333333333333,
"#31688e"
],
[
0.4444444444444444,
"#26828e"
],
[
0.5555555555555556,
"#1f9e89"
],
[
0.6666666666666666,
"#35b779"
],
[
0.7777777777777778,
"#6ece58"
],
[
0.8888888888888888,
"#b5de2b"
],
[
1.0,
"#fde725"
]
],
"type": "surface"
}
],
"table": [
{
"cells": {
"fill": {
"color": "rgb(237,237,237)"
},
"line": {
"color": "white"
}
},
"header": {
"fill": {
"color": "rgb(217,217,217)"
},
"line": {
"color": "white"
}
},
"type": "table"
}
]
},
"layout": {
"annotationdefaults": {
"arrowhead": 0,
"arrowwidth": 1
},
"autotypenumbers": "strict",
"coloraxis": {
"colorbar": {
"outlinewidth": 1,
"tickcolor": "rgb(36,36,36)",
"ticks": "outside"
}
},
"colorscale": {
"diverging": [
[
0.0,
"rgb(103,0,31)"
],
[
0.1,
"rgb(178,24,43)"
],
[
0.2,
"rgb(214,96,77)"
],
[
0.3,
"rgb(244,165,130)"
],
[
0.4,
"rgb(253,219,199)"
],
[
0.5,
"rgb(247,247,247)"
],
[
0.6,
"rgb(209,229,240)"
],
[
0.7,
"rgb(146,197,222)"
],
[
0.8,
"rgb(67,147,195)"
],
[
0.9,
"rgb(33,102,172)"
],
[
1.0,
"rgb(5,48,97)"
]
],
"sequential": [
[
0.0,
"#440154"
],
[
0.1111111111111111,
"#482878"
],
[
0.2222222222222222,
"#3e4989"
],
[
0.3333333333333333,
"#31688e"
],
[
0.4444444444444444,
"#26828e"
],
[
0.5555555555555556,
"#1f9e89"
],
[
0.6666666666666666,
"#35b779"
],
[
0.7777777777777778,
"#6ece58"
],
[
0.8888888888888888,
"#b5de2b"
],
[
1.0,
"#fde725"
]
],
"sequentialminus": [
[
0.0,
"#440154"
],
[
0.1111111111111111,
"#482878"
],
[
0.2222222222222222,
"#3e4989"
],
[
0.3333333333333333,
"#31688e"
],
[
0.4444444444444444,
"#26828e"
],
[
0.5555555555555556,
"#1f9e89"
],
[
0.6666666666666666,
"#35b779"
],
[
0.7777777777777778,
"#6ece58"
],
[
0.8888888888888888,
"#b5de2b"
],
[
1.0,
"#fde725"
]
]
},
"colorway": [
"#1F77B4",
"#FF7F0E",
"#2CA02C",
"#D62728",
"#9467BD",
"#8C564B",
"#E377C2",
"#7F7F7F",
"#BCBD22",
"#17BECF"
],
"font": {
"color": "rgb(36,36,36)"
},
"geo": {
"bgcolor": "white",
"lakecolor": "white",
"landcolor": "white",
"showlakes": true,
"showland": true,
"subunitcolor": "white"
},
"hoverlabel": {
"align": "left"
},
"hovermode": "closest",
"mapbox": {
"style": "light"
},
"paper_bgcolor": "white",
"plot_bgcolor": "white",
"polar": {
"angularaxis": {
"gridcolor": "rgb(232,232,232)",
"linecolor": "rgb(36,36,36)",
"showgrid": false,
"showline": true,
"ticks": "outside"
},
"bgcolor": "white",
"radialaxis": {
"gridcolor": "rgb(232,232,232)",
"linecolor": "rgb(36,36,36)",
"showgrid": false,
"showline": true,
"ticks": "outside"
}
},
"scene": {
"xaxis": {
"backgroundcolor": "white",
"gridcolor": "rgb(232,232,232)",
"gridwidth": 2,
"linecolor": "rgb(36,36,36)",
"showbackground": true,
"showgrid": false,
"showline": true,
"ticks": "outside",
"zeroline": false,
"zerolinecolor": "rgb(36,36,36)"
},
"yaxis": {
"backgroundcolor": "white",
"gridcolor": "rgb(232,232,232)",
"gridwidth": 2,
"linecolor": "rgb(36,36,36)",
"showbackground": true,
"showgrid": false,
"showline": true,
"ticks": "outside",
"zeroline": false,
"zerolinecolor": "rgb(36,36,36)"
},
"zaxis": {
"backgroundcolor": "white",
"gridcolor": "rgb(232,232,232)",
"gridwidth": 2,
"linecolor": "rgb(36,36,36)",
"showbackground": true,
"showgrid": false,
"showline": true,
"ticks": "outside",
"zeroline": false,
"zerolinecolor": "rgb(36,36,36)"
}
},
"shapedefaults": {
"fillcolor": "black",
"line": {
"width": 0
},
"opacity": 0.3
},
"ternary": {
"aaxis": {
"gridcolor": "rgb(232,232,232)",
"linecolor": "rgb(36,36,36)",
"showgrid": false,
"showline": true,
"ticks": "outside"
},
"baxis": {
"gridcolor": "rgb(232,232,232)",
"linecolor": "rgb(36,36,36)",
"showgrid": false,
"showline": true,
"ticks": "outside"
},
"bgcolor": "white",
"caxis": {
"gridcolor": "rgb(232,232,232)",
"linecolor": "rgb(36,36,36)",
"showgrid": false,
"showline": true,
"ticks": "outside"
}
},
"title": {
"x": 0.05
},
"xaxis": {
"automargin": true,
"gridcolor": "rgb(232,232,232)",
"linecolor": "rgb(36,36,36)",
"showgrid": false,
"showline": true,
"ticks": "outside",
"title": {
"standoff": 15
},
"zeroline": false,
"zerolinecolor": "rgb(36,36,36)"
},
"yaxis": {
"automargin": true,
"gridcolor": "rgb(232,232,232)",
"linecolor": "rgb(36,36,36)",
"showgrid": false,
"showline": true,
"ticks": "outside",
"title": {
"standoff": 15
},
"zeroline": false,
"zerolinecolor": "rgb(36,36,36)"
}
}
},
"margin": {
"l": 20,
"r": 20,
"t": 20,
"b": 20
},
"width": 650,
"height": 280
},
"config": {
"plotlyServerURL": "https://plot.ly"
}
}
},
"metadata": {},
"output_type": "display_data",
"jetTransient": {
"display_id": null
}
}
],
"execution_count": 31
},
{
"metadata": {
"ExecuteTime": {
"end_time": "2026-01-18T15:16:47.317313Z",
"start_time": "2026-01-18T15:16:47.310916Z"
}
},
"cell_type": "code",
"source": "",
"id": "61647538f9344b49",
"outputs": [],
"execution_count": null
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 5
}