OpenDSS decks to CIM and back¶
cimhub-opendss reads an OpenDSS deck, writes it as
.cimtbl text, and builds an IEC CIM model (cim18v17) from that text. It also reads a CIM model
and writes a deck the engine compiles.
from cimhub_opendss import DssReader, cim_to_dss, dss_to_cim
model = DssReader("IEEE13_CDPSM.dss").read_all() # deck -> typed records
network = dss_to_cim(model, name="IEEE13_CDPSM") # records -> .cimtbl -> CIM network
cim_to_dss(network, "out/IEEE13_CDPSM.dss") # CIM network -> deck
dss_to_cim writes the model as .cimtbl text and builds the CIM network from that text, so the text you can read
and diff (pass artifact_dir= to keep it) is exactly what the model was built from. Values keep the deck's units;
the unit is in the column header. cim_to_dss reads the network back through the
CIMHub core getters, which convert once to the unit
DSS expects.
-
User guide
Install it, convert the IEEE 13-node feeder both ways, then import, export, round-trip checks and the list of DSS classes that convert.
-
Conversion reference
For each group of DSS classes, what each one becomes in CIM, how its properties map and where the two models differ.
-
Developer docs
The map of the code: reader and writer, importer, exporter, the LinkML schema, the tests and the rules a change keeps.
-
Schema reference
Every DSS class and property the reader knows, generated from the LinkML schema.
What the package does¶
| Step | Call | Result |
|---|---|---|
| Read | DssReader(path).read_all() |
a DssModel of typed records, with Redirects followed and Edits applied |
| Import | dss_to_cim(model, name=...) |
a cim18v17 network, built from .cimtbl text |
| Export | DssExporter().to_model(network) |
a DssModel again, from the CIM objects |
| Write | DssWriter().write(model, path) |
a deck the reader, the importer and the engine read |
Only the reader and the writer touch the filesystem. The quick start runs each step on a real deck.
- Geometry stays geometry. A
LineGeometryimports as aWireConfigurationand exports as aLineGeometry. No impedance matrix is computed in its place. - Nothing is guessed. An unknown property, an unmapped value or an unresolved reference raises with the name of
the DSS object. A DSS class no mapper reads is listed by count in the master
.cimtbl, so it never disappears silently. - Units are not converted by hand. Import copies values in the deck's units; export converts with the CIM
quantity's
.to().
CIMHub OpenDSS is one package of CIMHub. The other converters, and the landing page for all of them, are at CIMHub. The shared layer under every converter is CIMHub core.