From ee85e8b0e6923af3da081e207b6086eb72883f3f Mon Sep 17 00:00:00 2001 From: Hendrik Date: Sun, 8 Feb 2026 16:28:59 +0100 Subject: [PATCH] . --- GHA_triaxial/gha1_approx.py | 19 +- GHA_triaxial/utils.py | 32 +- Tests/algorithms_test.ipynb | 807 ++++++++++++++++++++++++++---------- 3 files changed, 611 insertions(+), 247 deletions(-) diff --git a/GHA_triaxial/gha1_approx.py b/GHA_triaxial/gha1_approx.py index b28f4d9..a15878d 100644 --- a/GHA_triaxial/gha1_approx.py +++ b/GHA_triaxial/gha1_approx.py @@ -21,6 +21,7 @@ def gha1_approx(ell: EllipsoidTriaxial, p0: np.ndarray, alpha0: float, s: float, alphas = [alpha0] s_curr = 0.0 last_sigma = None + last_p = None while s_curr < s: ds_step = min(ds, s - s_curr) @@ -30,9 +31,13 @@ def gha1_approx(ell: EllipsoidTriaxial, p0: np.ndarray, alpha0: float, s: float, p1 = points[-1] 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") + p, q = pq_ell(ell, p1) + if last_p is not None and np.dot(p, last_p) < 0: + p = -p + q = -q + sigma = p * sin(alpha1) + q * cos(alpha1) + if last_sigma is not None and np.dot(sigma, last_sigma) < 0: + sigma = -sigma p2 = p1 + ds_step * sigma p2 = ell.point_onto_ellipsoid(p2) @@ -82,10 +87,10 @@ def show_points(points: NDArray, p0: NDArray, p1: NDArray): if __name__ == '__main__': ell = EllipsoidTriaxial.init_name("BursaSima1980round") - P0 = ell.ell2cart(wu.deg2rad(10), wu.deg2rad(1)) + P0 = ell.ell2cart(wu.deg2rad(89), 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) + s = 200000 + P1_app, alpha1_app, points, alphas = gha1_approx(ell, P0, alpha0, s, ds=100, all_points=True) 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)) + show_points(points, P0, P1_ana) diff --git a/GHA_triaxial/utils.py b/GHA_triaxial/utils.py index bf0dfaf..6bfc5c0 100644 --- a/GHA_triaxial/utils.py +++ b/GHA_triaxial/utils.py @@ -128,21 +128,27 @@ def pq_ell(ell: EllipsoidTriaxial, point: NDArray) -> Tuple[NDArray, NDArray]: n = ell.func_n(point) beta, lamb = ell.cart2ell(point) - B = ell.Ex ** 2 * cos(beta) ** 2 + ell.Ee ** 2 * sin(beta) ** 2 - L = ell.Ex ** 2 - ell.Ee ** 2 * cos(lamb) ** 2 + if abs(cos(beta)) < 1e-12 and abs(np.sin(lamb)) < 1e-12: + if beta > 0: + p = np.array([0, -1, 0]) + else: + p = np.array([0, 1, 0]) + else: + B = ell.Ex ** 2 * cos(beta) ** 2 + ell.Ee ** 2 * sin(beta) ** 2 + L = ell.Ex ** 2 - ell.Ee ** 2 * cos(lamb) ** 2 - c1 = x ** 2 + y ** 2 + z ** 2 - (ell.ax ** 2 + ell.ay ** 2 + ell.b ** 2) - c0 = (ell.ax ** 2 * ell.ay ** 2 + ell.ax ** 2 * ell.b ** 2 + ell.ay ** 2 * ell.b ** 2 - - (ell.ay ** 2 + ell.b ** 2) * x ** 2 - (ell.ax ** 2 + ell.b ** 2) * y ** 2 - ( - ell.ax ** 2 + ell.ay ** 2) * z ** 2) - t2 = (-c1 + sqrt(c1 ** 2 - 4 * c0)) / 2 + c1 = x ** 2 + y ** 2 + z ** 2 - (ell.ax ** 2 + ell.ay ** 2 + ell.b ** 2) + c0 = (ell.ax ** 2 * ell.ay ** 2 + ell.ax ** 2 * ell.b ** 2 + ell.ay ** 2 * ell.b ** 2 - + (ell.ay ** 2 + ell.b ** 2) * x ** 2 - (ell.ax ** 2 + ell.b ** 2) * y ** 2 - ( + ell.ax ** 2 + ell.ay ** 2) * z ** 2) + t2 = (-c1 + sqrt(c1 ** 2 - 4 * c0)) / 2 - F = ell.Ey ** 2 * cos(beta) ** 2 + ell.Ee ** 2 * sin(lamb) ** 2 - p1 = -sqrt(L / (F * t2)) * ell.ax / ell.Ex * sqrt(B) * sin(lamb) - p2 = sqrt(L / (F * t2)) * ell.ay * cos(beta) * cos(lamb) - p3 = 1 / sqrt(F * t2) * (ell.b * ell.Ee ** 2) / (2 * ell.Ex) * sin(beta) * sin(2 * lamb) - p = np.array([p1, p2, p3]) - p = p / np.linalg.norm(p) + F = ell.Ey ** 2 * cos(beta) ** 2 + ell.Ee ** 2 * sin(lamb) ** 2 + p1 = -sqrt(L / (F * t2)) * ell.ax / ell.Ex * sqrt(B) * sin(lamb) + p2 = sqrt(L / (F * t2)) * ell.ay * cos(beta) * cos(lamb) + p3 = 1 / sqrt(F * t2) * (ell.b * ell.Ee ** 2) / (2 * ell.Ex) * sin(beta) * sin(2 * lamb) + p = np.array([p1, p2, p3]) + p = p / np.linalg.norm(p) q = np.array([n[1] * p[2] - n[2] * p[1], n[2] * p[0] - n[0] * p[2], n[0] * p[1] - n[1] * p[0]]) diff --git a/Tests/algorithms_test.ipynb b/Tests/algorithms_test.ipynb index 78983f5..c15f166 100644 --- a/Tests/algorithms_test.ipynb +++ b/Tests/algorithms_test.ipynb @@ -3,8 +3,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2026-02-07T20:59:57.191051Z", - "start_time": "2026-02-07T20:59:56.829377Z" + "end_time": "2026-02-08T14:37:43.639183Z", + "start_time": "2026-02-08T14:37:41.363837Z" } }, "cell_type": "code", @@ -14,13 +14,13 @@ ], "id": "89aa93e9dbedd113", "outputs": [], - "execution_count": 2 + "execution_count": 1 }, { "metadata": { "ExecuteTime": { - "end_time": "2026-02-07T20:59:59.176074Z", - "start_time": "2026-02-07T20:59:57.791116Z" + "end_time": "2026-02-08T14:37:44.991629Z", + "start_time": "2026-02-08T14:37:43.654255Z" } }, "cell_type": "code", @@ -56,13 +56,13 @@ ], "id": "2005e5a8854eea1e", "outputs": [], - "execution_count": 3 + "execution_count": 2 }, { "metadata": { "ExecuteTime": { - "end_time": "2026-02-07T21:00:00.433740Z", - "start_time": "2026-02-07T21:00:00.217286Z" + "end_time": "2026-02-08T09:56:48.946285Z", + "start_time": "2026-02-08T09:56:48.479496Z" } }, "cell_type": "code", @@ -75,20 +75,20 @@ ], "id": "90f107a11ff0de7e", "outputs": [], - "execution_count": 4 + "execution_count": 3 }, { "metadata": { "ExecuteTime": { - "end_time": "2026-02-07T17:01:54.558895Z", - "start_time": "2026-02-07T17:01:54.016235Z" + "end_time": "2026-02-07T21:21:03.628386Z", + "start_time": "2026-02-07T21:21:03.410822Z" } }, "cell_type": "code", "source": [ "# dsPart = [60, 125, 600, 1250, 6000, 60000] entspricht bei der Erde ca. 100km, 50km, 10km, 5km, 1km, 100m\n", "\n", - "steps_gha1_num = [200, 500, 1000, 5000, 10000]\n", + "steps_gha1_num = [200, 500, 1000, 5000, 10000, 20000, 50000]\n", "maxM_gha1_ana = [20, 50, 80]\n", "parts_gha1_ana = [2, 8, 32]\n", "dsPart_gha1_ES = [60, 600, 1250]\n", @@ -100,13 +100,13 @@ ], "id": "fc6c39b8d358e54b", "outputs": [], - "execution_count": 14 + "execution_count": 7 }, { "metadata": { "ExecuteTime": { - "end_time": "2026-02-07T21:00:07.365335Z", - "start_time": "2026-02-07T21:00:07.174675Z" + "end_time": "2026-02-07T21:22:30.400129Z", + "start_time": "2026-02-07T21:22:30.193713Z" } }, "cell_type": "code", @@ -118,7 +118,7 @@ "def build_examples(test):\n", " if test == \"Karney\":\n", " ell: EllipsoidTriaxial = EllipsoidTriaxial.init_name(\"KarneyTest2024\")\n", - " examples = get_examples_karney(4, seed=42)\n", + " examples = get_examples_karney(20, seed=42)\n", " elif test == \"Panou\":\n", " ell: EllipsoidTriaxial = EllipsoidTriaxial.init_name(\"BursaSima1980round\")\n", " tables = get_tables_panou()\n", @@ -128,6 +128,7 @@ " for example in table:\n", " table_indices.append(i+1)\n", " examples.append(example)\n", + " examples = examples[:14]\n", " elif test == \"Random\":\n", " ell: EllipsoidTriaxial = EllipsoidTriaxial.init_name(\"BursaSima1980round\")\n", " examples = []\n", @@ -139,18 +140,23 @@ " s = random.randint(10000, int(np.pi*ell.b))\n", " examples.append([beta0, lamb0, alpha0_ell, s])\n", " pass\n", - " return examples\n", - "examples = build_examples(test)" + " return ell, examples\n", + "# ell, examples = build_examples(test)" ], "id": "6770dbd57d475127", "outputs": [], - "execution_count": 5 + "execution_count": 15 }, { - "metadata": {}, + "metadata": { + "ExecuteTime": { + "end_time": "2026-02-07T21:22:03.254266Z", + "start_time": "2026-02-07T21:22:03.046527Z" + } + }, "cell_type": "code", "source": [ - "def execute_results(test, examples):\n", + "def execute_results(test, ell, examples):\n", " results = {}\n", " for i, example in enumerate(examples):\n", " print(f\"----- Beispiel {i+1}/{len(examples)}\")\n", @@ -186,7 +192,6 @@ " start = time.perf_counter()\n", " try:\n", " P1_num, alpha1_num_1 = gha1_num(ell, P0, alpha0_ell, s, num=steps)\n", - " print(f\"GHA1_num_{steps}\", P1_num)\n", " end = time.perf_counter()\n", " beta1_num, lamb1_num = ell.cart2ell(P1_num)\n", " d_beta1 = abs(beta1_num - beta1)\n", @@ -198,126 +203,131 @@ " print(e)\n", " example_results[f\"GHA1_num_{steps}\"] = (nan, nan, nan, nan)\n", "\n", - " for maxM in maxM_gha1_ana:\n", - " for parts in parts_gha1_ana:\n", - " start = time.perf_counter()\n", - " try:\n", - " P1_ana, alpha1_ana_para = gha1_ana(ell, P0, alpha0_para, s, maxM=maxM, maxPartCircum=parts)\n", - " end = time.perf_counter()\n", - " beta1_ana, lamb1_ana = ell.cart2ell(P1_ana)\n", - " u1_ana, v1_ana = ell.cart2para(P1_ana)\n", - " _, _, alpha1_ana_ell = alpha_para2ell(ell, u1_ana, v1_ana, alpha1_ana_para)\n", - " d_beta1 = abs(beta1_ana - beta1)\n", - " d_lamb1 = abs(lamb1_ana - lamb1)\n", - " d_alpha1 = abs(alpha1_ana_ell - alpha1_ell)\n", - " d_time = end - start\n", - " example_results[f\"GHA1_ana_{maxM}_{parts}\"] = (d_beta1, d_lamb1, d_alpha1, d_time)\n", - " except Exception as e:\n", - " print(e)\n", - " example_results[f\"GHA1_ana_{maxM}_{parts}\"] = (nan, nan, nan, nan)\n", - "\n", - " for dsPart in dsPart_gha1_ES:\n", - " ds = ell.ax/dsPart\n", - " start = time.perf_counter()\n", - " try:\n", - " P1_ES, alpha1_ES = gha1_ES(ell, beta0, lamb0, alpha0_ell, s, maxSegLen=ds)\n", - " end = time.perf_counter()\n", - " beta1_ES, lamb1_ES = ell.cart2ell(P1_ES)\n", - " d_beta1 = abs(beta1_ES - beta1)\n", - " d_lamb1 = abs(lamb1_ES - lamb1)\n", - " d_alpha1 = abs(alpha1_ES - alpha1_ell)\n", - " d_time = end - start\n", - " example_results[f\"GHA1_ES_{dsPart}\"] = (d_beta1, d_lamb1, d_alpha1, d_time)\n", - " except Exception as e:\n", - " print(e)\n", - " example_results[f\"GHA1_ES_{dsPart}\"] = (nan, nan, nan, nan)\n", - "\n", - " for dsPart in dsPart_gha1_approx:\n", - " ds = ell.ax/dsPart\n", - " start = time.perf_counter()\n", - " try:\n", - " P1_approx, alpha1_approx = gha1_approx(ell, P0, alpha0_ell, s, ds=ds)\n", - " end = time.perf_counter()\n", - " beta1_approx, lamb1_approx = ell.cart2ell(P1_approx)\n", - " d_beta1 = abs(beta1_approx - beta1)\n", - " d_lamb1 = abs(lamb1_approx - lamb1)\n", - " d_alpha1 = abs(alpha1_approx - alpha1_ell)\n", - " d_time = end - start\n", - " example_results[f\"GHA1_approx_{dsPart}\"] = (d_beta1, d_lamb1, d_alpha1, d_time)\n", - " except Exception as e:\n", - " print(e)\n", - " example_results[f\"GHA1_approx_{dsPart}\"] = (nan, nan, nan, nan)\n", - "\n", - " # ----------------------------------------------\n", - "\n", - " for steps in steps_gha2_num:\n", - " start = time.perf_counter()\n", - " try:\n", - " with warnings.catch_warnings():\n", - " warnings.simplefilter(\"ignore\", RuntimeWarning)\n", - " alpha0_num, alpha1_num_2, s_num = gha2_num(ell, beta0, lamb0, beta1, lamb1, n=steps)\n", - " print(alpha0_num, alpha1_num_2, s_num)\n", - " end = time.perf_counter()\n", - " d_alpha0 = abs(alpha0_num - alpha0_ell)\n", - " d_alpha1 = abs(alpha1_num_2 - alpha1_ell)\n", - " d_s = abs(s_num - s)\n", - " d_time = end - start\n", - " example_results[f\"GHA2_num_{steps}\"] = (d_alpha0, d_alpha1, d_s, d_time)\n", - " except Exception as e:\n", - " print(e)\n", - " example_results[f\"GHA2_num_{steps}\"] = (nan, nan, nan, nan)\n", - "\n", - " for dsPart in dsPart_gha2_ES:\n", - " ds = ell.ax/dsPart\n", - " start = time.perf_counter()\n", - " try:\n", - " with suppress_print():\n", - " alpha0_ES, alpha1_ES, s_ES = gha2_ES(ell, P0, P1, maxSegLen=ds)\n", - " end = time.perf_counter()\n", - " d_alpha0 = abs(alpha0_ES - alpha0_ell)\n", - " d_alpha1 = abs(alpha1_ES - alpha1_ell)\n", - " d_s = abs(s_ES - s)\n", - " d_time = end - start\n", - " example_results[f\"GHA2_ES_{dsPart}\"] = (d_alpha0, d_alpha1, d_s, d_time)\n", - " except Exception as e:\n", - " print(e)\n", - " example_results[f\"GHA2_ES_{dsPart}\"] = (nan, nan, nan, nan)\n", - "\n", - " for dsPart in dsPart_gha2_approx:\n", - " ds = ell.ax/dsPart\n", - " start = time.perf_counter()\n", - " try:\n", - " alpha0_approx, alpha1_approx, s_approx = gha2_approx(ell, P0, P1, ds=ds)\n", - " end = time.perf_counter()\n", - " d_alpha0 = abs(alpha0_approx - alpha0_ell)\n", - " d_alpha1 = abs(alpha1_approx - alpha1_ell)\n", - " d_s = abs(s_approx - s)\n", - " d_time = end - start\n", - " example_results[f\"GHA2_approx_{dsPart}\"] = (d_alpha0, d_alpha1, d_s, d_time)\n", - " except Exception as e:\n", - " print(e)\n", - " example_results[f\"GHA2_approx_{dsPart}\"] = (nan, nan, nan, nan)\n", + " # for maxM in maxM_gha1_ana:\n", + " # for parts in parts_gha1_ana:\n", + " # start = time.perf_counter()\n", + " # try:\n", + " # P1_ana, alpha1_ana_para = gha1_ana(ell, P0, alpha0_para, s, maxM=maxM, maxPartCircum=parts)\n", + " # end = time.perf_counter()\n", + " # beta1_ana, lamb1_ana = ell.cart2ell(P1_ana)\n", + " # u1_ana, v1_ana = ell.cart2para(P1_ana)\n", + " # _, _, alpha1_ana_ell = alpha_para2ell(ell, u1_ana, v1_ana, alpha1_ana_para)\n", + " # d_beta1 = abs(beta1_ana - beta1)\n", + " # d_lamb1 = abs(lamb1_ana - lamb1)\n", + " # d_alpha1 = abs(alpha1_ana_ell - alpha1_ell)\n", + " # d_time = end - start\n", + " # example_results[f\"GHA1_ana_{maxM}_{parts}\"] = (d_beta1, d_lamb1, d_alpha1, d_time)\n", + " # except Exception as e:\n", + " # print(e)\n", + " # example_results[f\"GHA1_ana_{maxM}_{parts}\"] = (nan, nan, nan, nan)\n", + " #\n", + " # for dsPart in dsPart_gha1_ES:\n", + " # ds = ell.ax/dsPart\n", + " # start = time.perf_counter()\n", + " # try:\n", + " # P1_ES, alpha1_ES = gha1_ES(ell, beta0, lamb0, alpha0_ell, s, maxSegLen=ds)\n", + " # end = time.perf_counter()\n", + " # beta1_ES, lamb1_ES = ell.cart2ell(P1_ES)\n", + " # d_beta1 = abs(beta1_ES - beta1)\n", + " # d_lamb1 = abs(lamb1_ES - lamb1)\n", + " # d_alpha1 = abs(alpha1_ES - alpha1_ell)\n", + " # d_time = end - start\n", + " # example_results[f\"GHA1_ES_{dsPart}\"] = (d_beta1, d_lamb1, d_alpha1, d_time)\n", + " # except Exception as e:\n", + " # print(e)\n", + " # example_results[f\"GHA1_ES_{dsPart}\"] = (nan, nan, nan, nan)\n", + " #\n", + " # for dsPart in dsPart_gha1_approx:\n", + " # ds = ell.ax/dsPart\n", + " # start = time.perf_counter()\n", + " # try:\n", + " # P1_approx, alpha1_approx = gha1_approx(ell, P0, alpha0_ell, s, ds=ds)\n", + " # end = time.perf_counter()\n", + " # beta1_approx, lamb1_approx = ell.cart2ell(P1_approx)\n", + " # d_beta1 = abs(beta1_approx - beta1)\n", + " # d_lamb1 = abs(lamb1_approx - lamb1)\n", + " # d_alpha1 = abs(alpha1_approx - alpha1_ell)\n", + " # d_time = end - start\n", + " # example_results[f\"GHA1_approx_{dsPart}\"] = (d_beta1, d_lamb1, d_alpha1, d_time)\n", + " # except Exception as e:\n", + " # print(e)\n", + " # example_results[f\"GHA1_approx_{dsPart}\"] = (nan, nan, nan, nan)\n", + " #\n", + " # # ----------------------------------------------\n", + " #\n", + " # for steps in steps_gha2_num:\n", + " # start = time.perf_counter()\n", + " # try:\n", + " # with warnings.catch_warnings():\n", + " # warnings.simplefilter(\"ignore\", RuntimeWarning)\n", + " # alpha0_num, alpha1_num_2, s_num = gha2_num(ell, beta0, lamb0, beta1, lamb1, n=steps)\n", + " # print(alpha0_num, alpha1_num_2, s_num)\n", + " # end = time.perf_counter()\n", + " # d_alpha0 = abs(alpha0_num - alpha0_ell)\n", + " # d_alpha1 = abs(alpha1_num_2 - alpha1_ell)\n", + " # d_s = abs(s_num - s)\n", + " # d_time = end - start\n", + " # example_results[f\"GHA2_num_{steps}\"] = (d_alpha0, d_alpha1, d_s, d_time)\n", + " # except Exception as e:\n", + " # print(e)\n", + " # example_results[f\"GHA2_num_{steps}\"] = (nan, nan, nan, nan)\n", + " #\n", + " # for dsPart in dsPart_gha2_ES:\n", + " # ds = ell.ax/dsPart\n", + " # start = time.perf_counter()\n", + " # try:\n", + " # with suppress_print():\n", + " # alpha0_ES, alpha1_ES, s_ES = gha2_ES(ell, P0, P1, maxSegLen=ds)\n", + " # end = time.perf_counter()\n", + " # d_alpha0 = abs(alpha0_ES - alpha0_ell)\n", + " # d_alpha1 = abs(alpha1_ES - alpha1_ell)\n", + " # d_s = abs(s_ES - s)\n", + " # d_time = end - start\n", + " # example_results[f\"GHA2_ES_{dsPart}\"] = (d_alpha0, d_alpha1, d_s, d_time)\n", + " # except Exception as e:\n", + " # print(e)\n", + " # example_results[f\"GHA2_ES_{dsPart}\"] = (nan, nan, nan, nan)\n", + " #\n", + " # for dsPart in dsPart_gha2_approx:\n", + " # ds = ell.ax/dsPart\n", + " # start = time.perf_counter()\n", + " # try:\n", + " # alpha0_approx, alpha1_approx, s_approx = gha2_approx(ell, P0, P1, ds=ds)\n", + " # end = time.perf_counter()\n", + " # d_alpha0 = abs(alpha0_approx - alpha0_ell)\n", + " # d_alpha1 = abs(alpha1_approx - alpha1_ell)\n", + " # d_s = abs(s_approx - s)\n", + " # d_time = end - start\n", + " # example_results[f\"GHA2_approx_{dsPart}\"] = (d_alpha0, d_alpha1, d_s, d_time)\n", + " # except Exception as e:\n", + " # print(e)\n", + " # example_results[f\"GHA2_approx_{dsPart}\"] = (nan, nan, nan, nan)\n", "\n", " results[f\"beta0: {wu.rad2deg(beta0):.3f}, lamb0: {wu.rad2deg(lamb0):.3f}, alpha0: {wu.rad2deg(alpha0_ell):.3f}, s: {s}\"] = example_results\n", " return results\n", - "results = execute_results(test, examples)" + "# results = execute_results(test, ell, examples)" ], "id": "fc45e0f618a0e4d8", "outputs": [], - "execution_count": null + "execution_count": 12 }, { - "metadata": {}, + "metadata": { + "ExecuteTime": { + "end_time": "2026-02-07T21:22:06.184091Z", + "start_time": "2026-02-07T21:22:05.991850Z" + } + }, "cell_type": "code", - "outputs": [], - "execution_count": null, "source": [ "def save_results(test, results):\n", " with open(f\"gha_results{test}.pkl\", \"wb\") as f:\n", " pickle.dump(results, f)\n", "# save_results(test, results)" ], - "id": "74fbd4d33c288839" + "id": "74fbd4d33c288839", + "outputs": [], + "execution_count": 13 }, { "metadata": {}, @@ -326,24 +336,70 @@ "execution_count": null, "source": [ "test = \"Panou\"\n", - "examples_panou = build_examples(test)\n", - "results_panou = execute_results(test, examples_panou)\n", + "ell_panou, examples_panou = build_examples(test)\n", + "results_panou = execute_results(test, ell_panou, examples_panou)\n", "save_results(test, results_panou)" ], "id": "58697308664fa539" }, { - "metadata": {}, + "metadata": { + "ExecuteTime": { + "end_time": "2026-02-07T21:31:04.829637Z", + "start_time": "2026-02-07T21:29:14.982823Z" + } + }, "cell_type": "code", - "outputs": [], - "execution_count": null, "source": [ "test = \"Karney\"\n", - "examples_karney = build_examples(test)\n", - "results_karney = execute_results(test, examples_karney)\n", + "ell_karney, examples_karney = build_examples(test)\n", + "results_karney = execute_results(test, ell_karney, examples_karney)\n", "save_results(test, results_karney)" ], - "id": "5d35a01ba8d6e2b1" + "id": "5d35a01ba8d6e2b1", + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "----- Beispiel 1/20\n", + "----- Beispiel 2/20\n", + "----- Beispiel 3/20\n", + "----- Beispiel 4/20\n", + "----- Beispiel 5/20\n", + "----- Beispiel 6/20\n", + "----- Beispiel 7/20\n", + "----- Beispiel 8/20\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "C:\\Users\\moell\\OneDrive\\Desktop\\Vorlesungen\\Master-Projekt\\Python_Masterprojekt\\GHA_triaxial\\utils.py:138: RuntimeWarning: invalid value encountered in sqrt\n", + " t2 = (-c1 + sqrt(c1 ** 2 - 4 * c0)) / 2\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "----- Beispiel 9/20\n", + "----- Beispiel 10/20\n", + "----- Beispiel 11/20\n", + "----- Beispiel 12/20\n", + "----- Beispiel 13/20\n", + "----- Beispiel 14/20\n", + "----- Beispiel 15/20\n", + "----- Beispiel 16/20\n", + "----- Beispiel 17/20\n", + "----- Beispiel 18/20\n", + "----- Beispiel 19/20\n", + "----- Beispiel 20/20\n" + ] + } + ], + "execution_count": 20 }, { "metadata": {}, @@ -352,8 +408,8 @@ "execution_count": null, "source": [ "test = \"Random\"\n", - "examples_random = build_examples(test)\n", - "results_random = execute_results(test, examples_random)\n", + "ell_random, examples_random = build_examples(test)\n", + "results_random = execute_results(test, ell_random, examples_random)\n", "save_results(test, results_random)" ], "id": "848eab44283945c6" @@ -361,37 +417,82 @@ { "metadata": { "ExecuteTime": { - "end_time": "2026-02-07T21:00:12.376487Z", - "start_time": "2026-02-07T21:00:12.071794Z" + "end_time": "2026-02-08T15:00:05.614272Z", + "start_time": "2026-02-08T15:00:05.349014Z" } }, "cell_type": "code", - "source": [ - "with open(f\"gha_results{test}_all.pkl\", \"rb\") as f:\n", - " results = pickle.load(f)" - ], - "id": "4c20a0579c0f7038", - "outputs": [ - { - "ename": "FileNotFoundError", - "evalue": "[Errno 2] No such file or directory: 'gha_resultsKarney.pkl'", - "output_type": "error", - "traceback": [ - "\u001B[31m---------------------------------------------------------------------------\u001B[39m", - "\u001B[31mFileNotFoundError\u001B[39m Traceback (most recent call last)", - "\u001B[36mCell\u001B[39m\u001B[36m \u001B[39m\u001B[32mIn[6]\u001B[39m\u001B[32m, line 1\u001B[39m\n\u001B[32m----> \u001B[39m\u001B[32m1\u001B[39m \u001B[38;5;28;01mwith\u001B[39;00m \u001B[38;5;28;43mopen\u001B[39;49m\u001B[43m(\u001B[49m\u001B[33;43mf\u001B[39;49m\u001B[33;43m\"\u001B[39;49m\u001B[33;43mgha_results\u001B[39;49m\u001B[38;5;132;43;01m{\u001B[39;49;00m\u001B[43mtest\u001B[49m\u001B[38;5;132;43;01m}\u001B[39;49;00m\u001B[33;43m.pkl\u001B[39;49m\u001B[33;43m\"\u001B[39;49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[33;43m\"\u001B[39;49m\u001B[33;43mrb\u001B[39;49m\u001B[33;43m\"\u001B[39;49m\u001B[43m)\u001B[49m \u001B[38;5;28;01mas\u001B[39;00m f:\n\u001B[32m 2\u001B[39m results = pickle.load(f)\n", - "\u001B[36mFile \u001B[39m\u001B[32m~\\PythonInterpreter\\Lib\\site-packages\\IPython\\core\\interactiveshell.py:343\u001B[39m, in \u001B[36m_modified_open\u001B[39m\u001B[34m(file, *args, **kwargs)\u001B[39m\n\u001B[32m 336\u001B[39m \u001B[38;5;28;01mif\u001B[39;00m file \u001B[38;5;129;01min\u001B[39;00m {\u001B[32m0\u001B[39m, \u001B[32m1\u001B[39m, \u001B[32m2\u001B[39m}:\n\u001B[32m 337\u001B[39m \u001B[38;5;28;01mraise\u001B[39;00m \u001B[38;5;167;01mValueError\u001B[39;00m(\n\u001B[32m 338\u001B[39m \u001B[33mf\u001B[39m\u001B[33m\"\u001B[39m\u001B[33mIPython won\u001B[39m\u001B[33m'\u001B[39m\u001B[33mt let you open fd=\u001B[39m\u001B[38;5;132;01m{\u001B[39;00mfile\u001B[38;5;132;01m}\u001B[39;00m\u001B[33m by default \u001B[39m\u001B[33m\"\u001B[39m\n\u001B[32m 339\u001B[39m \u001B[33m\"\u001B[39m\u001B[33mas it is likely to crash IPython. If you know what you are doing, \u001B[39m\u001B[33m\"\u001B[39m\n\u001B[32m 340\u001B[39m \u001B[33m\"\u001B[39m\u001B[33myou can use builtins\u001B[39m\u001B[33m'\u001B[39m\u001B[33m open.\u001B[39m\u001B[33m\"\u001B[39m\n\u001B[32m 341\u001B[39m )\n\u001B[32m--> \u001B[39m\u001B[32m343\u001B[39m \u001B[38;5;28;01mreturn\u001B[39;00m \u001B[43mio_open\u001B[49m\u001B[43m(\u001B[49m\u001B[43mfile\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43m*\u001B[49m\u001B[43margs\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43m*\u001B[49m\u001B[43m*\u001B[49m\u001B[43mkwargs\u001B[49m\u001B[43m)\u001B[49m\n", - "\u001B[31mFileNotFoundError\u001B[39m: [Errno 2] No such file or directory: 'gha_resultsKarney.pkl'" - ] - } - ], - "execution_count": 6 + "source": "test = \"Karney\"", + "id": "8be408707e46f165", + "outputs": [], + "execution_count": 48 + }, + { + "metadata": {}, + "cell_type": "code", + "outputs": [], + "execution_count": null, + "source": "results = results_karney", + "id": "3a7c0416e1667b84" }, { "metadata": { "ExecuteTime": { - "end_time": "2026-02-07T20:59:54.841038500Z", - "start_time": "2026-02-07T17:02:15.854020Z" + "end_time": "2026-02-08T15:00:06.544175Z", + "start_time": "2026-02-08T15:00:06.215465Z" + } + }, + "cell_type": "code", + "source": [ + "with open(f\"gha_results{test}.pkl\", \"rb\") as f:\n", + " results = pickle.load(f)" + ], + "id": "4c20a0579c0f7038", + "outputs": [], + "execution_count": 49 + }, + { + "metadata": { + "ExecuteTime": { + "end_time": "2026-02-08T15:00:28.798843Z", + "start_time": "2026-02-08T15:00:28.527486Z" + } + }, + "cell_type": "code", + "source": [ + "metrics_gha1 = ['dBeta [\"]', 'dLambda [\"]', 'dAlpha1 [\"]', 'time [s]']\n", + "metrics_gha2 = ['dAlpha0 [\"]', 'dAlpha1 [\"]', 'dStrecke [m]', 'time [s]']\n", + "for example, example_metrics in results.items():\n", + " for method, method_metrics in example_metrics.items():\n", + " results[example][method] = list(results[example][method])\n", + " if \"GHA1\" in method:\n", + " for i, metric in enumerate(method_metrics):\n", + " if '[\"]' in metrics_gha1[i]:\n", + " if not np.isnan(metric):\n", + " metric %= (2*np.pi)\n", + " if not \"beta\" in metrics_gha1[i]:\n", + " metric = min(metric, abs(metric - 2*np.pi))\n", + " results[example][method][i] = metric\n", + " if \"GHA2\" in method:\n", + " for i, metric in enumerate(method_metrics):\n", + " if abs(metric - np.pi) < 0.1:\n", + " metric -= np.pi\n", + " if '[\"]' in metrics_gha2[i]:\n", + " if not np.isnan(metric):\n", + " metric %= (2*np.pi)\n", + " metric = min(metric, abs(metric - 2*np.pi))\n", + " results[example][method][i] = metric\n", + " pass" + ], + "id": "24ee93abe040e707", + "outputs": [], + "execution_count": 50 + }, + { + "metadata": { + "ExecuteTime": { + "end_time": "2026-02-08T15:26:22.209167Z", + "start_time": "2026-02-08T15:00:31.424013Z" } }, "cell_type": "code", @@ -406,17 +507,15 @@ " listed_results[method] = {metric: [] for metric in metrics_gha1}\n", " for i, metric in enumerate(method_metrics):\n", " if '[\"]' in metrics_gha1[i]:\n", - " listed_results[method][metrics_gha1[i]].append(wu.rad2deg(metric)*3600)\n", - " else:\n", - " listed_results[method][metrics_gha1[i]].append(metric)\n", + " metric = wu.rad2deg(metric)*3600\n", + " listed_results[method][metrics_gha1[i]].append(metric)\n", " if \"GHA2\" in method:\n", " if method not in listed_results.keys():\n", " listed_results[method] = {metric: [] for metric in metrics_gha2}\n", " for i, metric in enumerate(method_metrics):\n", " if '[\"]' in metrics_gha2[i]:\n", - " listed_results[method][metrics_gha2[i]].append(wu.rad2deg(metric)*3600)\n", - " else:\n", - " listed_results[method][metrics_gha2[i]].append(metric)\n", + " metric = wu.rad2deg(metric)*3600\n", + " listed_results[method][metrics_gha2[i]].append(metric)\n", " pass" ], "id": "2086b5bcd8416e33", @@ -426,8 +525,8 @@ { "metadata": { "ExecuteTime": { - "end_time": "2026-02-07T17:01:00.223306Z", - "start_time": "2026-02-07T17:00:59.325338Z" + "end_time": "2026-02-08T14:55:39.908336Z", + "start_time": "2026-02-08T14:55:39.447742Z" } }, "cell_type": "code", @@ -458,7 +557,6 @@ " example_keys = [example_key for example_key in list(results.keys())]\n", " else:\n", " example_keys = [example_key for example_key, group_index in zip(results.keys(), table_indices) if group_index==group_value]\n", - " example_keys = example_keys[:14]\n", "\n", " algorithms = sorted({algorithm for example_key in example_keys for algorithm in results[example_key].keys() if algorithm.startswith(gha_prefix)})\n", "\n", @@ -525,46 +623,158 @@ "align": "center", "values": [ [ + "ES", + "ES", + "ES", "ana", "ana", "ana", - "ana" + "ana", + "ana", + "ana", + "ana", + "ana", + "ana", + "approx", + "approx", + "approx", + "num", + "num", + "num", + "num", + "num" ], [ + "1250", + "60", + "600", "20_2", + "20_32", "20_8", "50_2", - "50_8" + "50_32", + "50_8", + "80_2", + "80_32", + "80_8", + "1250", + "600", + "6000", + "1000", + "10000", + "200", + "500", + "5000" ], [ - 2, - 2, - 2, - 2 + 0, + 0, + 0, + 32, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 3, + 3, + 3, + 0, + 0, + 27, + 4, + 0 ], [ - "3.2e+05", - "3.2e+05", - "3.2e+05", - "3.2e+05" + "1.89e+03", + "3.35e+04", + "1.37e+04", + "1.04e-08", + "4.77e-09", + "4e-09", + "3.96e-09", + "4.77e-09", + "4e-09", + "3.96e-09", + "4.77e-09", + "4e-09", + "126", + "1.08e+03", + "1.38", + "4.54e-07", + "0", + "2.62e-06", + "5.94e-06", + "4.35e-09" ], [ - "6.68e+05", - "6.68e+05", - "6.68e+05", - "6.68e+05" + "1.63e+04", + "3.01e+05", + "6.35e+04", + "5.63e-09", + "1.08e-08", + "1.13e-08", + "7.1e-09", + "1.08e-08", + "1.13e-08", + "7.1e-09", + "1.08e-08", + "1.13e-08", + "8.47e+03", + "1.89e+04", + "99.5", + "1.97e-06", + "0", + "3.98e-06", + "7.77e-06", + "2e-08" ], [ - "3.22e+05", - "3.22e+05", - "3.22e+05", - "3.22e+05" + "6.48e+05", + "6.48e+05", + "6.48e+05", + "3.3e-09", + "9.53e-09", + "9.98e-09", + "7.79e-09", + "9.53e-09", + "9.98e-09", + "7.79e-09", + "9.53e-09", + "9.98e-09", + "1.14e+03", + "1.52e+03", + "13.2", + "1.8e-06", + "0", + "3.05e-06", + "6.36e-06", + "1.8e-08" ], [ - "0.0169", - "0.0235", - "0.158", - "0.384" + "91.7", + "7.97", + "52.7", + "0.00917", + "0.179", + "0.0512", + "0.118", + "1.71", + "0.517", + "0.43", + "7.03", + "1.76", + "3.18", + "1.48", + "14.6", + "0.0677", + "0.573", + "0.0126", + "0.0323", + "0.294" ] ] }, @@ -1416,7 +1626,7 @@ "b": 20 }, "title": { - "text": "Karney - GHA1" + "text": "Random - GHA1" }, "width": 800, "height": 280 @@ -1440,13 +1650,97 @@ "cells": { "align": "center", "values": [ - [], - [], - [], - [], - [], - [], - [] + [ + "ES", + "ES", + "ES", + "approx", + "approx", + "approx", + "num", + "num", + "num", + "num", + "num" + ], + [ + "1250", + "60", + "600", + "1250", + "600", + "6000", + "1000", + "10000", + "200", + "500", + "5000" + ], + [ + 0, + 0, + 0, + 0, + 0, + 0, + 3, + 3, + 4, + 3, + 3 + ], + [ + "7.17e+03", + "7.17e+03", + "7.17e+03", + "8.03e+03", + "8.03e+03", + "8.03e+03", + "6.01e+05", + "6.01e+05", + "6.01e+05", + "6.01e+05", + "6.01e+05" + ], + [ + "7.17e+03", + "7.17e+03", + "7.17e+03", + "8.04e+03", + "8.04e+03", + "8.04e+03", + "6e+05", + "6e+05", + "6e+05", + "6e+05", + "6e+05" + ], + [ + "138", + "153", + "137", + "174", + "173", + "175", + "4.01e+07", + "4.01e+07", + "4.01e+07", + "4.01e+07", + "4.01e+07" + ], + [ + "104", + "5.21", + "53.7", + "0.524", + "0.251", + "3.81", + "1.47", + "6.79", + "0.25", + "0.877", + "6" + ] ] }, "header": { @@ -2297,7 +2591,7 @@ "b": 20 }, "title": { - "text": "Karney - GHA2" + "text": "Random - GHA2" }, "width": 800, "height": 280 @@ -2314,13 +2608,13 @@ } } ], - "execution_count": 11 + "execution_count": 46 }, { "metadata": { "ExecuteTime": { - "end_time": "2026-02-06T16:25:27.834928Z", - "start_time": "2026-02-06T16:25:27.488557Z" + "end_time": "2026-02-08T14:58:35.295970Z", + "start_time": "2026-02-08T14:58:34.968668Z" } }, "cell_type": "code", @@ -2373,13 +2667,15 @@ " return int(np.sum(np.isnan(np.array(vals, dtype=float))))\n", "\n", "\n", - "def max_abs_metric(results, example_keys, algorithm, metric_index, is_angle=False, wu=None):\n", + "def max_abs_metric(results, example_keys, algorithm, metric_index, is_angle=False, wu=None, mask=None):\n", " \"\"\"\n", " Echter Max(|...|) über alle example_keys.\n", " Wenn is_angle=True: Werte werden als rad angenommen und in Bogensekunden umgerechnet.\n", " \"\"\"\n", " arr = []\n", - " for k in example_keys:\n", + " for i, k in enumerate(example_keys):\n", + " if mask is not None and not mask[i]:\n", + " continue\n", " arr.append(results[k][algorithm][metric_index])\n", " arr = np.array(arr, dtype=float)\n", "\n", @@ -2531,7 +2827,18 @@ "\n", " # Metriken\n", " for mi in range(len(metric_headers)):\n", - " m = max_abs_metric(results, example_keys, alg, mi, is_angle=angle_mask[mi], wu=wu)\n", + " other_GL_mask = None\n", + " if gha_prefix == \"GHA2\" and variant == \"num\":\n", + " other_GL_mask = [\n", + " (\n", + " np.isfinite(results[k][alg][2]) and\n", + " abs(results[k][alg][2]) <= 10.0\n", + " )\n", + " for k in example_keys\n", + " ]\n", + " if other_GL_mask is not None:\n", + " print(f\"{alg}: {other_GL_mask.count(False)} falsche Linien\")\n", + " m = max_abs_metric(results, example_keys, alg, mi, is_angle=angle_mask[mi], wu=wu, mask=other_GL_mask)\n", " if mi == 3:\n", " row_cells.append(f\"${m:.2f}$\")\n", " else:\n", @@ -2556,7 +2863,7 @@ "example_keys = list(key for i, key in enumerate(results.keys()))\n", "if test == \"Panou\":\n", " example_keys = example_keys[:14]\n", - "gha = \"GHA2\"\n", + "gha = \"GHA1\"\n", "# example_keys = list(key for i, key in enumerate(results.keys()) if table_indices[i] == 3) # gefiltert auf Panou Gruppe etc.\n", "latex = build_latex_table_from_results(\n", " results,\n", @@ -2577,37 +2884,83 @@ "text": [ "\\begin{table}[H]\n", "\\centering\n", - "\\caption{Ergebnisse der Lösungsmethoden der 2. GHA (Panou)}\n", - "\\label{tab:results_Panou_GHA2}\n", + "\\caption{Ergebnisse der Lösungsmethoden der 1. GHA (Random)}\n", + "\\label{tab:results_Random_GHA1}\n", "\\begin{tabular}{|c|c|c|c|c|c|c|}\n", "\\hline\n", - "Methode & Parameterwerte & NaN & $\\max(|\\Delta \\alpha_0|)$ [$''$] & $\\max(|\\Delta \\alpha_1|)$ [$''$] & $\\max(|\\Delta s|)$ [m] & time [s] \\\\\n", + "Methode & Parameterwerte & NaN & $\\max(|\\Delta \\beta|)$ [$''$] & $\\max(|\\Delta \\lambda|)$ [$''$] & $\\max(|\\Delta \\alpha_1|)$ [$''$] & time [s] \\\\\n", "\\Xhline{1.5pt}\n", - "\\multirow{4}{*}{numerisch} & 200 & 0 & $1.738\\cdot10^{+01}$ & $1.858\\cdot10^{+01}$ & $7.262\\cdot10^{+03}$ & $3.67$ \\\\\n", - " & 500 & 0 & $4.679\\cdot10^{-01}$ & $4.667\\cdot10^{-01}$ & $1.796\\cdot10^{+02}$ & $9.07$ \\\\\n", - " & 1000 & 0 & $2.913\\cdot10^{-02}$ & $2.910\\cdot10^{-02}$ & $1.111\\cdot10^{+01}$ & $18.95$ \\\\\n", - " & 5000 & 0 & $4.453\\cdot10^{-05}$ & $6.276\\cdot10^{-05}$ & $1.750\\cdot10^{-02}$ & $92.75$ \\\\\\hline\n", - "\\multirow{3}{*}{approximiert} & 600 & 0 & $2.201\\cdot10^{+03}$ & $2.201\\cdot10^{+03}$ & $1.458\\cdot10^{+01}$ & $0.17$ \\\\\n", - " & 1250 & 0 & $2.201\\cdot10^{+03}$ & $2.201\\cdot10^{+03}$ & $1.600\\cdot10^{+01}$ & $0.36$ \\\\\n", - " & 6000 & 0 & $2.201\\cdot10^{+03}$ & $2.201\\cdot10^{+03}$ & $1.647\\cdot10^{+01}$ & $2.80$ \\\\\\hline\n", - "\\multirow{3}{*}{ES} & 60 & 0 & $1.779\\cdot10^{+05}$ & $1.779\\cdot10^{+05}$ & $1.480\\cdot10^{+02}$ & $5.14$ \\\\\n", - " & 600 & 0 & $1.779\\cdot10^{+05}$ & $1.779\\cdot10^{+05}$ & $4.493\\cdot10^{+01}$ & $41.70$ \\\\\n", - " & 1250 & 0 & $1.779\\cdot10^{+05}$ & $1.779\\cdot10^{+05}$ & $4.640\\cdot10^{+01}$ & $80.40$ \\\\\\hline\n", + "\\multirow{9}{*}{analytisch} & 2, 20 & 32 & $1.037\\cdot10^{-08}$ & $5.633\\cdot10^{-09}$ & $3.298\\cdot10^{-09}$ & $0.01$ \\\\\n", + " & 2, 50 & 0 & $3.962\\cdot10^{-09}$ & $7.099\\cdot10^{-09}$ & $7.786\\cdot10^{-09}$ & $0.12$ \\\\\n", + " & 2, 80 & 0 & $3.962\\cdot10^{-09}$ & $7.099\\cdot10^{-09}$ & $7.786\\cdot10^{-09}$ & $0.43$ \\\\\n", + " & 8, 20 & 0 & $3.996\\cdot10^{-09}$ & $1.127\\cdot10^{-08}$ & $9.984\\cdot10^{-09}$ & $0.05$ \\\\\n", + " & 8, 50 & 0 & $3.996\\cdot10^{-09}$ & $1.127\\cdot10^{-08}$ & $9.984\\cdot10^{-09}$ & $0.52$ \\\\\n", + " & 8, 80 & 0 & $3.996\\cdot10^{-09}$ & $1.127\\cdot10^{-08}$ & $9.984\\cdot10^{-09}$ & $1.76$ \\\\\n", + " & 32, 20 & 0 & $4.775\\cdot10^{-09}$ & $1.081\\cdot10^{-08}$ & $9.526\\cdot10^{-09}$ & $0.18$ \\\\\n", + " & 32, 50 & 0 & $4.775\\cdot10^{-09}$ & $1.081\\cdot10^{-08}$ & $9.526\\cdot10^{-09}$ & $1.71$ \\\\\n", + " & 32, 80 & 0 & $4.775\\cdot10^{-09}$ & $1.081\\cdot10^{-08}$ & $9.526\\cdot10^{-09}$ & $7.03$ \\\\\\hline\n", + "\\multirow{5}{*}{numerisch} & 200 & 27 & $2.617\\cdot10^{-06}$ & $3.985\\cdot10^{-06}$ & $3.046\\cdot10^{-06}$ & $0.01$ \\\\\n", + " & 500 & 4 & $5.939\\cdot10^{-06}$ & $7.774\\cdot10^{-06}$ & $6.358\\cdot10^{-06}$ & $0.03$ \\\\\n", + " & 1000 & 0 & $4.543\\cdot10^{-07}$ & $1.972\\cdot10^{-06}$ & $1.796\\cdot10^{-06}$ & $0.07$ \\\\\n", + " & 5000 & 0 & $4.351\\cdot10^{-09}$ & $2.001\\cdot10^{-08}$ & $1.795\\cdot10^{-08}$ & $0.29$ \\\\\n", + " & 10000 & 0 & $0.000\\cdot10^{+00}$ & $0.000\\cdot10^{+00}$ & $0.000\\cdot10^{+00}$ & $0.57$ \\\\\\hline\n", + "\\multirow{3}{*}{approximiert} & 600 & 3 & $1.084\\cdot10^{+03}$ & $1.889\\cdot10^{+04}$ & $1.524\\cdot10^{+03}$ & $1.48$ \\\\\n", + " & 1250 & 3 & $1.257\\cdot10^{+02}$ & $8.470\\cdot10^{+03}$ & $1.136\\cdot10^{+03}$ & $3.18$ \\\\\n", + " & 6000 & 3 & $1.380\\cdot10^{+00}$ & $9.948\\cdot10^{+01}$ & $1.325\\cdot10^{+01}$ & $14.56$ \\\\\\hline\n", + "\\multirow{3}{*}{ES} & 60 & 0 & $3.354\\cdot10^{+04}$ & $3.007\\cdot10^{+05}$ & $6.480\\cdot10^{+05}$ & $7.97$ \\\\\n", + " & 600 & 0 & $1.372\\cdot10^{+04}$ & $6.354\\cdot10^{+04}$ & $6.480\\cdot10^{+05}$ & $52.69$ \\\\\n", + " & 1250 & 0 & $1.894\\cdot10^{+03}$ & $1.633\\cdot10^{+04}$ & $6.480\\cdot10^{+05}$ & $91.68$ \\\\\\hline\n", "\\end{tabular}\n", "\\end{table}\n", "\\noindent\n" ] } ], - "execution_count": 48 + "execution_count": 47 }, { - "metadata": {}, + "metadata": { + "ExecuteTime": { + "end_time": "2026-02-08T12:45:27.798160Z", + "start_time": "2026-02-08T12:45:27.247424Z" + } + }, "cell_type": "code", - "outputs": [], - "execution_count": null, - "source": "", - "id": "44f20396e6c5493c" + "source": [ + "def count_large_ds(results, example_keys, algorithm=\"GHA2_num\", threshold=10.0):\n", + " \"\"\"\n", + " Zählt Fälle, bei denen |Δs| > threshold ist.\n", + " \"\"\"\n", + " count = 0\n", + " for k in example_keys:\n", + " val = results[k][algorithm][2] # Δs\n", + " try:\n", + " if np.isfinite(val) and abs(val) > threshold:\n", + " count += 1\n", + " except Exception:\n", + " pass\n", + " return count\n", + "\n", + "example_keys = list(key for i, key in enumerate(results.keys()))\n", + "n_bad = count_large_ds(results, example_keys, algorithm=\"GHA2_num\", threshold=10.0)\n", + "print(f\"GHA2_num: |Δs| > 10 m in {n_bad} Fällen\")" + ], + "id": "44f20396e6c5493c", + "outputs": [ + { + "ename": "KeyError", + "evalue": "'GHA2_num'", + "output_type": "error", + "traceback": [ + "\u001B[31m---------------------------------------------------------------------------\u001B[39m", + "\u001B[31mKeyError\u001B[39m Traceback (most recent call last)", + "\u001B[36mCell\u001B[39m\u001B[36m \u001B[39m\u001B[32mIn[106]\u001B[39m\u001B[32m, line 16\u001B[39m\n\u001B[32m 13\u001B[39m \u001B[38;5;28;01mreturn\u001B[39;00m count\n\u001B[32m 15\u001B[39m example_keys = \u001B[38;5;28mlist\u001B[39m(key \u001B[38;5;28;01mfor\u001B[39;00m i, key \u001B[38;5;129;01min\u001B[39;00m \u001B[38;5;28menumerate\u001B[39m(results.keys()))\n\u001B[32m---> \u001B[39m\u001B[32m16\u001B[39m n_bad = \u001B[43mcount_large_ds\u001B[49m\u001B[43m(\u001B[49m\u001B[43mresults\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mexample_keys\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43malgorithm\u001B[49m\u001B[43m=\u001B[49m\u001B[33;43m\"\u001B[39;49m\u001B[33;43mGHA2_num\u001B[39;49m\u001B[33;43m\"\u001B[39;49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mthreshold\u001B[49m\u001B[43m=\u001B[49m\u001B[32;43m10.0\u001B[39;49m\u001B[43m)\u001B[49m\n\u001B[32m 17\u001B[39m \u001B[38;5;28mprint\u001B[39m(\u001B[33mf\u001B[39m\u001B[33m\"\u001B[39m\u001B[33mGHA2_num: |Δs| > 10 m in \u001B[39m\u001B[38;5;132;01m{\u001B[39;00mn_bad\u001B[38;5;132;01m}\u001B[39;00m\u001B[33m Fällen\u001B[39m\u001B[33m\"\u001B[39m)\n", + "\u001B[36mCell\u001B[39m\u001B[36m \u001B[39m\u001B[32mIn[106]\u001B[39m\u001B[32m, line 7\u001B[39m, in \u001B[36mcount_large_ds\u001B[39m\u001B[34m(results, example_keys, algorithm, threshold)\u001B[39m\n\u001B[32m 5\u001B[39m count = \u001B[32m0\u001B[39m\n\u001B[32m 6\u001B[39m \u001B[38;5;28;01mfor\u001B[39;00m k \u001B[38;5;129;01min\u001B[39;00m example_keys:\n\u001B[32m----> \u001B[39m\u001B[32m7\u001B[39m val = \u001B[43mresults\u001B[49m\u001B[43m[\u001B[49m\u001B[43mk\u001B[49m\u001B[43m]\u001B[49m\u001B[43m[\u001B[49m\u001B[43malgorithm\u001B[49m\u001B[43m]\u001B[49m[\u001B[32m2\u001B[39m] \u001B[38;5;66;03m# Δs\u001B[39;00m\n\u001B[32m 8\u001B[39m \u001B[38;5;28;01mtry\u001B[39;00m:\n\u001B[32m 9\u001B[39m \u001B[38;5;28;01mif\u001B[39;00m np.isfinite(val) \u001B[38;5;129;01mand\u001B[39;00m \u001B[38;5;28mabs\u001B[39m(val) > threshold:\n", + "\u001B[31mKeyError\u001B[39m: 'GHA2_num'" + ] + } + ], + "execution_count": 106 } ], "metadata": {