Meldung wenn Berechung fehlschlägt
This commit is contained in:
46
dashboard.py
46
dashboard.py
@@ -5,6 +5,7 @@ import dash_bootstrap_components as dbc
|
|||||||
|
|
||||||
import builtins
|
import builtins
|
||||||
from dash.exceptions import PreventUpdate
|
from dash.exceptions import PreventUpdate
|
||||||
|
import traceback
|
||||||
|
|
||||||
import webbrowser
|
import webbrowser
|
||||||
from threading import Timer
|
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)
|
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"):
|
def ellipsoid_figure(ell: EllipsoidTriaxial, title="Dreiachsiges Ellipsoid"):
|
||||||
fig = go.Figure()
|
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
|
n_in = int(n_in) if n_in else 70
|
||||||
|
|
||||||
|
try:
|
||||||
ell = EllipsoidTriaxial(ax, ay, b)
|
ell = EllipsoidTriaxial(ax, ay, b)
|
||||||
beta_rad = wu.deg2rad(float(beta0))
|
beta_rad = wu.deg2rad(float(beta0))
|
||||||
lamb_rad = wu.deg2rad(float(lamb0))
|
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
|
return out, store
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
return method_failed("Analytisch", e), None
|
||||||
|
|
||||||
@app.callback(
|
@app.callback(
|
||||||
Output("output-gha1-num", "children"),
|
Output("output-gha1-num", "children"),
|
||||||
Output("store-gha1-num", "data"),
|
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))
|
alpha_rad = wu.deg2rad(float(a0))
|
||||||
s_val = float(s)
|
s_val = float(s)
|
||||||
|
|
||||||
|
try:
|
||||||
P0 = ell.ell2cart(beta_rad, lamb_rad)
|
P0 = ell.ell2cart(beta_rad, lamb_rad)
|
||||||
|
|
||||||
P1_num, alpha1, werte = gha1_num(ell, P0, alpha_rad, s_val, n_in, all_points=True)
|
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
|
return out, store
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
return method_failed("Numerisch", e), None
|
||||||
|
|
||||||
@app.callback(
|
@app.callback(
|
||||||
Output("output-gha1-stoch", "children"),
|
Output("output-gha1-stoch", "children"),
|
||||||
Output("store-gha1-stoch", "data"),
|
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
|
n_in = int(n_in) if n_in else 1000
|
||||||
|
|
||||||
|
try:
|
||||||
ell = EllipsoidTriaxial(ax, ay, b)
|
ell = EllipsoidTriaxial(ax, ay, b)
|
||||||
beta_rad = wu.deg2rad(float(beta0))
|
beta_rad = wu.deg2rad(float(beta0))
|
||||||
lamb_rad = wu.deg2rad(float(lamb0))
|
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
|
return out, store
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
return method_failed("Stochastisch (ES)", e), None
|
||||||
|
|
||||||
@app.callback(
|
@app.callback(
|
||||||
Output("output-gha1-approx", "children"),
|
Output("output-gha1-approx", "children"),
|
||||||
Output("store-gha1-approx", "data"),
|
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
|
ds_in = int(ds_in) if ds_in else 1000
|
||||||
|
|
||||||
|
try:
|
||||||
ell = EllipsoidTriaxial(ax, ay, b)
|
ell = EllipsoidTriaxial(ax, ay, b)
|
||||||
beta_rad = wu.deg2rad(float(beta0))
|
beta_rad = wu.deg2rad(float(beta0))
|
||||||
lamb_rad = wu.deg2rad(float(lamb0))
|
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
|
return out, store
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
return method_failed("Approximiert", e), None
|
||||||
|
|
||||||
|
|
||||||
# --- GHA 2 ---
|
# --- GHA 2 ---
|
||||||
@app.callback(
|
@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
|
n_in = int(n_in) if n_in else 2000
|
||||||
|
|
||||||
|
try:
|
||||||
ell = EllipsoidTriaxial(ax, ay, b)
|
ell = EllipsoidTriaxial(ax, ay, b)
|
||||||
|
|
||||||
beta0_rad = wu.deg2rad(float(beta0))
|
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
|
return out, store
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
return method_failed("Numerisch", e), None
|
||||||
|
|
||||||
@app.callback(
|
@app.callback(
|
||||||
Output("output-gha2-stoch", "children"),
|
Output("output-gha2-stoch", "children"),
|
||||||
Output("store-gha2-stoch", "data"),
|
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
|
n_in = int(n_in) if n_in else 1000
|
||||||
|
|
||||||
|
try:
|
||||||
ell = EllipsoidTriaxial(ax, ay, b)
|
ell = EllipsoidTriaxial(ax, ay, b)
|
||||||
|
|
||||||
beta0_rad = wu.deg2rad(float(beta0))
|
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
|
return out, store
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
return method_failed("Stochastisch (ES)", e), None
|
||||||
|
|
||||||
@app.callback(
|
@app.callback(
|
||||||
Output("output-gha2-approx", "children"),
|
Output("output-gha2-approx", "children"),
|
||||||
Output("store-gha2-approx", "data"),
|
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
|
ds_in = int(ds_in) if ds_in else 1000
|
||||||
|
|
||||||
|
try:
|
||||||
ell = EllipsoidTriaxial(ax, ay, b)
|
ell = EllipsoidTriaxial(ax, ay, b)
|
||||||
|
|
||||||
beta0_rad = wu.deg2rad(float(beta0))
|
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
|
return out, store
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
return method_failed("Stochastisch (ES)", e), None
|
||||||
|
|
||||||
# --- Plot ---
|
# --- Plot ---
|
||||||
@app.callback(
|
@app.callback(
|
||||||
Output("ellipsoid-plot", "figure"),
|
Output("ellipsoid-plot", "figure"),
|
||||||
|
|||||||
Reference in New Issue
Block a user