harmonic_content¶
- typhoon.test.IEC61000.harmonic_content(samples: DataFrame, nominal_grid_freq: float, max_harmonic_order: int, interharm: bool = False, reference_split=None)¶
This method measures harmonics, interharmonics, and total harmonic distortion according to IEC 61000-4-7. The measurements are valid up to the 180th (50 Hz) or 150th (60 Hz) harmonic order.
- Parameters:
samples (pandas.DataFrame) – Samples captured from simulation. The grid voltage is used for synchronization and detecting zero-crossings. According to the IEC 61000-4-30 standard the calculation window length is determined by the grid frequency. The voltage is also used to calculate harmonics, interharmonics, and total harmonic distortion.
nominal_grid_freq (float) – According to the IEC 61000-4-7 standard, this method is applied only in grids with a nominal frequency of 50.0 Hz or 60.0 Hz.
max_harmonic_order (int) – The order of the highest harmonic that is taken into account.
interharm (bool) – If True, returns the rms values of the harmonics and interharmonics. If False, returns the rms values of the harmonics only.
reference_split (list, optional) – List of indices to split the sample in windows. If None, the samples will be split according to the zero-crossings of the voltage signal.
- Returns:
THD (numpy.array) – Ratio of the r.m.s. value of the sum of all the harmonic components up to a specific
order to the r.m.s. voltage of the fundamental component, measured per window.
rms_values (numpy.array) – RMS of a spectral components (harmonics and interharmonics).
freq (numpy.array) – Frequency measured at each measurement window.
- Raises:
ValueError – When the
nominal_grid_freq
is different from 50 Hz or 60 Hz:
Examples
>>> from typhoon.test.signals import pandas_sine >>> from typhoon.test.IEC61000 import harmonic_content >>> >>> frequency = 60 >>> max_harmonic_order = 33 >>> enable_interharmonics = False >>> samples = pandas_sine(frequency=frequency) >>> >>> THD, rms_components, measure_frequency = harmonic_content(samples, frequency, max_harmonic_order, enable_interharmonics)