Skip to main content

Module format

Module format 

Source
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 Conversion warnings, never dropped silently. On the read side, readers itemize what they ignore in Parsed warnings.

Modules§

powerworld
Read and write PowerWorld auxiliary .aux files.

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 warnings means a faithful conversion. For convert_file and convert_str, warnings carries the read side (Parsed warnings) 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. x and y are diagram coordinates as stored, y north positive (see the module docs).
PypsaCsvOutputs

Enums§

DisplayData
Output of a display parse. v0.2.2 supports PowerWorld .pwd; future display formats can add variants without changing the parse entry point.
DisplayFormat
A display artifact format. These files are not power network cases and do not parse to Network.
TargetFormat
A target interchange format. See write_as.

Functions§

convert_file
Convert a case file to to, optionally forcing the source format with from.
convert_str
Convert in-memory case text of the named format (see target_format_from_name) to to.
display_format_from_name
Map a display format name to a DisplayFormat, or None if unrecognized. Accepts pwd, powerworld-pwd, and powerworld-display.
parse_display_bytes
Parse display bytes in the named display format.
parse_display_file
Parse the display file at path, choosing the reader from from or, when None, from the extension. v0.2.2 infers PowerWorld .pwd.
parse_egret_json
Parse egret ModelData JSON into a Network.
parse_file
Parse the case file at path, choosing the reader from from (the target_format_from_name names plus pypsa-csv/pypsa and pwb) or, when None, from the path: a directory containing network.csv parses as a PyPSA CSV folder (any other directory fails: Error::UnknownFormat when 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: .RAW is as common as .raw in the wild). A .json file is sniffed three ways: pandapower ("_class": "pandapowerNet"), egret (top level elements and system), else PowerModels. Pass from to force one. .pwb binaries are read only and carry no retained source. Returns Parsed: the network plus the reader’s fidelity warnings.
parse_matpower
Parse the MATPOWER case in content into a Network.
parse_matpower_file
Parse the MATPOWER case at path, using the file stem as the network name.
parse_pandapower_json
Parse pandapower pandapowerNet JSON content. Returns Parsed: 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 = true input (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 (storage ps/qs stay raw, dcline pt/qf/qt flip sign); per_unit = false is read as-is.
parse_powerworld
Parse a PowerWorld .aux into a Network, reading the Bus/Load/Shunt/ Gen/Branch DATA blocks by their declared field lists.
parse_psse
Parse a PSS/E v33 .raw into a Network. Reads bus/load/fixed-shunt/ generator/branch/2-winding-transformer; skips the advanced sections.
parse_str
Parse in-memory case text of the named format (see target_format_from_name). Returns Parsed: the network plus the reader’s fidelity warnings.
read_pypsa_csv_folder
Read a PyPSA CSV folder at path. Returns Parsed: the network plus the reader’s fidelity warnings.
target_format_from_name
Map a format name (with the common aliases) to a TargetFormat, or None if unrecognized. Accepts matpower/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 private is_pypsa_csv_name next to this.
write_as
Convert a Network to format. 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 net to MATPOWER .m text. Echoes the retained source verbatim when net came from MATPOWER; otherwise emits canonical .m.
write_pandapower_json
write_powermodels_json
write_powerworld
write_psse
write_pypsa_csv_folder