Umrechnungs-Test, Tabellen

This commit is contained in:
2026-01-18 22:29:29 +01:00
parent 07212dcc97
commit aa7175c3c4
5 changed files with 5539 additions and 97 deletions

View File

@@ -72,33 +72,33 @@ table3 = [
wu.gms2rad([0, -1, 27.9705]), wu.gms2rad([0, 0, 16.0490]), 8888783.7815)
]
table4 = [
(wu.deg2rad(0), wu.deg2rad(0), wu.deg2rad(0), wu.deg2rad(90), 1.00000000000,
wu.gms2rad([90, 0, 0.0000]), wu.gms2rad([90, 0, 0.0000]), 10018754.1714),
# table4 = [
# (wu.deg2rad(0), wu.deg2rad(0), wu.deg2rad(0), wu.deg2rad(90), 1.00000000000,
# wu.gms2rad([90, 0, 0.0000]), wu.gms2rad([90, 0, 0.0000]), 10018754.1714),
#
# (wu.deg2rad(1), wu.deg2rad(0), wu.deg2rad(0), wu.deg2rad(179.5), 0.30320665822,
# wu.gms2rad([17, 39, 11.0942]), wu.gms2rad([162, 20, 58.9032]), 19884417.8083),
#
# (wu.deg2rad(5), wu.deg2rad(0), wu.deg2rad(-80), wu.deg2rad(170), 0.03104258442,
# wu.gms2rad([178, 12, 51.5083]), wu.gms2rad([10, 17, 52.6423]), 11652530.7514),
#
# (wu.deg2rad(30), wu.deg2rad(0), wu.deg2rad(-75), wu.deg2rad(120), 0.24135347134,
# wu.gms2rad([163, 49, 4.4615]), wu.gms2rad([68, 49, 50.9617]), 14057886.8752),
#
# (wu.deg2rad(60), wu.deg2rad(0), wu.deg2rad(-60), wu.deg2rad(40), 0.19408499032,
# wu.gms2rad([157, 9, 33.5589]), wu.gms2rad([157, 9, 33.5589]), 13767414.8267),
#
# (wu.deg2rad(75), wu.deg2rad(0), wu.deg2rad(-30), wu.deg2rad(0.5), 0.00202789418,
# wu.gms2rad([179, 33, 3.8613]), wu.gms2rad([179, 51, 57.0077]), 11661713.4496),
#
# (wu.deg2rad(80), wu.deg2rad(0), wu.deg2rad(-5), wu.deg2rad(120), 0.15201222384,
# wu.gms2rad([61, 5, 33.9600]), wu.gms2rad([171, 13, 22.0148]), 11105138.2902),
#
# (wu.deg2rad(0), wu.deg2rad(0), wu.deg2rad(60), wu.deg2rad(0), 0.00000000000,
# wu.gms2rad([0, 0, 0.0000]), wu.gms2rad([0, 0, 0.0000]), 6663348.2060)
# ]
(wu.deg2rad(1), wu.deg2rad(0), wu.deg2rad(0), wu.deg2rad(179.5), 0.30320665822,
wu.gms2rad([17, 39, 11.0942]), wu.gms2rad([162, 20, 58.9032]), 19884417.8083),
(wu.deg2rad(5), wu.deg2rad(0), wu.deg2rad(-80), wu.deg2rad(170), 0.03104258442,
wu.gms2rad([178, 12, 51.5083]), wu.gms2rad([10, 17, 52.6423]), 11652530.7514),
(wu.deg2rad(30), wu.deg2rad(0), wu.deg2rad(-75), wu.deg2rad(120), 0.24135347134,
wu.gms2rad([163, 49, 4.4615]), wu.gms2rad([68, 49, 50.9617]), 14057886.8752),
(wu.deg2rad(60), wu.deg2rad(0), wu.deg2rad(-60), wu.deg2rad(40), 0.19408499032,
wu.gms2rad([157, 9, 33.5589]), wu.gms2rad([157, 9, 33.5589]), 13767414.8267),
(wu.deg2rad(75), wu.deg2rad(0), wu.deg2rad(-30), wu.deg2rad(0.5), 0.00202789418,
wu.gms2rad([179, 33, 3.8613]), wu.gms2rad([179, 51, 57.0077]), 11661713.4496),
(wu.deg2rad(80), wu.deg2rad(0), wu.deg2rad(-5), wu.deg2rad(120), 0.15201222384,
wu.gms2rad([61, 5, 33.9600]), wu.gms2rad([171, 13, 22.0148]), 11105138.2902),
(wu.deg2rad(0), wu.deg2rad(0), wu.deg2rad(60), wu.deg2rad(0), 0.00000000000,
wu.gms2rad([0, 0, 0.0000]), wu.gms2rad([0, 0, 0.0000]), 6663348.2060)
]
tables = [table1, table2, table3, table4]
tables = [table1, table2, table3]
def get_example(table: int, example: int) -> Tuple:
"""
@@ -110,18 +110,25 @@ def get_example(table: int, example: int) -> Tuple:
table -= 1
example -= 1
tables = get_tables()
return tables[table][example]
beta0, lamb0, beta1, lamb1, _, alpha0_ell, alpha1_ell, s = tables[table][example]
return beta0, lamb0, alpha0_ell, beta1, lamb1, alpha1_ell, s
def get_tables() -> List:
"""
Rückgabe aller Tabellen
:return: Alle Tabellen
"""
return tables
sorted_tables = []
for table in tables:
sorted_tables.append([])
for example in table:
beta0, lamb0, beta1, lamb1, _, alpha0_ell, alpha1_ell, s = example
sorted_tables[-1].append((beta0, lamb0, alpha0_ell, beta1, lamb1, alpha1_ell, s))
return sorted_tables
def get_random_examples(num: int, seed: int = None) -> List:
"""
Rückgabe zufäliger Beispiele
Rückgabe zufälliger Beispiele
:param num: Anzahl Beispiele
:param seed: Random-Seed
:return:
@@ -131,7 +138,7 @@ def get_random_examples(num: int, seed: int = None) -> List:
examples = []
for i in range(num):
table = random.randint(1, 4)
table = random.randint(1, 3)
if table == 4:
example = random.randint(1, 8)
else:

4086
algorithms_test.ipynb Normal file

File diff suppressed because it is too large Load Diff

1214
conversions_test.ipynb Normal file

File diff suppressed because it is too large Load Diff

106
conversions_test.py Normal file
View File

@@ -0,0 +1,106 @@
import time
import pickle
import numpy as np
from numpy import nan
import winkelumrechnungen as wu
import os
from contextlib import contextmanager, redirect_stdout, redirect_stderr
from itertools import product
import pandas as pd
from ellipsoide import EllipsoidTriaxial
# ellips = "KarneyTest2024"
# ellips = "BursaSima1980"
ellips = "Fiction"
ell: EllipsoidTriaxial = EllipsoidTriaxial.init_name(ellips)
def deg_range(start, stop, step):
return [float(x) for x in range(start, stop + step, step)]
def asymptotic_range(start, direction="up", max_decimals=4):
values = []
for d in range(0, max_decimals + 1):
step = 10 ** -d
if direction == "up":
values.append(start + (1 - step))
else:
values.append(start - (1 - step))
return values
beta_5_85 = deg_range(5, 85, 5)
lambda_5_85 = deg_range(5, 85, 5)
beta_5_90 = deg_range(5, 90, 5)
lambda_5_90 = deg_range(5, 90, 5)
beta_0_90 = deg_range(0, 90, 5)
lambda_0_90 = deg_range(0, 90, 5)
beta_90 = [90.0]
lambda_90 = [90.0]
beta_0 = [0.0]
lambda_0 = [0.0]
beta_asym_89 = asymptotic_range(89.0, direction="up")
lambda_asym_0 = asymptotic_range(1.0, direction="down")
groups = {
1: list(product(beta_5_85, lambda_5_85)),
# 2: list(product(beta_0, lambda_0_90)),
# 3: list(product(beta_5_85, lambda_0)),
# 4: list(product(beta_90, lambda_5_90)),
# 5: list(product(beta_asym_89, lambda_asym_0)),
# 6: list(product(beta_5_85, lambda_90)),
7: list(product(lambda_asym_0, lambda_0_90)),
# 8: list(product(beta_0_90, lambda_asym_0)),
# 9: list(product(beta_asym_89, lambda_0_90)),
# 10: list(product(beta_0_90, beta_asym_89)),
}
for nr, points in groups.items():
points_cart = []
for point in points:
beta, lamb = point
cart = ell.ell2cart(wu.deg2rad(beta), wu.deg2rad(lamb))
points_cart.append(cart)
groups[nr] = points_cart
results = {}
for nr, points in groups.items():
group_results = {"ell": [],
"para": [],
"geod": []}
for point in points:
elli = ell.cart2ell(point)
cart_elli = ell.ell2cart(elli[0], elli[1])
group_results["ell"].append(np.linalg.norm(point - cart_elli, axis=-1))
para = ell.cart2para(point)
cart_para = ell.para2cart(para[0], para[1])
group_results["para"].append(np.linalg.norm(point - cart_para, axis=-1))
geod = ell.cart2geod(point, "ligas3")
cart_geod = ell.geod2cart(geod[0], geod[1], geod[2])
group_results["geod"].append(np.linalg.norm(point - cart_geod, axis=-1))
group_results["ell"] = np.array(group_results["ell"])
group_results["para"] = np.array(group_results["para"])
group_results["geod"] = np.array(group_results["geod"])
results[nr] = group_results
with open(f"conversion_results_{ellips}.pkl", "wb") as f:
pickle.dump(results, f)
df = pd.DataFrame({
"Gruppe": [nr for nr in results.keys()],
"max_Δr_ell": [f"{max(result["ell"]):.3g}" for result in results.values()],
"max_Δr_para": [f"{max(result["para"]):.3g}" for result in results.values()],
"max_Δr_geod": [f"{max(result["geod"]):.3g}" for result in results.values()]
})
print(df)

