Exceptions einheitlich

This commit is contained in:
2026-02-07 19:34:54 +01:00
parent 49d03786dc
commit 322ac94299
8 changed files with 153 additions and 250 deletions

View File

@@ -245,7 +245,7 @@ def gha1_ES(ell: EllipsoidTriaxial, beta0: float, omega0: float, alpha0: float,
P_all.append(P)
alpha_end.append(alpha)
if step > nsteps_est + 50:
raise RuntimeError("Zu viele Schritte vermutlich Konvergenzproblem / falsche Azimut-Konvention.")
raise RuntimeError("GHA1_ES: Zu viele Schritte vermutlich Konvergenzproblem / falsche Azimut-Konvention.")
Pk = P_all[-1]
alpha1 = float(alpha_end[-1])

View File

@@ -132,7 +132,7 @@ def gha1_ana(ell: EllipsoidTriaxial, point: NDArray, alpha0: float, s: float, ma
_, _, h = ell.cart2geod(point_end, "ligas3")
if h > 1e-5:
raise Exception("Analytische Methode ist explodiert, Punkt liegt nicht mehr auf dem Ellipsoid")
raise Exception("GHA1_ana: explodiert, Punkt liegt nicht mehr auf dem Ellipsoid")
return point_end, alpha_end

View File

@@ -20,6 +20,7 @@ def gha1_approx(ell: EllipsoidTriaxial, p0: np.ndarray, alpha0: float, s: float,
points = [p0]
alphas = [alpha0]
s_curr = 0.0
last_sigma = None
while s_curr < s:
ds_step = min(ds, s - s_curr)
@@ -30,6 +31,8 @@ def gha1_approx(ell: EllipsoidTriaxial, p0: np.ndarray, alpha0: float, s: float,
alpha1 = alphas[-1]
sigma = func_sigma_ell(ell, p1, alpha1)
if last_sigma is not None and np.linalg.norm(sigma - last_sigma) > 0.2:
raise Exception("GHA1_approx: Plötzlicher Richtungswechsel")
p2 = p1 + ds_step * sigma
p2 = ell.point_onto_ellipsoid(p2)
@@ -43,8 +46,8 @@ def gha1_approx(ell: EllipsoidTriaxial, p0: np.ndarray, alpha0: float, s: float,
ds_step = np.linalg.norm(p2 - p1)
s_curr += ds_step
if s_curr > 10000000:
pass
last_sigma = sigma
pass
if all_points:
return points[-1], alphas[-1], np.array(points), np.array(alphas)
@@ -79,10 +82,10 @@ def show_points(points: NDArray, p0: NDArray, p1: NDArray):
if __name__ == '__main__':
ell = EllipsoidTriaxial.init_name("BursaSima1980round")
P0 = ell.para2cart(0.2, 0.3)
alpha0 = wu.deg2rad(35)
s = 13000000
P0 = ell.ell2cart(wu.deg2rad(10), wu.deg2rad(1))
alpha0 = wu.deg2rad(2)
s = 100000
P1_app, alpha1_app, points, alphas = gha1_approx(ell, P0, alpha0, s, ds=10000, all_points=True)
P1_ana, alpha1_ana = gha1_ana(ell, P0, alpha0, s, maxM=60, maxPartCircum=16)
P1_ana, alpha1_ana = gha1_ana(ell, P0, alpha0, s, maxM=20, maxPartCircum=2)
show_points(points, P0, P1_ana)
print(np.linalg.norm(P1_app - P1_ana))

View File

@@ -78,6 +78,10 @@ def gha1_num(ell: EllipsoidTriaxial, point: NDArray, alpha0: float, s: float, nu
if alpha1 < 0:
alpha1 += 2 * np.pi
_, _, h = ell.cart2geod(point1, "ligas3")
if h > 1e-5:
raise Exception("GHA1_num: explodiert, Punkt liegt nicht mehr auf dem Ellipsoid")
if all_points:
return point1, alpha1, werte
else:

View File

@@ -109,7 +109,7 @@ def gha2_ES(ell: EllipsoidTriaxial, P0: NDArray, Pk: NDArray, maxSegLen: float =
startIter += 1
maxIter = 10000
if startIter > maxIter:
raise RuntimeError("Abbruch: maximale Iterationen überschritten.")
raise RuntimeError("GHA2_ES: maximale Iterationen überschritten")
new_points.append(B)
points = new_points

View File

@@ -282,7 +282,7 @@ def gha2_num(
if (best is None) or (s_quick < best[0]):
best = (s_quick, sol)
if best is None:
raise RuntimeError("Keine Startwert-Variante konvergiert (lambda-Fall).")
raise RuntimeError("GHA2_num: Keine Startwert-Variante konvergiert (lambda-Fall)")
beta_p0_sol = best[1]
beta_p0 = float(beta_p0_sol)
@@ -362,7 +362,7 @@ def gha2_num(
break
if abs(Y3_end) < 1e-20:
raise RuntimeError("Abbruch (Ableitung ~ 0) im beta-Fall.")
raise RuntimeError("GHA2_num: Ableitung ~ 0 im beta-Fall")
step = delta / Y3_end
step = np.clip(step, -1.0, 1.0)