Anpassungen im Plot
This commit is contained in:
134
dashboard.py
134
dashboard.py
@@ -145,21 +145,57 @@ def method_failed(method_label: str, exc: Exception):
|
||||
], style={"marginTop": "6px"})
|
||||
])
|
||||
|
||||
def axes_valid(ax, ay, b) -> bool:
|
||||
if ax is None or ay is None or b is None:
|
||||
return False
|
||||
try:
|
||||
ax = float(ax); ay = float(ay); b = float(b)
|
||||
except (TypeError, ValueError):
|
||||
return False
|
||||
if ax <= 0 or ay <= 0 or b <= 0:
|
||||
return False
|
||||
return ax >= ay >= b
|
||||
|
||||
|
||||
def ellipsoid_figure(ell: EllipsoidTriaxial, title="Dreiachsiges Ellipsoid"):
|
||||
fig = go.Figure()
|
||||
|
||||
# Darstellung
|
||||
rx, ry, rz = 1.05*ell.ax, 1.05*ell.ay, 1.05*ell.b
|
||||
rx, ry, rz = 1.01*ell.ax, 1.01*ell.ay, 1.01*ell.b
|
||||
fig.update_layout(
|
||||
title=title,
|
||||
scene=dict(
|
||||
xaxis=dict(range=[-rx, rx], title="X [m]"),
|
||||
yaxis=dict(range=[-ry, ry], title="Y [m]"),
|
||||
zaxis=dict(range=[-rz, rz], title="Z [m]"),
|
||||
aspectmode="data"
|
||||
xaxis=dict(
|
||||
range=[-rx, rx],
|
||||
#title="X [m]",
|
||||
title="",
|
||||
showgrid=False,
|
||||
zeroline=False,
|
||||
showbackground=False,
|
||||
showticklabels=False
|
||||
),
|
||||
margin=dict(l=0, r=0, t=10, b=0),
|
||||
yaxis=dict(
|
||||
range=[-ry, ry],
|
||||
#title="Y [m]",
|
||||
title="",
|
||||
showgrid=False,
|
||||
zeroline=False,
|
||||
showbackground=False,
|
||||
showticklabels=False
|
||||
),
|
||||
zaxis=dict(
|
||||
range=[-rz, rz],
|
||||
#title="Z [m]",
|
||||
title="",
|
||||
showgrid=False,
|
||||
zeroline=False,
|
||||
showbackground=False,
|
||||
showticklabels=False
|
||||
),
|
||||
aspectmode="data",
|
||||
),
|
||||
margin=dict(l=0, r=0, t=0, b=0),
|
||||
scene_camera=dict(eye=dict(x=1.05, y=1.05, z=0.85)),
|
||||
)
|
||||
|
||||
# Ellipsoid
|
||||
@@ -915,6 +951,7 @@ def compute_gha2_num(n2, cb_num, n_in, beta0, lamb0, beta1, lamb1, ax, ay, b):
|
||||
|
||||
out = html.Div([
|
||||
html.Strong("Numerisch: "),
|
||||
html.Br(),
|
||||
html.Span(f"{aus.gms('α₀', a0_num, 4)}, {aus.gms('α₁', a1_num, 4)}, s = {s_num:.4f} m"),
|
||||
])
|
||||
|
||||
@@ -967,6 +1004,7 @@ def compute_gha2_stoch(n2, cb_stoch, n_in, beta0, lamb0, beta1, lamb1, ax, ay, b
|
||||
|
||||
out = html.Div([
|
||||
html.Strong("Stochastisch (ES): "),
|
||||
html.Br(),
|
||||
html.Span(f"{aus.gms('α₀', a0_stoch, 4)}, {aus.gms('α₁', a1_stoch, 4)}, s = {s_stoch:.4f} m"),
|
||||
])
|
||||
|
||||
@@ -1020,6 +1058,7 @@ def compute_gha2_approx(n2, cb_approx, ds_in, beta0, lamb0, beta1, lamb1, ax, ay
|
||||
|
||||
out = html.Div([
|
||||
html.Strong("Approximiert: "),
|
||||
html.Br(),
|
||||
html.Span(f"{aus.gms('α₀', a0_app, 4)}, {aus.gms('α₁', a1_app, 4)}, s = {s_app:.4f} m"),
|
||||
])
|
||||
|
||||
@@ -1059,15 +1098,7 @@ def render_all(ax, ay, b, coords_type, tab, t1, t2,
|
||||
if None in (ax, ay, b):
|
||||
return go.Figure()
|
||||
|
||||
try:
|
||||
ax = float(ax); ay = float(ay); b = float(b)
|
||||
except (TypeError, ValueError):
|
||||
return go.Figure()
|
||||
|
||||
if ax <= 0 or ay <= 0 or b <= 0:
|
||||
return go.Figure()
|
||||
|
||||
if not (ax >= ay >= b):
|
||||
if not axes_valid(ax, ay, b):
|
||||
return go.Figure()
|
||||
|
||||
ell = EllipsoidTriaxial(ax, ay, b)
|
||||
@@ -1075,32 +1106,32 @@ def render_all(ax, ay, b, coords_type, tab, t1, t2,
|
||||
fig = ellipsoid_figure(ell, title="")
|
||||
fig = figure_constant_lines(fig, ell, coords_type)
|
||||
|
||||
legend_added = set()
|
||||
if tab == "tab-GHA1":
|
||||
stores = (s1a, s1n, s1s, s1p)
|
||||
else:
|
||||
stores = (s2n, s2s, s2p)
|
||||
|
||||
def add_legend_for_store(store):
|
||||
def add_method(store, fallback_name):
|
||||
nonlocal fig
|
||||
if not store:
|
||||
return
|
||||
name = store.get("name")
|
||||
color = store.get("color")
|
||||
if not name or not color:
|
||||
return
|
||||
|
||||
key = (name, color)
|
||||
if key in legend_added:
|
||||
return
|
||||
legend_added.add(key)
|
||||
name = store.get("name") or fallback_name
|
||||
color = store.get("color", "#ff8c00")
|
||||
group = name # legendgroup-ID
|
||||
|
||||
has_line = bool(store.get("polyline"))
|
||||
pts = store.get("points") or []
|
||||
line = store.get("polyline")
|
||||
|
||||
if has_line:
|
||||
if line:
|
||||
arr = np.asarray(line, dtype=float)
|
||||
fig.add_trace(go.Scatter3d(
|
||||
x=[None], y=[None], z=[None],
|
||||
x=arr[:, 0], y=arr[:, 1], z=arr[:, 2],
|
||||
mode="lines",
|
||||
line=dict(width=6, color=color),
|
||||
line=dict(width=4, color=color),
|
||||
name=name,
|
||||
legendgroup=group,
|
||||
showlegend=True,
|
||||
hoverinfo="skip",
|
||||
))
|
||||
else:
|
||||
fig.add_trace(go.Scatter3d(
|
||||
@@ -1108,36 +1139,25 @@ def render_all(ax, ay, b, coords_type, tab, t1, t2,
|
||||
mode="markers",
|
||||
marker=dict(size=8, color=color),
|
||||
name=name,
|
||||
legendgroup=group,
|
||||
showlegend=True,
|
||||
hoverinfo="skip",
|
||||
))
|
||||
|
||||
def add_from_store(store):
|
||||
nonlocal fig
|
||||
if not store:
|
||||
return
|
||||
for pname, (px, py, pz), pcolor in pts:
|
||||
fig.add_trace(go.Scatter3d(
|
||||
x=[px], y=[py], z=[pz],
|
||||
mode="markers+text",
|
||||
marker=dict(size=6, color=pcolor),
|
||||
text=[pname],
|
||||
textposition="top center",
|
||||
name=pname,
|
||||
showlegend=False,
|
||||
legendgroup=group,
|
||||
))
|
||||
|
||||
pts = store.get("points") or []
|
||||
if pts:
|
||||
fig = figure_points(fig, pts)
|
||||
|
||||
line = store.get("polyline")
|
||||
if line:
|
||||
fig = figure_lines(
|
||||
fig,
|
||||
line,
|
||||
store.get("name", ""),
|
||||
store.get("color", "#ff8c00"),
|
||||
)
|
||||
|
||||
if tab == "tab-GHA1":
|
||||
stores = (s1a, s1n, s1s, s1p)
|
||||
else:
|
||||
stores = (s2n, s2s, s2p)
|
||||
|
||||
for st in stores:
|
||||
add_legend_for_store(st)
|
||||
add_from_store(st)
|
||||
for i, st in enumerate(stores, start=1):
|
||||
add_method(st, f"Methode {i}")
|
||||
|
||||
fig.update_layout(
|
||||
showlegend=True,
|
||||
@@ -1147,9 +1167,11 @@ def render_all(ax, ay, b, coords_type, tab, t1, t2,
|
||||
y=1.02,
|
||||
xanchor="left",
|
||||
x=0.06,
|
||||
groupclick="togglegroup",
|
||||
itemclick="toggle",
|
||||
itemdoubleclick="toggleothers",
|
||||
),
|
||||
)
|
||||
|
||||
return fig
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user