Skip to content

Export: CIM → DistOPF

The exporter converts a CIM FeederModel into the per-type CSV files that DistOPF consumes.

Write CSV Files

from cimhub_distopf.exporter.cim_to_distopf import cim_to_distopf

output_path = cim_to_distopf(feeder, "/path/to/output/")

The output directory receives one CSV per record type:

CSV file Record Source CIM class(es)
bus_data BusRecord ConnectivityNode
branch_data BranchRecord ACLineSegment, PowerTransformer, LoadBreakSwitch / Breaker / Fuse / Recloser
gen_data GeneratorRecord PowerElectronicsConnection (PV / generation)
cap_data CapacitorRecord LinearShuntCompensator
bat_data BatteryRecord BatteryUnit
reg_data RegulatorRecord RatioTapChanger
schedules ScheduleRecord schedules / load shapes

Each converter is registered against its CIM class via @distopf_exporter_registry.register(CIMClass); the orchestrator dispatches every graph object to its registered converter.

In-Memory DataFrames

Pass output_dir=None to get the DataFrames back instead of writing files:

frames = cim_to_distopf(feeder)          # dict: "bus_data" -> pandas.DataFrame, ...
frames["bus_data"].head()

Loading from CIM XML

For convenience, a path to a CIM XML file is accepted in place of a FeederModel; it is loaded into a FeederModel before export:

cim_to_distopf("/path/to/model.xml", "/path/to/output/")