qlroms.utils.metrics
Lightweight diagnostic metrics used to compare ROM trajectories against the FOM.
dominant_frequency(signal, dt)
Frequency of the highest peak of the Hann-windowed periodogram of a 1D signal (mean removed).
The resolution is 1 / (len(signal) * dt); use a long record (many periods) for a sharp estimate.
Source code in qlroms/utils/metrics.py
39 40 41 42 43 44 45 46 47 | |
relative_error_series(X_ref, X_approx, eps=1e-12, *, Mw=None)
Per-snapshot relative error of (N, T) column-trajectory tensors (torch), in the M metric of Mw: ||x - x_hat||_M / ||x||_M (plain 2-norms for None / uniform weights).
Source code in qlroms/utils/metrics.py
98 99 100 101 102 103 104 105 106 107 108 109 110 111 | |
one_step_errors_series(X, model)
Open-loop one-step-ahead error: at every snapshot i, step the model ONE step forward from the TRUE state x_i (not from its own previous prediction) and compare to the TRUE next snapshot x_{i+1}. Unlike a free multi-step run, errors here cannot accumulate across steps -- this isolates the one-step fit quality itself (and, for a quantized-local model, shows up as error spikes right at cluster-boundary snapshots).
Source code in qlroms/utils/metrics.py
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | |
reconstruction_error_series(X, model)
Pure POD projection+reconstruction relative error per snapshot -- NO dynamics/ time-stepping: for the nearest cluster k, a = Phi_k^T Mw (x - c_k), x_hat = c_k + Phi_k a. Isolates how well the fitted basis alone represents each snapshot, independent of the model's fitted dynamics (contrast one_step_errors_series).
Source code in qlroms/utils/metrics.py
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | |
prediction_horizon(rel_err, dt, threshold=0.5)
First time (in physical units) at which rel_err exceeds threshold, matching
the ql-ROM papers' T_ph definition (normalized-error threshold, default tau=0.5).
Source code in qlroms/utils/metrics.py
159 160 161 162 163 164 | |