Skip to content

PowerSystem

Module for creating power system objects.

This module provides classes and methods to define power systems, including phases, zero-crossing detection, and calculation of electrical quantities like voltage, current, and power.

Classes:

Name Description
PowerSystem

Represents the overall power system, allowing configuration, data processing, and analysis.

PowerPhase

Represents a single phase of the power system.

Imports
  • numpy: For numerical calculations.
  • List: For type hinting lists.
  • logging: For logging messages.
  • AcqBuffer, DataChannelBuffer: From daqopen.channelbuffer for data handling.
  • ZeroCrossDetector: From pqopen.zcd for detecting zero crossings in signals.

PowerPhase

Bases: object

Represents a single phase in the power system.

Attributes:

Name Type Description
_u_channel AcqBuffer

Voltage channel buffer for the phase.

_i_channel AcqBuffer

Current channel buffer for the phase.

_number int

Identifier number for the phase.

name str

Name of the phase.

_calc_channels dict

Dictionary for storing calculated data channels.

__init__(u_channel, i_channel=None, number=1, name='')

Initializes a PowerPhase object.

Parameters:

Name Type Description Default
u_channel AcqBuffer

Voltage channel buffer.

required
i_channel AcqBuffer

Current channel buffer. Defaults to None.

None
number int

Phase number. Defaults to 1.

1
name str

Name of the phase. Defaults to an empty string.

''

update_calc_channels(features)

Update the calculation channels depending of active features

Parameters:

Name Type Description Default
features dict

Dict of features

required

PowerSystem

Bases: object

Represents the overall power system, including zero-crossing detection, phase management, and power system calculations.

Attributes:

Name Type Description
_zcd_channel AcqBuffer

Channel buffer for zero-crossing detection data.

_samplerate float

Sampling rate of the input signal.

_time_channel AcqBuffer

Optional time channel buffer.

_zcd_cutoff_freq float

Cutoff frequency for the zero-crossing detector.

_zcd_threshold float

Threshold for zero-crossing detection.

_zcd_minimum_frequency float

Minimum frequency for valid zero-crossing detection.

nominal_frequency float

Nominal frequency of the power system.

nper Optional[int]

Number of periods for analysis (if applicable).

_phases List[PowerPhase]

List of phases in the power system.

_features dict

Configuration for harmonic and fluctuation calculations.

output_channels dict

Dictionary of output data channels.

__init__(zcd_channel, input_samplerate, zcd_cutoff_freq=50.0, zcd_threshold=1.0, zcd_minimum_freq=10, nominal_frequency=50.0, nper=10)

Initializes a PowerSystem object.

Parameters:

Name Type Description Default
zcd_channel AcqBuffer

Channel buffer for zero-crossing detection.

required
input_samplerate float

Sampling rate of the input signal.

required
zcd_cutoff_freq float

Cutoff frequency for zero-crossing detection. Defaults to 50.0.

50.0
zcd_threshold float

Threshold for zero-crossing detection. Defaults to 1.0.

1.0
zcd_minimum_freq float

Minimum frequency for valid zero crossings. Defaults to 10.

10
nominal_frequency float

Nominal system frequency. Defaults to 50.0.

50.0
nper int

Number of periods for calculations. Defaults to 10.

10

add_phase(u_channel, i_channel=None, name='')

Adds a phase to the power system.

Parameters:

Name Type Description Default
u_channel AcqBuffer

Voltage channel buffer.

required
i_channel AcqBuffer

Current channel buffer. Defaults to None.

None
name str

Name of the phase. Defaults to an empty string.

''

enable_harmonic_calculation(num_harmonics=50)

Enables harmonic analysis for the power system.

Parameters:

Name Type Description Default
num_harmonics int

Number of harmonics to calculate. Defaults to 50.

50

enable_mains_signaling_calculation(frequency)

Enables calculation of mains signaling voltage Complies to IEC 61000-4-30

Parameters:

Name Type Description Default
frequency float

Expected frequency of signaling voltage

required

enable_nper_abs_time_sync(time_channel, interval_sec=600)

Enables synchronisation of multi-period calculation to absolute rounded timestamp. Complies to IEC 61000-4-30 overlapping

Parameters:

Name Type Description Default
time_channel AcqBuffer

Channel buffer for time information

required
interval_sec int

Resync interval in seconds

600

enable_under_over_deviation_calculation(u_din)

Enables calculation of under and overdeviation Complies to IEC 61000-4-30

Parameters:

Name Type Description Default
u_din float

Dimensioned voltage (typ. nominal voltage)

required

get_aggregated_data(start_acq_sidx, stop_acq_sidx)

Retrieves aggregated data for the specified sample range.

Parameters:

Name Type Description Default
start_acq_sidx int

Start sample index.

required
stop_acq_sidx int

Stop sample index.

required

Returns:

Name Type Description
dict dict

Aggregated data values.

process()

Processes new data samples, performing zero-crossing detection and calculations for each period.