View File

@@ -5,6 +5,7 @@ import jacobian_Ligas
import matplotlib.pyplot as plt
from typing import Tuple
from numpy.typing import NDArray
import math
class EllipsoidBiaxial:
@@ -199,6 +200,9 @@ class EllipsoidTriaxial:
c0 = (self.ax ** 2 * self.ay ** 2 + self.ax ** 2 * self.b ** 2 + self.ay ** 2 * self.b ** 2 -
(self.ay ** 2 + self.b ** 2) * x ** 2 - (self.ax ** 2 + self.b ** 2) * y ** 2 - (
self.ax ** 2 + self.ay ** 2) * z ** 2)
if c1 ** 2 - 4 * c0 < 0:
t2 = np.nan
else:
t2 = (-c1 + sqrt(c1 ** 2 - 4 * c0)) / 2
if t2 == 0:
t2 = 1e-18
@@ -316,32 +320,23 @@ class EllipsoidTriaxial:
Z = self.b * sin(beta) * sqrt(k**2 + k_**2 * sin(lamb)**2)
return np.array([X, Y, Z])
def cart2ell(self, point: NDArray, eps: float = 1e-12, maxI: int = 100) -> Tuple[float, float]:
def cart2ell_yFake(self, point: NDArray, start_delta) -> Tuple[float, float]:
"""
Panou, Korakitis 2019 3f. (num)
:param point: Punkt in kartesischen Koordinaten
:param eps: zu erreichende Genauigkeit
:param maxI: maximale Anzahl Iterationen
:return: elliptische Breite und Länge [rad]
:param point:
:return:
"""
x, y, z = point
beta, lamb = self.cart2ell_panou(point)
delta_ell = np.array([np.inf, np.inf]).T
tiny = 1e-30
i = 0
while np.linalg.norm(delta_ell) > eps and i < maxI:
if abs(y) < eps:
delta_y = 1e-4
best_delta = np.inf
while True:
try:
y1 = y - delta_y
beta1, lamb1 = self.cart2ell(np.array([x, y1, z]))
beta1, lamb1 = self.cart2ell(np.array([x, y1, z]), noFake=True)
point1 = self.ell2cart(beta1, lamb1)
y2 = y + delta_y
beta2, lamb2 = self.cart2ell(np.array([x, y2, z]))
beta2, lamb2 = self.cart2ell(np.array([x, y2, z]), noFake=True)
point2 = self.ell2cart(beta2, lamb2)
pointM = (point1 + point2) / 2
@@ -357,10 +352,27 @@ class EllipsoidTriaxial:
delta_y *= 10
y1 = y - delta_y
beta1, lamb1 = self.cart2ell(np.array([x, y1, z]))
beta1, lamb1 = self.cart2ell(np.array([x, y1, z]), noFake=True)
return beta1, lamb1
def cart2ell(self, point: NDArray, eps: float = 1e-12, maxI: int = 100, noFake: bool = False) -> Tuple[float, float]:
"""
Panou, Korakitis 2019 3f. (num)
:param point: Punkt in kartesischen Koordinaten
:param eps: zu erreichende Genauigkeit
:param maxI: maximale Anzahl Iterationen
:param noFake:
:return: elliptische Breite und Länge [rad]
"""
x, y, z = point
beta, lamb = self.cart2ell_panou(point)
delta_ell = np.array([np.inf, np.inf]).T
tiny = 1e-30
try:
i = 0
while np.linalg.norm(delta_ell) > eps and i < maxI:
x0, y0, z0 = self.ell2cart(beta, lamb)
delta_l = np.array([x-x0, y-y0, z-z0]).T
@@ -378,6 +390,7 @@ class EllipsoidTriaxial:
det = N[0, 0] * N[1, 1] - N[0, 1] * N[1, 0]
N_inv = 1 / det * np.array([[N[1, 1], -N[0, 1]], [-N[1, 0], N[0, 0]]])
delta_ell = N_inv @ J.T @ delta_l
# delta_ell, *_ = np.linalg.lstsq(J, delta_l, rcond=None)
beta += delta_ell[0]
lamb += delta_ell[1]
@@ -388,12 +401,18 @@ class EllipsoidTriaxial:
point_n = self.ell2cart(beta, lamb)
delta_r = np.linalg.norm(point - point_n, axis=-1)
if delta_r > 1e-3:
if delta_r > 1e-6:
raise Exception("Fehler in der Umrechnung cart2ell")
return beta, lamb
except Exception as e:
delta_y = 10 ** math.floor(math.log10(abs(self.ay/1000)))
if abs(y) < delta_y and not noFake:
return self.cart2ell_yFake(point, delta_y)
else:
raise e
def cart2ell_panou(self, point: NDArray) -> Tuple[float, float]:
"""
Panou, Korakitis 2019 2f. (analytisch -> Näherung)
@@ -548,10 +567,20 @@ class EllipsoidTriaxial:
pE = pEi
i += 1
if i == maxIter and loa > maxLoa:
act_mode = int(mode[-1])
new_mode = 3 if act_mode == 1 else act_mode - 1
phi, lamb, h = self.cart2geod(point, f"ligas{new_mode}", maxIter, maxLoa)
else:
phi = arctan((1-self.ee**2) / (1-self.ex**2) * pE[2] / sqrt((1-self.ee**2)**2 * pE[0]**2 + pE[1]**2))
lamb = arctan(1/(1-self.ee**2) * pE[1]/pE[0])
h = np.sign(zG - pE[2]) * np.sign(pE[2]) * sqrt((pE[0] - xG) ** 2 + (pE[1] - yG) ** 2 + (pE[2] - zG) ** 2)
if h < -self.ax:
act_mode = int(mode[-1])
new_mode = 3 if act_mode == 1 else act_mode - 1
phi, lamb, h = self.cart2geod(point, f"ligas{new_mode}", maxIter, maxLoa)
else:
if xG < 0 and yG < 0:
lamb = -pi + lamb