Expand description
Readers and writers for supported case formats, all meeting at BalancedNetwork.
Each format module owns its reader and/or writer: MATPOWER .m,
PowerModels JSON, PSS/E .raw, PowerWorld .aux, egret ModelData JSON,
pandapower JSON, PyPSA CSV folders, PSLF .epc, GO Challenge 3 JSON, and
Surge JSON, and DeepMind OPFData JSON. PowerWorld .pwb cases, GO Challenge
3 and OPFData JSON canonical output, and PowerWorld .pwd displays are read
only. Case input and
output formats meet here, so adding a writable format is one module plus
one hub registration.
parse_file reads BalancedNetwork cases, detecting the format from its extension;
parse_display_file reads display artifacts such as PowerWorld .pwd.
write_as serializes a BalancedNetwork to text targets. Directory formats,
such as PyPSA CSV folders, use explicit filesystem helpers. Non-finite
numeric values, such as MATPOWER Inf/NaN angle limits, are written as
JSON null.
§Fidelity behavior
Conversion is two-tier:
- Same format writes return the original text. A reader keeps its source
text (see
BalancedNetwork), so writing back 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 in the
Conversionwarnings, never dropped silently. On the read side, readers itemize what they ignore inParsedwarnings.
Re-exports§
pub use powerworld::PwdDisplay;pub use powerworld::PwdSubstation;pub use powerworld::parse_powerworld;pub use powerworld::write_powerworld;
Modules§
- powerworld
- Read and write PowerWorld auxiliary
.auxfiles. - routing
- Shared format alias and JSON shape routing for the
poweriocrate.
Structs§
- Conversion
- Output of a conversion: the serialized text plus any fidelity warnings:
data the target can’t represent, defaults synthesized, or blocks mapped best
effort. An empty
warningsmeans a faithful conversion. Forconvert_fileandconvert_str,warningscarries the read side (Parsedwarnings) too, ahead of the write side. - Parsed
- Output of a parse: the network plus the reader’s fidelity warnings, tables and columns the model cannot carry, reported instead of dropped silently. Empty for readers that don’t report read warnings (currently readers that do not need to reduce any source fields).
- Pypsa
CsvOutputs - Write
Options - Optional write-time policies layered on top of the neutral
BalancedNetwork.
Enums§
- Display
Data - Output of a display parse. PowerWorld
.pwdproducesDisplayData::PowerWorld; a geographic sidecar producesDisplayData::Geo. - Display
Format - A display artifact format. These files are not power network cases and do
not parse to
BalancedNetwork. - Source
Document - A format’s source document, parsed once by the reader and handed forward so
downstream adapters derive their data from the same parse instead of
reparsing the retained source text. Today that is the GOC3 document, which
the operating point extractor in
powerio-pkgconsumes. - Target
Format - A target interchange format. See
write_as.
Functions§
- convert_
file - Convert a case file to
to, optionally forcing the source format withfrom. - convert_
file_ with_ options - Convert a case file with write-time cost policies.
- convert_
str - Convert in-memory case
textof the namedformat(seetarget_format_from_name) toto. - convert_
str_ with_ options - Convert in-memory case text with write-time cost policies.
- display_
format_ from_ name - Map a display format name to a
DisplayFormat, orNoneif unrecognized. Acceptspwd,powerworld-pwd, andpowerworld-display;geojson,geo-json, andgeoname the geographic layer. - parse_
bytes - Parse in-memory case
bytesof the namedformat. Accepts every nameparse_strdoes, pluspwb: PowerWorld binary has no text form, so this is the only in-memory entry point that reaches it. Text formats decode as UTF-8 and take theparse_strpath from there. - parse_
bytes_ with_ name parse_byteswith a name hint, asparse_str_with_nameis toparse_str.- parse_
deepmind_ opfdata_ json - Parse one raw FullTop or N-1 DeepMind OPFData JSON document as a solved snapshot. The reader does not assume a case name or fixed element counts.
- parse_
display_ bytes - Parse display bytes in the named display
format. - parse_
display_ file - Parse the display file at
path, choosing the reader fromfromor, whenNone, from the extension. A.pwdextension selects PowerWorld display data. - parse_
egret_ json - Parse egret
ModelDataJSON into aBalancedNetwork. - parse_
file - Parse the case file at
path, choosing the reader fromfrom(thetarget_format_from_namenames pluspypsa-csv/pypsa,pwb,pslf, andepc) or, whenNone, from the path: a directory containingnetwork.csvparses as a PyPSA CSV folder (any other directory fails:Error::UnknownFormatwhen its name maps to no extension, the I/O error otherwise), and a file maps by extension (m/json/raw/aux/pwb/epc), case insensitively (issue #97:.RAWis as common as.rawin the wild). A.jsonfile is classified by top level shape markers: pandapower ("_class": "pandapowerNet"), egret (elementsandsystem), GO Challenge 3 (networkplustime_series_input/reliability), Surge JSON (format: "surge-json"), OPFData (grid,solution, andmetadata), powerio-json (busesplus network keys), and PowerModels JSON (baseMVA,branch,gen, orgencost). JSON matching distribution markers, ambiguous markers, or no known markers returnsError::UnknownFormat. Passfromto force a transmission format. PowerWorld.pwbis a binary read only format with no retained source; PSLF.epcis text and has a writer. ReturnsParsed: the network plus the reader’s fidelity warnings. - parse_
goc3_ json - Parse a GO Challenge 3 JSON input file.
- parse_
matpower - Parse the MATPOWER case in
contentinto aBalancedNetwork. - parse_
matpower_ file - Parse the MATPOWER case at
path, using the file stem as the network name. - parse_
pandapower_ json - Parse pandapower
pandapowerNetJSONcontent. ReturnsParsed: the network plus the reader’s fidelity warnings. - parse_
powermodels_ json - Parse PowerModels.jl network data JSON into a
BalancedNetwork. Loads and shunts are read as separate elements and the raw text is retained, so writing back to PowerModels JSON is a byte-exact echo.per_unit = trueinput (powerio’s own output, and PowerModels’ own export) is converted to the neutral MW/degree convention (powers ×baseMVA, angles to degrees, cost coefficients un-scaled), following PowerModels’ own exceptions (storageps/qsstay raw, dclinept/qf/qtflip sign);per_unit = falseis read as-is. - parse_
pslf - Parse a PSLF
.epccase into aBalancedNetwork. - parse_
psse - Parse a PSS/E
.raw(revisions 33-35) into aBalancedNetwork. Reads bus/load/ fixed-shunt/generator/branch/2- and 3-winding transformer; skips the advanced sections. - parse_
str - Parse in-memory case
textof the namedformat(seetarget_format_from_name). ReturnsParsed: the network plus the reader’s fidelity warnings. - parse_
str_ with_ name parse_strwith a name hint for formats that carry no name of their own (the role the file stem plays inparse_file). Lets a caller that already read a file’s text keep the stem-derived case name without going back through the filesystem.- parse_
surge_ json - read_
pypsa_ csv_ folder - Read a PyPSA CSV folder at
path. ReturnsParsed: the network plus the reader’s fidelity warnings. - target_
format_ from_ name - 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, andopfdata-json/opfdata/gridopt. Thepowerio-json/powerio/jsonnames remain compatibility aliases for the model JSON methods. Case-insensitive. The one place the bindings (Python, C ABI) share, so a new text format means one new arm here, not three. PyPSA CSV folders, GridFM datasets, and PowerWorld.pwbare directory or read only inputs with no text target; they are routed bycrate::format::routing. - write_
as - Convert a
BalancedNetworktoformat. Writing back to the source format returns the retained source text; otherwise the network is serialized into the target. - write_
as_ with_ options - Convert a
BalancedNetworkwith write-time cost policies. The oldwrite_asbehavior is preserved whenoptionsis default. - write_
dir - Write
netintoout_diras the named directory format. This function dispatches directory format names for the bindings. PyPSA CSV (pypsa-csv/pypsa) is the one such format today; a text format name is rejected by name, pointing atwrite_as. Returns the write’s fidelity warnings. - write_
egret_ json - write_
matpower - Serialize
netto MATPOWER.mtext. Echoes the retained source verbatim whennetcame from MATPOWER; otherwise emits canonical.m. - write_
pandapower_ json - write_
powermodels_ json - write_
pslf - Serialize
netto PSLF.epctext. - write_
psse - Serialize
netto PSS/E.rawat the default revision (33). - write_
psse_ rev - Serialize
netto PSS/E.rawatrev(33, 34, or 35). - write_
pypsa_ csv_ folder - write_
surge_ json