State Estimation and Measurements Reference
Sparlectra.Measurement — Type
MeasurementGeneric state-estimation measurement model.
Fields:
typ: Measurement type.value: Measured value (Vm in p.u., powers in MW/MVar).sigma: Standard deviation in measurement units.weight: Weight used in WLS (1/sigma^2).active: Iffalse, measurement is ignored by estimator.busIdx: Bus index for bus measurements.branchIdx: Branch index for branch flow measurements.direction: Branch direction:fromor:to, otherwise:none.id: Optional measurement identifier.
Sparlectra.MeasurementType — Type
@enum MeasurementTypeSupported measurement types for the first WLS state-estimation implementation.
Sparlectra.addMeasurement! — Method
addMeasurement!(measurements; typ, value, sigma, active=true, busIdx=nothing, branchIdx=nothing, direction=:none, id="")Append a state-estimation measurement to measurements and return it.
Sparlectra.addPflowMeasurement! — Method
addPflowMeasurement!(measurements; net, value, sigma, direction=:from, branchNr=nothing, fromBus=nothing, toBus=nothing, active=true, id="")Append an active-power flow measurement identified by branchNr or a unique fromBus/toBus branch pair.
Sparlectra.addPinjMeasurement! — Method
addPinjMeasurement!(measurements; net, busName, value, sigma, active=true, id="")Append an active-power injection measurement identified by busName.
Sparlectra.addQflowMeasurement! — Method
addQflowMeasurement!(measurements; net, value, sigma, direction=:from, branchNr=nothing, fromBus=nothing, toBus=nothing, active=true, id="")Append a reactive-power flow measurement identified by branchNr or a unique fromBus/toBus branch pair.
Sparlectra.addQinjMeasurement! — Method
addQinjMeasurement!(measurements; net, busName, value, sigma, active=true, id="")Append a reactive-power injection measurement identified by busName.
Sparlectra.addVmMeasurement! — Method
addVmMeasurement!(measurements; net, busName, value, sigma, active=true, id="")Append a bus voltage-magnitude measurement identified by busName.
Sparlectra.addZeroInjectionMeasurements! — Method
addZeroInjectionMeasurements!(measurements; net, sigma=1e-6, busNames=nothing, busIdxs=nothing, active=true, idPrefix="ZI") -> Vector{Measurement}Append active- and reactive-power zero-injection pseudo-measurements for the selected buses and return the newly added measurements.
Selection rules:
- If
busIdxsis provided, those indices are used. - Else if
busNamesis provided, names are resolved to indices. - Else passive buses are detected automatically via
findPassiveBuses(net).
These pseudo-measurements are the current way to encode equality constraints P_inj = 0 and Q_inj = 0 in the WLS estimator.
Sparlectra.findPassiveBuses — Method
findPassiveBuses(net; atol=1e-9, includeSlack=false) -> Vector{Int}Return bus indices that have no generation, no load, and no shunt contribution within the given tolerance atol.
This is useful for state-estimation workflows where passive / transit buses are often modeled through zero-injection pseudo-measurements.
Sparlectra.generateMeasurementsFromPF — Method
generateMeasurementsFromPF(net; kwargs...) -> Vector{Measurement}Generate synthetic measurements from the current solved network state.
Keyword options:
includeVm,includePinj,includeQinj,includePflow,includeQflownoise: add Gaussian noise iftruestddev: dictionary fromMeasurementType => sigmarng: random number generator
Sparlectra.measurementStdDevs — Method
measurementStdDevs(; vm=0.005, pinj=1.0, qinj=1.0, pflow=1.0, qflow=1.0)Create default standard-deviation map for synthetic measurement generation.
Sparlectra.SEResult — Type
SEResultResult container for the first classical WLS state-estimation run.
Sparlectra.evaluate_global_observability — Method
evaluate_global_observability(net, measurements; kwargs...) -> NamedTupleEvaluate global observability on active measurements using the finite-difference measurement Jacobian.
Includes global redundancy metrics
redundancy = r = m - nredundancy_ratio = ρ = m / ndof = ν = m - n
Quality classes:
:good: observable and no critical single measurement:critical: observable, but at least one single critical measurement (or ν <= 0):not_observable: not observable
Sparlectra.evaluate_local_observability — Method
evaluate_local_observability(net, measurements, stateCols; kwargs...) -> NamedTupleEvaluate local observability on selected Jacobian columns (stateCols).
Procedure:
- Build global Jacobian
Hfrom currently active measurements. - Keep only rows that have at least one nonzero entry in the selected columns. These rows correspond to measurements that are locally sensitive to the requested states.
- Evaluate observability/redundancy on the reduced matrix
Hlocal.
Returned NamedTuple extends global metrics with:
rows: selected row indices (within global active-Jacobian row numbering)stateCols: copied input state-column selection.
Interpretation:
:goodmeans local states are observable with positive redundancy and no single critical measurement.:criticalmeans still observable but vulnerable to a single outage (or ν <= 0).:not_observablemeans local states cannot be uniquely reconstructed.
Sparlectra.evaluate_local_observability_matrix — Method
evaluate_local_observability_matrix(H, stateCols; tol=nothing) -> NamedTupleEvaluate local observability on a matrix H restricted to selected stateCols.
Sparlectra.evaluate_observability_matrix — Method
evaluate_observability_matrix(H; tol=nothing) -> NamedTupleEvaluate global observability and single-row criticality directly on a matrix H (without building a network model).
Sparlectra.numeric_rank — Method
numeric_rank(A; tol=nothing) -> IntCompute numerical matrix rank using singular values.
Sparlectra.numerical_observable — Method
numerical_observable(H; tol=nothing) -> BoolNumerical observability test on a Jacobian-like matrix H. Returns true when rank(H) == n (full column rank).
Sparlectra.numerical_row_redundant — Method
numerical_row_redundant(H, i; tol=nothing) -> BoolCheck if row i remains numerically redundant in H.
Sparlectra.print_se_diagnostics — Method
print_se_diagnostics(io, diag; topN=10)Pretty-print diagnostics from validate_measurements or runse_diagnostics including:
- explanation of
global_consistency - tabular measurement ranking
- BAD/OK marker per measurement
- optional rerun comparison if present
Sparlectra.runse! — Method
runse!(net, measurements; kwargs...) -> SEResultRun a first classical nonlinear weighted least-squares state estimator.
State representation:
- bus voltage angles for all non-slack buses (radians)
- bus voltage magnitudes for all buses (p.u.)
Sparlectra.runse_diagnostics — Method
runse_diagnostics(net, measurements; deactivate_and_rerun=false, kwargs...) -> NamedTupleExtended diagnostics workflow around validate_measurements with optional deactivate-and-rerun logic for the currently largest suspicious measurement.
Sparlectra.structural_observable — Method
structural_observable(H) -> BoolStructural observability test on a Jacobian-like matrix H. Returns true when the maximum bipartite matching size equals the number of state columns n.
Sparlectra.structural_row_redundant — Method
structural_row_redundant(H, i) -> BoolCheck if row i remains structurally redundant in H.
Sparlectra.summarize_se_diagnostics — Method
summarize_se_diagnostics(diag) -> NamedTupleCreate a compact interpretation summary for a diagnostics object returned by validate_measurements or runse_diagnostics.
global_consistency is interpreted as:
true: SE converged and objective is inside χ²-like 3σ plausibility bandfalse: either non-convergence or implausibly large objective
Sparlectra.validate_measurements — Method
validate_measurements(net, measurements; kwargs...) -> NamedTupleRun state-estimation diagnostics on currently active measurements and return a machine-readable report with:
- global bad-data consistency check (
global_consistency) - χ²-like objective plausibility summary
- largest-normalized-residual ranking
- suspicious measurement list (threshold-based)