This release is a pre-release and may not be stable for production use.
cimhub_gridlabd
Bidirectional converter between GridLAB-D (GLM) and CIM (IEC 61968/61970) using the cimhub_2026 profile.
Usage
GLM to CIM (Import)
import os
os.environ['CIMG_USE_UNITS'] = 'TRUE'
os.environ['CIMG_CIM_PROFILE'] = 'cimhub_2026'
from cimhub_gridlabd.importer.glm_to_cim import glm_to_cim
feeder = glm_to_cim("/path/to/IEEE13.glm")
CIM to GLM (Export)
Export is two steps: build the GLM model, then write it.
from cimhub_gridlabd.exporter.cim_to_glm import GlmExporter
from cimhub_gridlabd.exporter.glm_text_writer import GlmTextWriter
glm_model = GlmExporter().to_model(feeder)
GlmTextWriter().write(glm_model, "/path/to/IEEE13.glm")
to_model returns an in-memory GraphModel of GLM dataclasses, so you can
inspect or edit the model before it is serialized.
JSON variant
Swap in the GLM-JSON writer (one object per JSON entry, grouped by class):
from cimhub_gridlabd.exporter.cim_to_glm import GlmExporter
from cimhub_gridlabd.exporter.glm_writer import GlmJsonWriter
glm_model = GlmExporter().to_model(feeder)
GlmJsonWriter().write(glm_model, "/path/to/IEEE13.json")
Or use the one-line convenience wrapper:
from cimhub_gridlabd.exporter.cim_to_glm import cim_to_glm_json
cim_to_glm_json(feeder, "/path/to/IEEE13.json")
Architecture
The package follows the standard CIMHub four-layer pipeline:
LinkML YAML → glm_schema.py → GraphModel → GlmReader / GlmWriter
↕
GlmImporter / GlmExporter
The writer is annotation-driven: LinkML slot annotations (native_name, glm_unit, etc.) control how each CIM field maps to a GLM attribute without hard-coded per-class logic. See GLM_LINKML_ARCHITECTURE.md for the full design.
Equipment Coverage
| Element | Import | Export |
|---|---|---|
| Overhead lines (geometry) | ✓ | ✓ |
| Underground cables | ✓ | ✓ |
| Transformers | ✓ | ✓ |
| Regulators | ✓ | ✓ |
| Capacitor banks | ✓ | ✓ |
| Loads | ✓ | ✓ |
| Switches / reclosers / fuses | ✓ | ✓ |
| DER (PV, battery) | partial | partial |
Running Tests
uv run pytest cimhub_gridlabd/tests/ -v
Notes
- Never substitute a computed impedance matrix for conductor geometry. When
WireSpacingInfois present, export it as native GridLAB-Dline_spacing+overhead_line_conductorobjects. Seecimhub_core/development/CONDUCTOR_GEOMETRY_ANTI_PATTERNS.md. - Python complex literals (
+0.79+0.43j) are not valid GLM syntax — the writer uses explicitr/xfields. - Phase lookups must traverse from
ACLineSegment.ACLineSegmentPhases, not fromWireSpacingInfo.ACLineSegment[0](that list can be empty).
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cimhub_gridlabd-2.0.0a1.tar.gz.
File metadata
- Download URL: cimhub_gridlabd-2.0.0a1.tar.gz
- Upload date:
- Size: 387.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f567ae8f6d6d119b342ecff398984f27575979b454fcab26f12ac07284410a31
|
|
| MD5 |
5e89e25200c0da4693d970eef648bac2
|
|
| BLAKE2b-256 |
fb28ef11a8f262db76fc04fdef79606cb6e8227a1388b1027e1bb190b9b33abd
|
Provenance
The following attestation bundles were made for cimhub_gridlabd-2.0.0a1.tar.gz:
Publisher:
publish-cimhub-gridlabd.yml on PNNL-CIM-Tools/CIMHub
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cimhub_gridlabd-2.0.0a1.tar.gz -
Subject digest:
f567ae8f6d6d119b342ecff398984f27575979b454fcab26f12ac07284410a31 - Sigstore transparency entry: 2523629219
- Sigstore integration time:
-
Permalink:
PNNL-CIM-Tools/CIMHub@1b73b91d85485ed800952094156d04858b0081d3 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/PNNL-CIM-Tools
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-cimhub-gridlabd.yml@1b73b91d85485ed800952094156d04858b0081d3 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file cimhub_gridlabd-2.0.0a1-py3-none-any.whl.
File metadata
- Download URL: cimhub_gridlabd-2.0.0a1-py3-none-any.whl
- Upload date:
- Size: 428.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
80513945e6dc89fcacb7b89979ba8a530c604b2a1d6ff086df3df096b8ec577e
|
|
| MD5 |
c1e443ec5a30f4bc7877d09ecee98ecf
|
|
| BLAKE2b-256 |
1f8d24b766adc74c76e2abcb73671a706e8f41f04d17fb716f1a550554c89b75
|
Provenance
The following attestation bundles were made for cimhub_gridlabd-2.0.0a1-py3-none-any.whl:
Publisher:
publish-cimhub-gridlabd.yml on PNNL-CIM-Tools/CIMHub
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cimhub_gridlabd-2.0.0a1-py3-none-any.whl -
Subject digest:
80513945e6dc89fcacb7b89979ba8a530c604b2a1d6ff086df3df096b8ec577e - Sigstore transparency entry: 2523629280
- Sigstore integration time:
-
Permalink:
PNNL-CIM-Tools/CIMHub@1b73b91d85485ed800952094156d04858b0081d3 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/PNNL-CIM-Tools
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-cimhub-gridlabd.yml@1b73b91d85485ed800952094156d04858b0081d3 -
Trigger Event:
workflow_dispatch
-
Statement type: