krangpower.enhancer

The submodule krangpower.enhancer constitues an OpenDSSDirect.py wrapper and overhaul, and is designed to expose the exact same interface - the api reference is the same you can find in its docs. It is usable in and by itself as a substitute of the OpenDSSDirect.py module when interested in the additional functionality.

This means that if:

import opendssdirect  # the OpenDSSDirect.py module
opendssdirect.dss.<X>

is a valid expression, then:

import krangpower
krangpower.enhancer.<X>

also is, but the results returned by krangpower.enhancer have several advantages:

  • Items that OpenDSS returns as simple lists of floats (e.g., opendssdirect.dss.Circuit.Losses(), opendssdirect.dss.Bus.Voltages(), etc.) are returned as lists of complex numbers, matrices of [nterm x ncond], etc. as is appropriate.
  • Structured items such as opendssdirect.Circuit.SistemY() are returned as pandas.DataFrame for easier manipulation and export
  • Items come, where appropriate, as Quantities (from the pint package) with the appropriate measurement unit. This enables easy conversions and secures against miscalculations.
  • Through the exposed function txt_command, the OpenDSS text interface is checked for errors (that are normally just returned as strings without raising anything).
  • The exposed pack function that enables easy and intuitive element exploration by returning a PackedOpendssElement corresponding to the name passed as argument, either fully qualified or simple.

Additional functions

krangpower.enhancer exposes a few more utility functions.

krangpower.enhancer.pack(item)

Returns a PackedOpendssElement corresponding to item.

krangpower.enhancer.get_all_names()

Gets the fully qualified names of the elements, plus buses, loadshapes and xycurves.

krangpower.enhancer.txt_command(cmd_str: str, echo=True)

Performs a text interface call with the argument passed and logs command and response. The results are checked for silent errors. When instantiating components through this function, the update of the names returned by get_all_names()is triggered. The log output can be suppressed by setting the keyword argument echo=False; but even in this case, if kp.get_log_level() is 0, the log of the command will be forced.