Commit 0ce21f35 authored by Steffen Vogel's avatar Steffen Vogel 🎅🏼

dpsim: accept .real and .imag suffixes in complex CSV dataseries

parent 240b3a2e
...@@ -95,25 +95,39 @@ def read_timeseries_dpsim(filename, timeseries_names=None): ...@@ -95,25 +95,39 @@ def read_timeseries_dpsim(filename, timeseries_names=None):
timestamps = pd_df.iloc[:, 0] timestamps = pd_df.iloc[:, 0]
# Find real and complex variable names # Find real and complex variable names
real_string = '_re' suffixes = [ ('_re', '_im'), ('.real', '.imag') ]
imaginary_string = '_im'
for column in column_names: for column in column_names:
if real_string in column: is_complex = False
tmp = column.replace(real_string, '') for suffix in suffixes:
cmpl_result_columns.append(tmp) real_suffix = suffix[0]
#print("Found complex variable: " + tmp) imag_suffix = suffix[1]
elif not imaginary_string in column:
real_result_columns.append(column) if column.endswith(imag_suffix):
#print("Found real variable: " + column) is_complex = True
break # Ignore imag columns
for column in real_result_columns:
if column.endswith(real_suffix):
is_complex = True
column_base = column.replace(real_suffix, '')
if column_base + imag_suffix not in column_names:
continue
cmpl_result_columns.append(column_base)
timeseries_list[column_base] = TimeSeries(column_base, timestamps,
np.vectorize(complex)(
pd_df[column_base + real_suffix],
pd_df[column_base + imag_suffix]
)
)
break
if is_complex:
continue
real_result_columns.append(column)
timeseries_list[column] = TimeSeries(column, timestamps, pd_df[column]) timeseries_list[column] = TimeSeries(column, timestamps, pd_df[column])
for column in cmpl_result_columns:
timeseries_list[column] = TimeSeries(column, timestamps,
np.vectorize(complex)(pd_df[column + real_string],
pd_df[column + imaginary_string]))
else: else:
# Read in specified time series # Read in specified time series
print('cannot read specified columns yet') print('cannot read specified columns yet')
......
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