mp.dm_converter

class mp.dm_converter

Bases: mp.element_container

mp.dm_converter - Abstract base class for MATPOWER data model converter objects.

A data model converter provides the ability to convert data between a data model and a specific data source or format, such as the PSS/E RAW format or version 2 of the MATPOWER case format. It is used, for example, during the import stage of the data model build process.

A data model converter object is primarily a container for data model converter element (mp.dmc_element) objects. Concrete data model converter classes are specific to the type or format of the data source.

By convention, data model converter variables are named dmc and data model converter class names begin with mp.dm_converter.

mp.dm_converter Methods:
  • format_tag() - return char array identifier for data source/format

  • copy() - make duplicate of object

  • build() - create and add element objects

  • import() - import data from a data source into a data model

  • export() - export data from a data model to a data source

  • init_export() - initialize a data source for export

  • save() - save data source to a file

  • display() - display the data model converter object

See the Data Model Converter Object section in the MATPOWER Developer’s Manual for more information.

See also mp.data_model, mp.task.

Method Summary
format_tag()

Return a short char array identifier for data source/format.

tag = dmc.format_tag()

E.g. the subclass for the MATPOWER case format returns 'mpc2'.

Note: This is an abstract method that must be implemented by a subclass.

copy()

Create a duplicate of the data model converter object, calling the copy() method on each element.

new_dmc = dmc.copy()
build()

Create and add data model converter element objects.

dmc.build()

Create the data model converter element objects by instantiating each class in the element_classes property and adding the resulting object to the elements property.

import(dm, d)

Import data from a data source into a data model.

dm = dmc.import(dm, d)
Inputs:
Output:

dm (mp.data_model) – updated data model

Calls the import() method for each data model converter element and its corresponding data model element.

export(dm, d)

Export data from a data model to a data source.

d = dmc.export(dm, d)
Inputs:
Output:

d – updated data source

Calls the export() method for each data model converter element and its corresponding data model element.

init_export(dm)

Initialize a data source for export.

d = dmc.export(dm)
Input:

dm (mp.data_model) – data model

Output:

d – new empty data source, type depends on the implementing subclass (e.g. MATPOWER case struct for mp.dm_converter_mpc2)

Creates a new data source of the appropriate type in preparation for calling export().

save(fname, d)

Save data source to a file.

fname_out = dmc.save(fname, d)
Inputs:
  • fname (char array)

  • d – data source, type depends on the implementing subclass (e.g. MATPOWER case struct for mp.dm_converter_mpc2)

Output:

fname_out (char array) – final file name after saving, possibly modified from input (e.g. extension added)

Note: This is an abstract method that must be implemented by a subclass.

display()

Display the data model converter object.

This method is called automatically when omitting a semicolon on a line that retuns an object of this class.

Displays the details of the data model converter elements.