Expand description
The format hub: readers and writers for every supported file format, all
meeting at the shared Network.
Each format is one module here, owning its reader and/or writer: MATPOWER
.m, PowerModels JSON, PSS/E .raw, PowerWorld .aux, egret
ModelData JSON, pandapower JSON, and PyPSA CSV folders. PowerWorld .pwb
cases and .pwd displays are read only. Case input and output formats meet
at the hub, so adding a format is one module, not a change to any other.
parse_file reads Network cases, detecting the format from its extension;
parse_display_file reads display artifacts such as PowerWorld .pwd.
write_as
serializes a Network to text targets.
Writers for directory formats, such as PyPSA CSV folders, expose explicit
filesystem helpers. Non-finite numeric values (a MATPOWER Inf/NaN angle
limit, say) are written as JSON null.
§Fidelity contract
Conversion is two-tier:
- Same format writes return the original text. A reader keeps its source
text (see
Network), 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.
Modules§
- powerworld
- Read and write PowerWorld auxiliary
.auxfiles.
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 every format except pandapower JSON and PyPSA CSV; the PSS/E and PowerWorld reductions are documented in docs/format-fidelity.md, not reported here yet).
- PwdDisplay
- Decoded PowerWorld display file content.
- PwdSubstation
- One substation symbol from a display file: the identity row joined with
its drawing record, in identity table (display) order.
xandyare diagram coordinates as stored, y north positive (see the module docs). - Pypsa
CsvOutputs
Enums§
- Display
Data - Output of a display parse. v0.2.2 supports PowerWorld
.pwd; future display formats can add variants without changing the parse entry point. - Display
Format - A display artifact format. These files are not power network cases and do
not parse to
Network. - 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_
str - Convert in-memory case
textof the namedformat(seetarget_format_from_name) toto. - display_
format_ from_ name - Map a display format name to a
DisplayFormat, orNoneif unrecognized. Acceptspwd,powerworld-pwd, andpowerworld-display. - 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. v0.2.2 infers PowerWorld.pwd. - parse_
egret_ json - Parse egret
ModelDataJSON into aNetwork. - parse_
file - Parse the case file at
path, choosing the reader fromfrom(thetarget_format_from_namenames pluspypsa-csv/pypsaandpwb) 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), case-insensitively (issue #97:.RAWis as common as.rawin the wild). A.jsonfile is sniffed three ways: pandapower ("_class": "pandapowerNet"), egret (top levelelementsandsystem), else PowerModels. Passfromto force one..pwbbinaries are read only and carry no retained source. ReturnsParsed: the network plus the reader’s fidelity warnings. - parse_
matpower - Parse the MATPOWER case in
contentinto aNetwork. - 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
Network. Loads and shunts are read as first-class 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_
powerworld - Parse a PowerWorld
.auxinto aNetwork, reading the Bus/Load/Shunt/ Gen/BranchDATAblocks by their declared field lists. - parse_
psse - Parse a PSS/E v33
.rawinto aNetwork. Reads bus/load/fixed-shunt/ generator/branch/2-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. - 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. 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 are directory inputs with no text target; their aliases are matched by the privateis_pypsa_csv_namenext to this. - write_
as - Convert a
Networktoformat. Writing back to the source format returns the retained source text; otherwise the network is serialized into the target. - 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_
powerworld - write_
psse - write_
pypsa_ csv_ folder