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"})
|
], 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"):
|
def ellipsoid_figure(ell: EllipsoidTriaxial, title="Dreiachsiges Ellipsoid"):
|
||||||
fig = go.Figure()
|
fig = go.Figure()
|
||||||
|
|
||||||
# Darstellung
|
# 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(
|
fig.update_layout(
|
||||||
title=title,
|
title=title,
|
||||||
scene=dict(
|
scene=dict(
|
||||||
xaxis=dict(range=[-rx, rx], title="X [m]"),
|
xaxis=dict(
|
||||||
yaxis=dict(range=[-ry, ry], title="Y [m]"),
|
range=[-rx, rx],
|
||||||
zaxis=dict(range=[-rz, rz], title="Z [m]"),
|
#title="X [m]",
|
||||||
aspectmode="data"
|
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
|
# Ellipsoid
|
||||||
@@ -915,6 +951,7 @@ def compute_gha2_num(n2, cb_num, n_in, beta0, lamb0, beta1, lamb1, ax, ay, b):
|
|||||||
|
|
||||||
out = html.Div([
|
out = html.Div([
|
||||||
html.Strong("Numerisch: "),
|
html.Strong("Numerisch: "),
|
||||||
|
html.Br(),
|
||||||
html.Span(f"{aus.gms('α₀', a0_num, 4)}, {aus.gms('α₁', a1_num, 4)}, s = {s_num:.4f} m"),
|
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([
|
out = html.Div([
|
||||||
html.Strong("Stochastisch (ES): "),
|
html.Strong("Stochastisch (ES): "),
|
||||||
|
html.Br(),
|
||||||
html.Span(f"{aus.gms('α₀', a0_stoch, 4)}, {aus.gms('α₁', a1_stoch, 4)}, s = {s_stoch:.4f} m"),
|
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([
|
out = html.Div([
|
||||||
html.Strong("Approximiert: "),
|
html.Strong("Approximiert: "),
|
||||||
|
html.Br(),
|
||||||
html.Span(f"{aus.gms('α₀', a0_app, 4)}, {aus.gms('α₁', a1_app, 4)}, s = {s_app:.4f} m"),
|
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):
|
if None in (ax, ay, b):
|
||||||
return go.Figure()
|
return go.Figure()
|
||||||
|
|
||||||
try:
|
if not axes_valid(ax, ay, b):
|
||||||
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):
|
|
||||||
return go.Figure()
|
return go.Figure()
|
||||||
|
|
||||||
ell = EllipsoidTriaxial(ax, ay, b)
|
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 = ellipsoid_figure(ell, title="")
|
||||||
fig = figure_constant_lines(fig, ell, coords_type)
|
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
|
nonlocal fig
|
||||||
if not store:
|
if not store:
|
||||||
return
|
return
|
||||||
name = store.get("name")
|
|
||||||
color = store.get("color")
|
|
||||||
if not name or not color:
|
|
||||||
return
|
|
||||||
|
|
||||||
key = (name, color)
|
name = store.get("name") or fallback_name
|
||||||
if key in legend_added:
|
color = store.get("color", "#ff8c00")
|
||||||
return
|
group = name # legendgroup-ID
|
||||||
legend_added.add(key)
|
|
||||||
|
|
||||||
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(
|
fig.add_trace(go.Scatter3d(
|
||||||
x=[None], y=[None], z=[None],
|
x=arr[:, 0], y=arr[:, 1], z=arr[:, 2],
|
||||||
mode="lines",
|
mode="lines",
|
||||||
line=dict(width=6, color=color),
|
line=dict(width=4, color=color),
|
||||||
name=name,
|
name=name,
|
||||||
|
legendgroup=group,
|
||||||
showlegend=True,
|
showlegend=True,
|
||||||
hoverinfo="skip",
|
|
||||||
))
|
))
|
||||||
else:
|
else:
|
||||||
fig.add_trace(go.Scatter3d(
|
fig.add_trace(go.Scatter3d(
|
||||||
@@ -1108,36 +1139,25 @@ def render_all(ax, ay, b, coords_type, tab, t1, t2,
|
|||||||
mode="markers",
|
mode="markers",
|
||||||
marker=dict(size=8, color=color),
|
marker=dict(size=8, color=color),
|
||||||
name=name,
|
name=name,
|
||||||
|
legendgroup=group,
|
||||||
showlegend=True,
|
showlegend=True,
|
||||||
hoverinfo="skip",
|
hoverinfo="skip",
|
||||||
))
|
))
|
||||||
|
|
||||||
def add_from_store(store):
|
for pname, (px, py, pz), pcolor in pts:
|
||||||
nonlocal fig
|
fig.add_trace(go.Scatter3d(
|
||||||
if not store:
|
x=[px], y=[py], z=[pz],
|
||||||
return
|
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 []
|
for i, st in enumerate(stores, start=1):
|
||||||
if pts:
|
add_method(st, f"Methode {i}")
|
||||||
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)
|
|
||||||
|
|
||||||
fig.update_layout(
|
fig.update_layout(
|
||||||
showlegend=True,
|
showlegend=True,
|
||||||
@@ -1147,9 +1167,11 @@ def render_all(ax, ay, b, coords_type, tab, t1, t2,
|
|||||||
y=1.02,
|
y=1.02,
|
||||||
xanchor="left",
|
xanchor="left",
|
||||||
x=0.06,
|
x=0.06,
|
||||||
|
groupclick="togglegroup",
|
||||||
|
itemclick="toggle",
|
||||||
|
itemdoubleclick="toggleothers",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
return fig
|
return fig
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user