Commit 1f9b9908 authored by Junjie Zhang's avatar Junjie Zhang

Merge branch 'master' into timeseries-processing-functions

parents 8ead176b 110b3ca8
......@@ -2,7 +2,7 @@
## Copyright
2017-2018, Institute for Automation of Complex Power Systems, EONERC, RWTH Aachen University
2017-2019, Institute for Automation of Complex Power Systems, EONERC, RWTH Aachen University
## License
......
This diff is collapsed.
1550448609.600921989(0) 0.000000+0.000000i
1550448609.601121989(1) 0.000628+0.000000i
1550448609.601321989(2) 0.001881+0.000000i
1550448609.601521989(3) 0.003755+0.000000i
1550448609.601721989(4) 0.006242+0.000000i
1550448609.601921989(5) 0.009332+0.000000i
1550448609.602121989(6) 0.013013+0.000000i
1550448609.602321989(7) 0.017271+0.000000i
1550448609.602521989(8) 0.022089+0.000000i
1550448609.602721989(9) 0.027447+0.000000i
1550448609.602921989(10) 0.033325+0.000000i
1550448609.603121989(11) 0.039699+0.000000i
1550448609.603321989(12) 0.046545+0.000000i
1550448609.603521989(13) 0.053834+0.000000i
1550448609.603721989(14) 0.061539+0.000000i
1550448609.603921989(15) 0.069630+0.000000i
1550448609.604121989(16) 0.078073+0.000000i
1550448609.604321989(17) 0.086836+0.000000i
1550448609.604521989(18) 0.095884+0.000000i
1550448609.604721989(19) 0.105182+0.000000i
1550448609.604921989(20) 0.114692+0.000000i
1550448609.605121989(21) 0.124378+0.000000i
1550448609.605321989(22) 0.134201+0.000000i
1550448609.605521989(23) 0.144122+0.000000i
1550448609.605721989(24) 0.154103+0.000000i
1550448609.605921989(25) 0.164103+0.000000i
1550448609.606121989(26) 0.174083+0.000000i
1550448609.606321989(27) 0.184004+0.000000i
1550448609.606521989(28) 0.193827+0.000000i
1550448609.606721989(29) 0.203513+0.000000i
1550448609.606921989(30) 0.213023+0.000000i
1550448609.607121989(31) 0.222321+0.000000i
1550448609.607321989(32) 0.231369+0.000000i
1550448609.607521989(33) 0.240132+0.000000i
1550448609.607721989(34) 0.248576+0.000000i
1550448609.607921989(35) 0.256666+0.000000i
1550448609.608121989(36) 0.264371+0.000000i
1550448609.608321989(37) 0.271661+0.000000i
1550448609.608521989(38) 0.278506+0.000000i
1550448609.608721989(39) 0.284880+0.000000i
1550448609.608921989(40) 0.290758+0.000000i
1550448609.609121989(41) 0.296116+0.000000i
1550448609.609321989(42) 0.300934+0.000000i
1550448609.609521989(43) 0.305192+0.000000i
1550448609.609721989(44) 0.308873+0.000000i
1550448609.609921989(45) 0.311963+0.000000i
1550448609.610121989(46) 0.314450+0.000000i
1550448609.610321989(47) 0.316324+0.000000i
1550448609.610521989(48) 0.317577+0.000000i
1550448609.610721989(49) 0.318205+0.000000i
1550448609.610921989(50) 0.318205+0.000000i
1550448609.611121989(51) 0.317577+0.000000i
1550448609.611321989(52) 0.316324+0.000000i
1550448609.611521989(53) 0.314450+0.000000i
1550448609.611721989(54) 0.311963+0.000000i
1550448609.611921989(55) 0.308873+0.000000i
1550448609.612121989(56) 0.305192+0.000000i
1550448609.612321989(57) 0.300934+0.000000i
1550448609.612521989(58) 0.296116+0.000000i
1550448609.612721989(59) 0.290758+0.000000i
1550448609.612921989(60) 0.284880+0.000000i
1550448609.613121989(61) 0.278506+0.000000i
1550448609.613321989(62) 0.271661+0.000000i
1550448609.613521989(63) 0.264371+0.000000i
1550448609.613721989(64) 0.256666+0.000000i
1550448609.613921989(65) 0.248576+0.000000i
1550448609.614121989(66) 0.240132+0.000000i
1550448609.614321989(67) 0.231369+0.000000i
1550448609.614521989(68) 0.222321+0.000000i
1550448609.614721989(69) 0.213023+0.000000i
1550448609.614921989(70) 0.203513+0.000000i
1550448609.615121989(71) 0.193827+0.000000i
1550448609.615321989(72) 0.184004+0.000000i
1550448609.615521989(73) 0.174083+0.000000i
1550448609.615721989(74) 0.164103+0.000000i
1550448609.615921989(75) 0.154103+0.000000i
1550448609.616121989(76) 0.144122+0.000000i
1550448609.616321989(77) 0.134201+0.000000i
1550448609.616521989(78) 0.124378+0.000000i
1550448609.616721989(79) 0.114692+0.000000i
1550448609.616921989(80) 0.105182+0.000000i
1550448609.617121989(81) 0.095884+0.000000i
1550448609.617321989(82) 0.086836+0.000000i
1550448609.617521989(83) 0.078073+0.000000i
1550448609.617721989(84) 0.069630+0.000000i
1550448609.617921989(85) 0.061539+0.000000i
1550448609.618121989(86) 0.053834+0.000000i
1550448609.618321989(87) 0.046545+0.000000i
1550448609.618521989(88) 0.039699+0.000000i
1550448609.618721989(89) 0.033325+0.000000i
1550448609.618921989(90) 0.027447+0.000000i
1550448609.619121989(91) 0.022089+0.000000i
1550448609.619321989(92) 0.017271+0.000000i
1550448609.619521989(93) 0.013013+0.000000i
1550448609.619721989(94) 0.009332+0.000000i
1550448609.619921989(95) 0.006242+0.000000i
1550448609.620121989(96) 0.003755+0.000000i
1550448609.620321989(97) 0.001881+0.000000i
1550448609.620521989(98) 0.000628+0.000000i
1550448609.620721989(99) 0.000000+0.000000i
1550448609.620921989(100) 0.000000+0.000000i
1550448609.621121989(101) 0.000628+0.000000i
1550448609.621321989(102) 0.001881+0.000000i
1550448609.621521989(103) 0.003755+0.000000i
1550448609.621721989(104) 0.006242+0.000000i
1550448609.621921989(105) 0.009332+0.000000i
1550448609.622121989(106) 0.013013+0.000000i
1550448609.622321989(107) 0.017271+0.000000i
1550448609.622521989(108) 0.022089+0.000000i
1550448609.622721989(109) 0.027447+0.000000i
1550448609.622921989(110) 0.033325+0.000000i
1550448609.623121989(111) 0.039699+0.000000i
1550448609.623321989(112) 0.046545+0.000000i
1550448609.623521989(113) 0.053834+0.000000i
1550448609.623721989(114) 0.061539+0.000000i
1550448609.623921989(115) 0.069630+0.000000i
1550448609.624121989(116) 0.078073+0.000000i
1550448609.624321989(117) 0.086836+0.000000i
1550448609.624521989(118) 0.095884+0.000000i
1550448609.624721989(119) 0.105182+0.000000i
1550448609.624921989(120) 0.114692+0.000000i
1550448609.625121989(121) 0.124378+0.000000i
1550448609.625321989(122) 0.134201+0.000000i
1550448609.625521989(123) 0.144122+0.000000i
1550448609.625721989(124) 0.154103+0.000000i
1550448609.625921989(125) 0.164103+0.000000i
1550448609.626121989(126) 0.174083+0.000000i
1550448609.626321989(127) 0.184004+0.000000i
1550448609.626521989(128) 0.193827+0.000000i
1550448609.626721989(129) 0.203513+0.000000i
1550448609.626921989(130) 0.213023+0.000000i
1550448609.627121989(131) 0.222321+0.000000i
1550448609.627321989(132) 0.231369+0.000000i
1550448609.627521989(133) 0.240132+0.000000i
1550448609.627721989(134) 0.248576+0.000000i
1550448609.627921989(135) 0.256666+0.000000i
1550448609.628121989(136) 0.264371+0.000000i
1550448609.628321989(137) 0.271661+0.000000i
1550448609.628521989(138) 0.278506+0.000000i
1550448609.628721989(139) 0.284880+0.000000i
1550448609.628921989(140) 0.290758+0.000000i
1550448609.629121989(141) 0.296116+0.000000i
1550448609.629321989(142) 0.300934+0.000000i
1550448609.629521989(143) 0.305192+0.000000i
1550448609.629721989(144) 0.308873+0.000000i
1550448609.629921989(145) 0.311963+0.000000i
1550448609.630121989(146) 0.314450+0.000000i
1550448609.630321989(147) 0.316324+0.000000i
1550448609.630521989(148) 0.317577+0.000000i
1550448609.630721989(149) 0.318205+0.000000i
1550448609.630921989(150) 0.318205+0.000000i
1550448609.631121989(151) 0.317577+0.000000i
1550448609.631321989(152) 0.316324+0.000000i
1550448609.631521989(153) 0.314450+0.000000i
1550448609.631721989(154) 0.311963+0.000000i
1550448609.631921989(155) 0.308873+0.000000i
1550448609.632121989(156) 0.305192+0.000000i
1550448609.632321988(157) 0.300934+0.000000i
1550448609.632521989(158) 0.296116+0.000000i
1550448609.632721989(159) 0.290758+0.000000i
......@@ -23,10 +23,11 @@ def read(fname):
setup(
name = 'villas-dataprocessing',
version = '0.2.2',
version = '0.2.4',
author = 'Markus Mirz, Jan Dinkelbach, Steffen Vogel',
author_email = 'acs-software@eonerc.rwth-aachen.de',
description = 'Several tools for processing simulation results',
long_description_content_type='text/markdown',
license = 'GPL-3.0',
keywords = 'simulation power system real-time data processing',
url = 'https://git.rwth-aachen.de/acs/public/villas/dataprocessing',
......
......@@ -120,21 +120,23 @@ def read_dpsim_log(log_path):
log_sections = {'init':[], 'none':[], 'sysmat_stamp':[], 'sysmat_final':[], 'sourcevec_stamp':[], 'sourcevec_final':[], 'ludecomp':[]}
section = 'init'
for line_pos in range(len(log_lines)):
if re.search('DEBUG: Stamping .+ into system matrix:', log_lines[line_pos]):
if re.search('\[D\] Stamping .+ into system matrix:', log_lines[line_pos]):
section = 'sysmat_stamp'
elif re.search('INFO: System matrix:', log_lines[line_pos]):
elif re.search('[I] System matrix:', log_lines[line_pos]):
section = 'sysmat_final'
elif re.search('DEBUG: Stamping .+ into source vector:', log_lines[line_pos]):
elif re.search('\[D\] Stamping .+ into source vector:', log_lines[line_pos]):
section = 'sourcevec_stamp'
elif re.search('INFO: Right side vector:', log_lines[line_pos]):
elif re.search('\[I\] Right side vector:', log_lines[line_pos]):
section = 'sourcevec_final'
elif re.search('INFO: LU decomposition:', log_lines[line_pos]):
elif re.search('\[I\] LU decomposition:', log_lines[line_pos]):
section = 'ludecomp'
elif re.search('INFO: Number of network simulation nodes:', log_lines[line_pos]):
elif re.search('\[I\] Number of network simulation nodes:', log_lines[line_pos]):
section = 'none'
elif re.search('INFO: Added .+ to simulation.', log_lines[line_pos]):
elif re.search('\[I\] Added .+ to simulation.', log_lines[line_pos]):
section = 'none'
elif re.search('INFO: Initial switch status:', log_lines[line_pos]):
elif re.search('\[I\] Initial switch status:', log_lines[line_pos]):
section = 'none'
elif re.search('\[(.*?)\]', log_lines[line_pos]):
section = 'none'
log_sections[section].append(line_pos)
......@@ -335,9 +337,11 @@ def read_timeseries_villas(filename):
timeseries = [ ]
times = [ ]
fields = [ ]
names = [ ]
for line in fp.readlines():
if line[0] == '#':
names = line.split()[2:]
continue
sample = Sample.parse(line)
......@@ -351,7 +355,10 @@ def read_timeseries_villas(filename):
fields[index].append(field)
for index, field in enumerate(fields):
name = 'signal_{}'.format(index)
if len(names) <= index:
name = names[index]
else:
name = 'signal_{}'.format(index)
series = TimeSeries(name, times, field)
......
......@@ -105,17 +105,26 @@ class TimeSeries:
return fft_freqs[:freqs_num], np.abs(fft_values[:freqs_num])/freqs_num
def interpolate(self, timestep):
""" Interpolates timeseries with new timestep
:param timestep:
:return:
"""
interpl_time = np.arange(self.time[0], self.time[-1], timestep)
values = np.interp(interpl_time, self.time, self.values)
ts_return = TimeSeries(self.name+'_intpl', interpl_time, values)
return ts_return
def interpolate_cmpl(self, timestep):
""" Not tested yet!
Interpolates complex timeseries with timestep
""" Interpolates complex timeseries with new timestep
:param timestep:
:return:
"""
interpl_time = np.arange(self.time[0], self.time[-1], timestep)
realValues = interp1d(interpl_time, self.values.real)
imagValues = interp1d(interpl_time, self.values.imag)
ts_return = TimeSeries(self.name+'_intpl', time, np.vectorize(complex)(realValues, imagValues))
return timeseries
realValues = np.interp(interpl_time, self.time, self.values.real)
imagValues = np.interp(interpl_time, self.time, self.values.imag)
ts_return = TimeSeries(self.name+'_intpl', interpl_time, np.vectorize(complex)(realValues, imagValues))
return ts_return
@staticmethod
def multi_frequency_shift(timeseries_list, freqs_list):
......@@ -153,7 +162,31 @@ class TimeSeries:
ts_shift = ts.frequency_shift(freq)
result_list[ts.name] = ts_shift
return result_list
@staticmethod
def interpolate_list(timeseries_list, timestep):
""" Interpolates timeseries list with new timestep
:param timestep:
:return:
"""
result_list = {}
for name, ts in timeseries_list.items():
ts_intp = ts.interpolate(timestep)
result_list[ts_intp.name] = ts_intp
return result_list
@staticmethod
def interpolate_cmpl_list(timeseries_list, timestep):
""" Interpolates list of complex timeseries with new timestep
:param timestep:
:return:
"""
result_list = {}
for name, ts in timeseries_list.items():
ts_intp = ts.interpolate_cmpl(timestep)
result_list[ts_intp.name] = ts_intp
return result_list
@staticmethod
def create_emt_from_dp(timeseries_list, freqs_list, new_name = 'emt_signal'):
""" Calculate shifted frequency results of all time series in list
......
......@@ -84,8 +84,8 @@ def convert_simulink_to_standard_timeseries(simseri):
for check in range(len(simseri)):
if 'U AB:' in simseri[check].name:
simseri[check].name = simseri[check].name.replace('U AB:', '')
simseri[check].name = simseri[check].name.replace('Vrms', v_abs_std_suffix)
simseri[check].name = simseri[check].name.replace('VDegree', v_angle_std_suffix)
simseri[check].name = simseri[check].name.replace('.Vrms', v_abs_std_suffix)
simseri[check].name = simseri[check].name.replace('.VDegree', v_angle_std_suffix)
simseri[check].name = simseri[check].name.replace(' ', '')
simseri[check].name = simseri[check].name.replace('_', '')
if 'Vangle' in simseri[check].name:
......@@ -162,6 +162,11 @@ def assert_modelica_results(net_name, error, threshold):
:param simulink_res: timeseries of reference result
:return: outputs to command line which are the results of the assert
"""
if not error:
raise ValueError("No error values available. Model assertion can not be performed!")
else:
print("%i error values available. Comparing with threshold..." % len(error))
fail_list = [] # List for all the failed test
for name in error.keys():
if abs(error[name]) > threshold:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment