# Created: 2026-06-05
# (c) Copyright 2025 ETH Zurich
#
# Licensed under the GNU General Public License v3.0;
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
#
# https://www.gnu.org/licenses/gpl-3.0.en.html
#
# This software is distributed "AS IS", WITHOUT WARRANTY OF ANY KIND,
# express or implied. See the License for specific language governing
# permissions and limitations under the License.
"""Byte-identical EST baseline gate for the inverter estimation path (Phase 0).
Runs the recursive estimator (iekf) over the IEEE39_bus_inverter estimation model
-- which carries both a GridForming and a GridFollowing (GFLI7_est at bus 36)
tracking the faulted simulation -- and compares the estimated state trajectory
against the pickled reference at atol=1e-5. Guards the estimation path (qcall,
algebraic-equation weights, finit), for both GFM and GFL, through the refactor.
"""
import pickle
import numpy as np
from pydynamicestimator.tests.baselines.inverter_baseline import (
BASELINES,
run_inverter_case,
)
[docs]
def test_run():
with open(BASELINES["est"], "rb") as file:
est_base = pickle.load(file)
est_x = run_inverter_case("est")
assert np.allclose(
est_x, est_base, atol=1e-5
), "The inverter EST trajectory did not match the byte-identical baseline"