Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# -*- coding: utf-8 -*-
"""
% TestScaling_Light_Flickermeter
% This script generates the light waveform in accordance with IEC TR 61547-1 [1] to verify the scaling of the function 'light_flickermeter_metric_PstLM' of the light flickermeter.
%
% Description:
% The light flickermeter specified in IEC TR 61547-1 [1] can be used to evaluate the flicker severity of light waveforms in terms of the short term flicker metric PstLM.
% This metric represents the flicker perception of light waveforms in a much more objective way than the metrics flicker index or flicker percent (also called modulation depth).
% This script generates the light waveform in accordance with IEC TR 61547-1 [1] to verify the scaling of the function 'light_flickermeter_metric_PstLM' of the light flickermeter.
% The script is based on a script of a matlab script 'benchtest example_testbench_230V_50Hz' [2] for testing the voltage fluctuation flickermeter specified in IEC 61000-4-15.
% This script generates the light waveform in accordance with IEC TR 61547-1 [1] to verify the scaling of the function 'light_flickermeter_metric_PstLM' of the light flickermeter. See subclause A.2.4 of [1].
%
% References:
% [1] IEC TR 61547-1, Equipment for general lighting purposes - EMC immunity requirements - Part 1: An objective voltage fluctuation immunity test method, 2015-04.
% [2] Patrik Jourdan, Flickermeter Simulator, Matlab script 'benchtest example_testbench_230V_50Hz' posted on the Matlab Central, version 1.6 (Updated 26 Aug 2014).
%
% Notes:
% - This script uses the following function: light_flickermeter_metric_PstLM
% - The latter function requires MATLAB with the Signal Processing Toolbox
%
% COPYRIGHT © PHILIPS LIGHTING HOLDING B.V. 2017
% P. Beeckman
% Philips Lighting - Eindhoven - Netherlands
% Version: 1.0
% Version: 2017-06-23
%
"""
import numpy as np
import scipy as sp
from scipy import signal
import time
from light_flickermeter_metric_PstLM import light_flickermeter_metric_PstLM
def main():
# SPECIFY INPUT VARIABLES
FS = 4000 # sampling frequency of the waveform in Hz; recommended to be above 4000 Hz; see subclause 6.6.2 of [1]
Ttest = 180 # minimum duration of the waveform in s; minimum 180 s recommended in Table 1 of [1]
t = np.arange(0, Ttest, 1 / FS ) # time vector
# RUN TEST
print('TEST OF SCALING FACTOR IN IEC TR 61547-1')
print('========================================')
# TEST SCALING FACTOR WITH ANALYTICAL WAVEFORM OF EQUATION (A.6) IEC TR 61547-1 [1]
# Parameters
rate = 1056 # modulation of the rectangular waveform in changes per minute = 8.8 Hz
d = 0.630 # relative illuminance change of the rectuangular modulation in percent
a_mod = d / 100 # relative illuminance change of the rectuangular modulation
f_mod = rate / 120 # modulation frequency in Hz
print('PARAMETERS TEST PST TEST WAVEFORM:') # print general parameters of the test waveforms
print('Duration waveform % 6.1f sec.', Ttest)
print('Sample frequency % 6.0f Hz.', FS)
# make test signal according to equation (A.6) of [1]; sinusoidal modulation giving Pinstmax = 1
u = 1 + ((a_mod / 2) * (np.sin(2 * np.pi * f_mod * t)))
print('Amplitude modulation: sinusoidal @ rate r = %4d cpm (%4.1f Hz), relative change d = %6.3f %%.\n' %(rate, f_mod, a_mod * 100))
PstLM, PstLMinstmax = light_flickermeter_metric_PstLM(u,FS) # calculation of PstLM and PstLMinstmax
PstLMinstmax_ref = 1; # reference value for PstLMinstmax = 1
print('Max of instantaneous flicker metric PstLMinst = %6.3f .' %(PstLMinstmax))
err = ((PstLMinstmax - PstLMinstmax_ref) / PstLMinstmax_ref) * 100 # calculation of the error in percent
print('Error: %.2f %%' % (err))
return
if __name__ == "__main__":
main()