MATPOWER

To communicate to MATPOWER to exchange network data these functions are available.

pandapower.converter.matpower.from_mpc(mpc_file, f_hz=50, casename_mpc_file='mpc', validate_conversion=False, load_case_engine=None, **kwargs)

This function converts a matpower case file version 2 to a pandapower net.

Note: If ‘mpc_file’ ends with ‘.m’ the python package ‘matpowercaseframes’ is used. If ‘mpc_file’ ends with ‘.mat’ ‘scipy.io.loadmat’ is used. Other file endings are not supported. In that other cases, please, rename the file ending or use the internal subfunctions. To run actual MATPOWER to load the .m file, use matpower-pip and pass load_case_engine.

Note: python is 0-based while Matlab is 1-based.

Parameters:
  • file (**mpc_file** - path to a matpower case)

  • **f_hz** (int, 50)

  • **casename_mpc_file** (str, 'mpc')

  • structure (the matpower case)

  • "gen" (i.e. the arrays)

  • "bus". ("branch" and)

  • **load_case_engine** (object, None)

  • Oct2Py ((e.g.)

  • matpowercaseframes.reader.parse_file. (data using)

  • from_ppc(). (****kwargs** - key word arguments for)

Returns:

net - The pandapower network

Example

>>> from pandapower.converter.matpower import from_mpc
>>>
>>> pp_net1 = from_mpc('case9.mat', f_hz=60)
>>> pp_net2 = from_mpc('case9.m', f_hz=60)
pandapower.converter.matpower.to_mpc(net, filename=None, **kwargs)

This function converts a pandapower net to a matpower case files (.mat) version 2. Note: python is 0-based while Matlab is 1-based.

Parameters:
  • net. (**net** - The pandapower)

  • **filename** (str, None) – the mpc will only be returned

  • documentation (****kwargs** - please look at to_ppc())

Example

>>> from pandapower.converter import to_mpc
>>> from pandapower.networks.power_system_test_cases import case9
>>>
>>> net = case9()
>>> to_mpc(net, "case9.mat")