Expand description
Parsing and emission for supported case formats, all meeting at BalancedNetwork.
Each format module owns its parser and/or serializer: MATPOWER .m,
PowerModels JSON, PSS/E .raw, PowerWorld .aux, egret ModelData JSON,
pandapower JSON, PyPSA CSV folders, PSLF .epc, PSS/E RAWX 35, PowSybl
XIIDM and JIIDM 1.0 through 1.17, CIM CGMES 2.4.15 and 3.0, GO Challenge 3 JSON,
Surge JSON, and
DeepMind OPFData JSON. PowerWorld .pwb cases, OPFData JSON, and the
IEEE Common Data Format are input
only. GO Challenge 3 defines a calculation rather than a bare network, so
its implementation is private to the powerio facade’s typed parser.
PowerWorld .pwd displays read through the top-level powerio::parse as a
powerio.GeoLayer. Case input and
output formats meet here, so adding a format that supports emission is one module plus
one hub registration.
parse compiles a retained source into a typed module, detecting the
format from the source name and content. emit emits a parsed
module through a destination and echoes the retained source for a same
format target.
Non-finite numeric values, such as MATPOWER Inf/NaN angle limits, are
emitted as JSON null.
§Fidelity behavior
Emission has two fidelity tiers:
- Same format emission of an unchanged parsed module returns the original
bytes. The module retains its source, so
emitback to the same format returns every field, comment, and numeric token. - Cross-format keeps maximal fidelity with itemized loss. Whatever the
target format cannot represent is reported by
EmitResult::diagnostics, never dropped silently. During parsing, parsers itemize what they ignore on the module’s diagnostics.
Re-exports§
pub use powerworld::PwdDisplay;pub use powerworld::PwdSubstation;
Modules§
- powerworld
- Parse and emit PowerWorld auxiliary
.auxfiles. - routing
- Shared format alias and JSON shape routing for the
poweriocrate.
Structs§
- Emit
Options - Optional emission policies layered on top of the neutral
BalancedNetwork.
Enums§
- Cgmes
Version - The CGMES release family a file set declares, from its
cimnamespace. - Target
Format - A target case format. See
emit.
Constants§
- SOURCE_
FORMAT_ NAMES - The source format names this crate recognizes, each with its aliases. A
recognized calculation format can still be refused with guidance to the
top level facade. The unknown format error prints this list, and a test walks
every alias through
routing::parse_transmission_formatso it cannot drift from the matcher.pypsa-csvnames a directory source andpwba binary one; every other name reads file and memory sources alike.
Functions§
- emit
- Emit a parsed module to
formatthrough a destination: the one output operation over file, memory, and (for the directory formats) folder output. Every text target commits a single artifact — a path destination names the exact file, a memory destination names the artifact — staged and renamed into place so a failed emission never exposes a partial target. The result carries the complete artifact inventory and the serializer’s findings. - emit_
with_ options emit()with generator cost policies.- is_
pypsa_ csv_ name - Whether a format name means a PyPSA CSV folder. PyPSA folders are directory
inputs, not text targets, so they have no
TargetFormatarm; this is the companion alias matcher toparse_target_formatand the one place the PyPSA aliases live. - parse
- Parse the case file at
path, choosing the parser fromfrom(theparse_target_formatnames pluspypsa-csv/pypsa,pwb,pslf, andepc) or, whenNone, from the path: a directory containingnetwork.csvparses as a PyPSA CSV folder (any other directory is refused as a directory withError::UnknownFormat, before extension inference), and a file maps by extension (m/json/raw/aux/pwb/epc), case insensitively (issue #97:.RAWis as common as.rawin the wild); a.txtor.cdffile whose first card is an IEEE CDF title card reads asieee-cdf. A.jsonfile is classified by top level shape markers: pandapower ("_class": "pandapowerNet"), egret (elementsandsystem), GO Challenge 3 (networkplustime_series_input/reliability, refused here with guidance to the typed facade parser), Surge JSON (format: "surge-json"), OPFData (grid,solution, andmetadata), and PowerModels JSON (baseMVA,branch,gen, orgencost). JSON matching distribution markers, ambiguous markers, or no known markers returnsError::UnknownFormat. Declare a format on the source to force a parser. PowerWorld.pwbis a binary input only format; PSLF.epcis text and supports emission. Returns the typed module: the network value, the parser’s findings, and the retained source. - parse_
format_ id - The declared format ID for a caller-supplied token. Tokens are matched case insensitively and accept the historical underscore spelling of a hyphenated alias; the ID itself keeps the stable lower case hyphen grammar.
- parse_
target_ format - Map a format name (with the common aliases) to a
TargetFormat, orNoneif unrecognized. Acceptsmatpower/m,powermodels-json/powermodels/pm,egret-json/egret,pandapower-json/pandapower/pp,psse/raw,powerworld/aux,pslf/epc,goc3-json/goc3, andsurge-json/surge,opfdata-json/opfdata/gridopt,xiidm,jiidm,cgmes, anducte/uct. Case-insensitive. The one place the bindings (Python, C ABI) share, so a new format means one new arm here, not three. CGMES emits a profile directory; PyPSA CSV folders, GridFM datasets, PowerWorld.pwb, and IEEE CDF cases are routed bycrate::format::routing.