Meldung wenn Berechung fehlschlägt

This commit is contained in:
Tammo.Weber
2026-02-08 17:51:55 +01:00
parent ee85e8b0e6
commit cfab70ac55

View File

@@ -5,6 +5,7 @@ import dash_bootstrap_components as dbc
import builtins
from dash.exceptions import PreventUpdate
import traceback
import webbrowser
from threading import Timer
@@ -117,6 +118,23 @@ def method_row(label, cb_id, input_id=None, value="", info=""):
return html.Div(children, style=base_row_style)
def method_failed(method_label: str, exc: Exception):
return html.Div([
html.Strong(f"{method_label}: "),
html.Span("konnte nicht berechnet werden. ", style={"color": "red"}),
#html.Span(f"({type(exc).__name__}: {exc})", style={"color": "#b02a37"}),
html.Details([
html.Summary("Details"),
html.Pre(traceback.format_exc(), style={
"whiteSpace": "pre-wrap",
"fontSize": "12px",
"color": "#6c757d",
"marginTop": "6px"
})
], style={"marginTop": "6px"})
])
def ellipsoid_figure(ell: EllipsoidTriaxial, title="Dreiachsiges Ellipsoid"):
fig = go.Figure()
@@ -634,6 +652,7 @@ def compute_gha1_ana(n1, cb_ana, n_in, beta0, lamb0, s, a0, ax, ay, b):
n_in = int(n_in) if n_in else 70
try:
ell = EllipsoidTriaxial(ax, ay, b)
beta_rad = wu.deg2rad(float(beta0))
lamb_rad = wu.deg2rad(float(lamb0))
@@ -664,6 +683,9 @@ def compute_gha1_ana(n1, cb_ana, n_in, beta0, lamb0, s, a0, ax, ay, b):
}
return out, store
except Exception as e:
return method_failed("Analytisch", e), None
@app.callback(
Output("output-gha1-num", "children"),
Output("store-gha1-num", "data"),
@@ -693,6 +715,7 @@ def compute_gha1_num(n1, cb_num, n_in, beta0, lamb0, s, a0, ax, ay, b):
alpha_rad = wu.deg2rad(float(a0))
s_val = float(s)
try:
P0 = ell.ell2cart(beta_rad, lamb_rad)
P1_num, alpha1, werte = gha1_num(ell, P0, alpha_rad, s_val, n_in, all_points=True)
@@ -717,6 +740,9 @@ def compute_gha1_num(n1, cb_num, n_in, beta0, lamb0, s, a0, ax, ay, b):
}
return out, store
except Exception as e:
return method_failed("Numerisch", e), None
@app.callback(
Output("output-gha1-stoch", "children"),
Output("store-gha1-stoch", "data"),
@@ -740,6 +766,7 @@ def compute_gha1_stoch(n1, cb_stoch, n_in, beta0, lamb0, s, a0, ax, ay, b):
n_in = int(n_in) if n_in else 1000
try:
ell = EllipsoidTriaxial(ax, ay, b)
beta_rad = wu.deg2rad(float(beta0))
lamb_rad = wu.deg2rad(float(lamb0))
@@ -767,6 +794,9 @@ def compute_gha1_stoch(n1, cb_stoch, n_in, beta0, lamb0, s, a0, ax, ay, b):
}
return out, store
except Exception as e:
return method_failed("Stochastisch (ES)", e), None
@app.callback(
Output("output-gha1-approx", "children"),
Output("store-gha1-approx", "data"),
@@ -790,6 +820,7 @@ def compute_gha1_approx(n1, cb_approx, ds_in, beta0, lamb0, s, a0, ax, ay, b):
ds_in = int(ds_in) if ds_in else 1000
try:
ell = EllipsoidTriaxial(ax, ay, b)
beta_rad = wu.deg2rad(float(beta0))
lamb_rad = wu.deg2rad(float(lamb0))
@@ -817,6 +848,9 @@ def compute_gha1_approx(n1, cb_approx, ds_in, beta0, lamb0, s, a0, ax, ay, b):
}
return out, store
except Exception as e:
return method_failed("Approximiert", e), None
# --- GHA 2 ---
@app.callback(
@@ -842,6 +876,7 @@ def compute_gha2_num(n2, cb_num, n_in, beta0, lamb0, beta1, lamb1, ax, ay, b):
n_in = int(n_in) if n_in else 2000
try:
ell = EllipsoidTriaxial(ax, ay, b)
beta0_rad = wu.deg2rad(float(beta0))
@@ -872,6 +907,9 @@ def compute_gha2_num(n2, cb_num, n_in, beta0, lamb0, beta1, lamb1, ax, ay, b):
}
return out, store
except Exception as e:
return method_failed("Numerisch", e), None
@app.callback(
Output("output-gha2-stoch", "children"),
Output("store-gha2-stoch", "data"),
@@ -895,6 +933,7 @@ def compute_gha2_stoch(n2, cb_stoch, n_in, beta0, lamb0, beta1, lamb1, ax, ay, b
n_in = int(n_in) if n_in else 1000
try:
ell = EllipsoidTriaxial(ax, ay, b)
beta0_rad = wu.deg2rad(float(beta0))
@@ -921,6 +960,9 @@ def compute_gha2_stoch(n2, cb_stoch, n_in, beta0, lamb0, beta1, lamb1, ax, ay, b
return out, store
except Exception as e:
return method_failed("Stochastisch (ES)", e), None
@app.callback(
Output("output-gha2-approx", "children"),
Output("store-gha2-approx", "data"),
@@ -944,6 +986,7 @@ def compute_gha2_approx(n2, cb_approx, ds_in, beta0, lamb0, beta1, lamb1, ax, ay
ds_in = int(ds_in) if ds_in else 1000
try:
ell = EllipsoidTriaxial(ax, ay, b)
beta0_rad = wu.deg2rad(float(beta0))
@@ -970,6 +1013,9 @@ def compute_gha2_approx(n2, cb_approx, ds_in, beta0, lamb0, beta1, lamb1, ax, ay
return out, store
except Exception as e:
return method_failed("Stochastisch (ES)", e), None
# --- Plot ---
@app.callback(
Output("ellipsoid-plot", "figure"),