zusammenfügen 13.1.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import numpy as np
|
||||
import plotly.graph_objects as go
|
||||
from scipy.stats import f as f_dist
|
||||
import pandas as pd
|
||||
|
||||
|
||||
class Genauigkeitsmaße:
|
||||
@@ -14,55 +15,136 @@ class Genauigkeitsmaße:
|
||||
return float(s0apost)
|
||||
|
||||
|
||||
@staticmethod
|
||||
def berechne_helmert_punktfehler_3D(Qxx_matrix: np.ndarray, s0apost: float, punkt_namen: list) -> dict:
|
||||
helmert_punktfehler_ergebnisse_3D = {}
|
||||
diag_Q = np.diag(Qxx_matrix)
|
||||
if len(diag_Q) < len(punkt_namen) * 3:
|
||||
raise ValueError("Die Matrix Qxx ist zu klein für die Anzahl der Punkte (3D erwartet).")
|
||||
for i, name in enumerate(punkt_namen):
|
||||
idx_x, idx_y, idx_z = 3 * i, 3 * i + 1, 3 * i + 2
|
||||
q_xx, q_yy, q_zz = diag_Q[idx_x], diag_Q[idx_y], diag_Q[idx_z]
|
||||
helmert_punktfehler_3D = s0apost * np.sqrt(q_xx + q_yy + q_zz)
|
||||
helmert_punktfehler_ergebnisse_3D[name] = round(float(helmert_punktfehler_3D), 4)
|
||||
return helmert_punktfehler_ergebnisse_3D
|
||||
|
||||
def helmert_punktfehler(Qxx, s0_apost, unbekannten_liste, dim=3):
|
||||
diagQ = np.diag(Qxx)
|
||||
daten = []
|
||||
|
||||
n_punkte = len(unbekannten_liste) // 3
|
||||
|
||||
for i in range(n_punkte):
|
||||
sym_x = str(unbekannten_liste[3 * i]) # z.B. "X10009"
|
||||
punkt = sym_x[1:] # -> "10009"
|
||||
|
||||
qx = diagQ[3 * i]
|
||||
qy = diagQ[3 * i + 1]
|
||||
qz = diagQ[3 * i + 2]
|
||||
|
||||
sx = s0_apost * np.sqrt(qx)
|
||||
sy = s0_apost * np.sqrt(qy)
|
||||
sz = s0_apost * np.sqrt(qz)
|
||||
|
||||
if dim == 2:
|
||||
sP = s0_apost * np.sqrt(qx + qy)
|
||||
else:
|
||||
sP = s0_apost * np.sqrt(qx + qy + qz)
|
||||
|
||||
daten.append([
|
||||
punkt,
|
||||
float(sx),
|
||||
float(sy),
|
||||
float(sz),
|
||||
float(sP)
|
||||
])
|
||||
helmert_punktfehler = pd.DataFrame(daten, columns=["Punkt", "σx", "σy", "σz", f"σP_{dim}D"])
|
||||
return helmert_punktfehler
|
||||
|
||||
|
||||
@staticmethod
|
||||
def berechne_standardellipsen(Qxx: np.ndarray, s0: float, punkt_namen: list):
|
||||
standardellipsen = []
|
||||
for i, name in enumerate(punkt_namen):
|
||||
ix, iy = 3 * i, 3 * i + 1
|
||||
qxx, qyy, qxy = Qxx[ix, ix], Qxx[iy, iy], Qxx[ix, iy]
|
||||
k = np.sqrt((qxx - qyy) ** 2 + 4 * qxy ** 2)
|
||||
qa, qb = 0.5 * (qxx + qyy + k), 0.5 * (qxx + qyy - k)
|
||||
a, b = s0 * np.sqrt(qa), s0 * np.sqrt(qb)
|
||||
theta = 0.5 * np.arctan2(2 * qxy, qxx - qyy)
|
||||
standardellipsen.append({
|
||||
"name": name, "a": a, "b": b, "theta": theta, "prob": 0.39 # Standard ca. 39%
|
||||
})
|
||||
return standardellipsen
|
||||
|
||||
def standardellipse(Qxx, s0_apost, unbekannten_liste, dim_labels=3):
|
||||
Qxx = np.asarray(Qxx, float)
|
||||
data = []
|
||||
|
||||
n_punkte = len(unbekannten_liste) // dim_labels
|
||||
|
||||
for i in range(n_punkte):
|
||||
sym_x = str(unbekannten_liste[dim_labels * i]) # z.B. "X10009"
|
||||
punkt = sym_x[1:] # -> "10009"
|
||||
|
||||
ix = dim_labels * i
|
||||
iy = dim_labels * i + 1
|
||||
|
||||
# 2x2-Kofaktorblock
|
||||
Qxx_ = Qxx[ix, ix]
|
||||
Qyy_ = Qxx[iy, iy]
|
||||
Qyx_ = Qxx[iy, ix]
|
||||
|
||||
# Standardabweichungen der Koordinatenkomponenten
|
||||
sx = s0_apost * np.sqrt(Qxx_)
|
||||
sy = s0_apost * np.sqrt(Qyy_)
|
||||
sxy = (s0_apost ** 2) * Qyx_
|
||||
|
||||
# k und Eigenwerte (Q_dmax, Q_dmin)
|
||||
k = np.sqrt((Qxx_ - Qyy_) ** 2 + 4 * (Qyx_ ** 2))
|
||||
Q_dmax = 0.5 * (Qxx_ + Qyy_ + k)
|
||||
Q_dmin = 0.5 * (Qxx_ + Qyy_ - k)
|
||||
|
||||
# Halbachsen (Standardabweichungen entlang Hauptachsen)
|
||||
s_max = s0_apost * np.sqrt(Q_dmax)
|
||||
s_min = s0_apost * np.sqrt(Q_dmin)
|
||||
|
||||
# Richtungswinkel theta (Hauptachse) in rad:
|
||||
theta_rad = 0.5 * np.arctan2(2 * Qyx_, (Qxx_ - Qyy_))
|
||||
|
||||
# in gon
|
||||
theta_gon = theta_rad * (200 / np.pi)
|
||||
if theta_gon < 0:
|
||||
theta_gon += 200.0
|
||||
|
||||
data.append([
|
||||
punkt,
|
||||
float(sx), float(sy), float(sxy),
|
||||
float(s_max), float(s_min),
|
||||
float(theta_gon)
|
||||
])
|
||||
|
||||
standardellipse = pd.DataFrame(data, columns=["Punkt", "σx", "σy", "σxy", "s_max", "s_min", "θ [gon]"])
|
||||
return standardellipse
|
||||
|
||||
|
||||
@staticmethod
|
||||
def berechne_konfidenzellipsen(Qxx: np.ndarray, s0: float, r: int, punkt_namen: list,
|
||||
wahrscheinlichkeit: float = 0.95):
|
||||
# Quantil der F-Verteilung (df1=2 für die Ebene, df2=r für Redundanz)
|
||||
f_quantil = f_dist.ppf(wahrscheinlichkeit, 2, r)
|
||||
k_faktor = np.sqrt(2 * f_quantil)
|
||||
|
||||
standard_ellipsen = Genauigkeitsmaße.berechne_standardellipsen(Qxx, s0, punkt_namen)
|
||||
konfidenz_ellipsen = []
|
||||
for ell in standard_ellipsen:
|
||||
konfidenz_ellipsen.append({
|
||||
"name": ell['name'],
|
||||
"a": ell['a'] * k_faktor,
|
||||
"b": ell['b'] * k_faktor,
|
||||
"theta": ell['theta'],
|
||||
"prob": wahrscheinlichkeit,
|
||||
"k_faktor": k_faktor
|
||||
})
|
||||
return konfidenz_ellipsen
|
||||
def konfidenzellipse(Qxx, s0_apost, unbekannten_liste, R, alpha=0.05):
|
||||
Qxx = np.asarray(Qxx, float)
|
||||
|
||||
data = []
|
||||
n_punkte = len(unbekannten_liste) // 3 # X,Y,Z je Punkt angenommen
|
||||
|
||||
k = float(np.sqrt(2.0 * f_dist.ppf(1.0 - alpha, 2, R)))
|
||||
|
||||
for i in range(n_punkte):
|
||||
punkt = str(unbekannten_liste[3 * i])[1:] # "X10009" -> "10009"
|
||||
|
||||
ix = 3 * i
|
||||
iy = 3 * i + 1
|
||||
|
||||
Qxx_ = Qxx[ix, ix]
|
||||
Qyy_ = Qxx[iy, iy]
|
||||
Qxy_ = Qxx[iy, ix] # = Qyx
|
||||
|
||||
# k für Eigenwerte
|
||||
kk = np.sqrt((Qxx_ - Qyy_) ** 2 + 4 * (Qxy_ ** 2))
|
||||
Q_dmax = 0.5 * (Qxx_ + Qyy_ + kk)
|
||||
Q_dmin = 0.5 * (Qxx_ + Qyy_ - kk)
|
||||
|
||||
# Standard-Halbachsen (1-sigma)
|
||||
s_max = s0_apost * np.sqrt(Q_dmax)
|
||||
s_min = s0_apost * np.sqrt(Q_dmin)
|
||||
|
||||
# Orientierung (Hauptachse) in gon
|
||||
theta_rad = 0.5 * np.arctan2(2 * Qxy_, (Qxx_ - Qyy_))
|
||||
theta_gon = theta_rad * (200 / np.pi)
|
||||
if theta_gon < 0:
|
||||
theta_gon += 200.0
|
||||
|
||||
# Konfidenz-Halbachsen
|
||||
a_K = k * s_max
|
||||
b_K = k * s_min
|
||||
|
||||
data.append([punkt, float(a_K), float(b_K), float(theta_gon)])
|
||||
|
||||
konfidenzellipsen = pd.DataFrame(data, columns=["Punkt", "a_K", "b_K", "θ [gon]"])
|
||||
return konfidenzellipsen
|
||||
|
||||
|
||||
|
||||
@staticmethod
|
||||
|
||||
Reference in New Issue
Block a user