pwrs.core.ext2int#
- pwrs.core.ext2int.ext2int_mpc(case, config=None, reorder_gens=0)[source]#
Convert a MATPOWER case struct from external to internal indexing.
- Parameters:
mpc (MatpowerCase) – MATPOWER case struct in external order.
config (MatpowerConfig or None, optional) – Configuration options for user-defined functions, by default None.
reorder_gens (int, optional) – Whether to reorder generators by their connected bus number, by default 0 (False).
case (MatpowerCase | CaseData)
- Returns:
MATPOWER case struct in internal order, with
ordermetadata.- Return type:
- pwrs.core.ext2int.ext2int_old(bus, gen, branch, areas=None)[source]#
Convert bus, gen, branch (and optionally areas) data from external to internal indexing.
This legacy helper function supports the old MATLAB-style call forms for
ext2intthat operate directly on the bus, gen, branch, and areas matrices. It is not recommended for use in new code; use ext2int_mpc() instead.The bus, gen, and branch matrices are modified in-place to convert from external to internal numbering. The returned
i2evector maps internal bus indices to external bus numbers.- Parameters:
bus (npt.NDArray[np.float64]) – Bus matrix.
gen (npt.NDArray[np.float64]) – Generator matrix.
branch (npt.NDArray[np.float64]) – Branch matrix.
areas (npt.NDArray[np.float64] or None, optional) – Areas matrix, or None if not provided.
- Returns:
(i2e, bus, gen, branch, areas)wherei2eis a column vector mapping internal bus indices to external bus numbers, and the bus, gen, branch, and areas matrices have been modified in-place to use internal numbering.- Return type:
tuple
- pwrs.core.ext2int.ext2int(*args)[source]#
Convert MATPOWER data from external to internal indexing.
This Python port supports only the two primary MATPOWER forms:
mpc = ext2int(mpc)mpc = ext2int(mpc, mpopt)mpc = ext2int(mpc, mpopt, reorder_gens)i2e, bus, gen, branch = ext2int(bus, gen, branch)i2e, bus, gen, branch, areas = ext2int(bus, gen, branch, areas)
The deprecated helper-call forms from MATLAB,
ext2int(mpc, val, ordering, dim)andext2int(mpc, 'field', ordering, dim), are intentionally not supported here. Use e2i_data() or e2i_field() directly instead.- Parameters:
*args (tuple) – Positional arguments for either the MATPOWER case-struct form or the legacy matrix form.
- Returns:
Internal-order MATPOWER case struct, or the legacy matrix-form outputs with ordering metadata.
- Return type:
dict or tuple