Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
VILLASdataprocessing
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ACS
Public
VILLASframework
VILLASdataprocessing
Commits
3ffe6cb4
Commit
3ffe6cb4
authored
7 years ago
by
Markus Mirz
Browse files
Options
Downloads
Patches
Plain Diff
udpate
parent
7c0dd646
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
dataprocessing/calc.py
+35
-0
35 additions, 0 deletions
dataprocessing/calc.py
dataprocessing/plotdpsim.py
+44
-5
44 additions, 5 deletions
dataprocessing/plotdpsim.py
dataprocessing/plottools.py
+1
-1
1 addition, 1 deletion
dataprocessing/plottools.py
with
80 additions
and
6 deletions
dataprocessing/calc.py
+
35
−
0
View file @
3ffe6cb4
...
...
@@ -23,3 +23,38 @@ def complex_abs(name, real, imag):
ts_abs
=
TimeSeries
(
name
,
real
.
time
,
np
.
sqrt
(
real
.
values
**
2
+
imag
.
values
**
2
))
return
ts_abs
def
dyn_phasor_shift_to_emt
(
name
,
real
,
imag
,
freq
):
"""
Shift dynamic phasor values to EMT by frequency freq.
Assumes the same time steps for both timeseries.
"""
ts_shift
=
TimeSeries
(
name
,
real
.
time
,
real
.
values
*
np
.
cos
(
2
*
np
.
pi
*
freq
*
real
.
time
)
-
imag
.
values
*
np
.
sin
(
2
*
np
.
pi
*
freq
*
real
.
time
))
return
ts_shift
def
check_node_number_comp
(
ts_comp
,
node
):
"""
Check if node number is available in complex time series.
:param ts_comp: complex time series
:param node: node number to be checked
:return: true if node number is available, false if out of range
"""
ts_comp_length
=
len
(
ts_comp
)
im_offset
=
int
(
ts_comp_length
/
2
)
if
im_offset
<=
node
or
node
<
0
:
print
(
'
Complex node not available
'
)
return
false
else
:
return
true
def
check_node_number
(
ts
,
node
):
"""
Check if node number is available in time series.
:param ts: time series
:param node: node number to be checked
:return: true if node number is available, false if out of range
"""
ts_length
=
len
(
ts
)
if
ts_length
<=
node
or
node
<
0
:
print
(
'
Node not available
'
)
return
false
else
:
return
true
This diff is collapsed.
Click to expand it.
dataprocessing/plotdpsim.py
+
44
−
5
View file @
3ffe6cb4
...
...
@@ -6,8 +6,8 @@ import matplotlib.pyplot as plt
matplotlib
.
rcParams
.
update
({
'
font.size
'
:
8
})
def
plot_dpsim_abs_diff
(
filename1
,
label1
,
node1
,
filename2
,
label2
,
node2
):
ts_dpsim1
=
read_time
_
series_DPsim
(
filename1
)
ts_dpsim2
=
read_time
_
series_DPsim
(
filename2
)
ts_dpsim1
=
read_timeseries_DPsim
(
filename1
)
ts_dpsim2
=
read_timeseries_DPsim
(
filename2
)
ts_dpsim1_length
=
len
(
ts_dpsim1
)
im_offset1
=
int
(
ts_dpsim1_length
/
2
)
...
...
@@ -44,8 +44,8 @@ def plot_dpsim_abs_diff(filename1, label1, node1, filename2, label2, node2):
plt
.
show
()
def
plot_dpsim_abs
(
filename1
,
label1
,
node1
,
filename2
,
label2
,
node2
):
ts_dpsim1
=
read_time
_
series_DPsim
(
filename1
)
ts_dpsim2
=
read_time
_
series_DPsim
(
filename2
)
ts_dpsim1
=
read_timeseries_DPsim
(
filename1
)
ts_dpsim2
=
read_timeseries_DPsim
(
filename2
)
ts_dpsim1_length
=
len
(
ts_dpsim1
)
im_offset1
=
int
(
ts_dpsim1_length
/
2
)
...
...
@@ -79,8 +79,47 @@ def plot_dpsim_abs(filename1, label1, node1, filename2, label2, node2):
plt
.
show
()
def
plot_dpsim_emt_abs
(
filenameDP
,
nodeDP
,
filenameEMT
,
nodeEMT
):
ts_dpsimDP
=
read_timeseries_DPsim
(
filenameDP
)
ts_dpsimEMT
=
read_timeseries_DPsim
(
filenameEMT
)
ts_dpsimDP_length
=
len
(
ts_dpsimDP
)
im_offsetDP
=
int
(
ts_dpsimDP_length
/
2
)
if
im_offsetDP
<=
nodeDP
or
nodeDP
<
0
:
print
(
'
Node DP not available
'
)
exit
()
ts_dpsimEMT_length
=
len
(
ts_dpsimEMT
)
if
ts_dpsimEMT_length
<=
nodeEMT
or
nodeEMT
<
0
:
print
(
'
Node EMT not available
'
)
exit
()
ts_absDP
=
complex_abs
(
'
node
'
+
str
(
nodeDP
)
+
'
abs
'
,
ts_dpsimDP
[
nodeDP
],
ts_dpsimDP
[
nodeDP
+
im_offsetDP
])
ts_absDP
=
scale_ts
(
ts_absDP
.
name
,
ts_absDP
,
0.001
)
ts_absDP
.
label
=
'
DP abs
'
ts_shiftDP
=
dyn_phasor_shift_to_emt
(
'
node
'
+
str
(
nodeDP
)
+
'
shift
'
,
ts_dpsimDP
[
nodeDP
],
ts_dpsimDP
[
nodeDP
+
im_offsetDP
],
50
)
ts_shiftDP
=
scale_ts
(
ts_shiftDP
.
name
,
ts_shiftDP
,
0.001
)
ts_shiftDP
.
label
=
'
DP shift
'
ts_EMT
=
TimeSeries
(
'
node
'
+
str
(
nodeEMT
),
ts_dpsimEMT
[
nodeEMT
].
time
,
ts_dpsimEMT
[
nodeEMT
].
values
)
ts_EMT
=
scale_ts
(
ts_EMT
.
name
,
ts_EMT
,
0.001
)
ts_EMT
.
label
=
'
EMT
'
figure_id
=
1
# plt.figure(figure_id)
plt
.
figure
(
figure_id
,
figsize
=
(
12
/
2.54
,
6
/
2.54
),
facecolor
=
'
w
'
,
edgecolor
=
'
k
'
)
plot_timeseries
(
figure_id
,
ts_EMT
)
plot_timeseries
(
figure_id
,
ts_absDP
)
plot_timeseries
(
figure_id
,
ts_shiftDP
)
plt
.
xlabel
(
'
Time [s]
'
)
plt
.
ylabel
(
'
Voltage [kV]
'
)
plt
.
grid
(
True
)
plt
.
tight_layout
()
plt
.
show
()
def
plot_dpsim_abs_single
(
filename
,
node
):
ts_dpsim
=
read_time
_
series_DPsim
(
filename
)
ts_dpsim
=
read_timeseries_DPsim
(
filename
)
ts_dpsim_length
=
len
(
ts_dpsim
)
print
(
'
DPsim results file length:
'
)
...
...
This diff is collapsed.
Click to expand it.
dataprocessing/plottools.py
+
1
−
1
View file @
3ffe6cb4
...
...
@@ -9,7 +9,7 @@ def plot_timeseries(figure_id, timeseries, plt_linestyle='-'):
if
not
isinstance
(
timeseries
,
list
):
plt
.
plot
(
timeseries
.
time
,
timeseries
.
values
,
linestyle
=
plt_linestyle
,
label
=
timeseries
.
label
)
plt
.
gca
().
autoscale
(
axis
=
'
x
'
,
tight
=
True
)
plt
.
legend
()
plt
.
legend
(
loc
=
'
lower right
'
)
else
:
for
ts
in
timeseries
:
plt
.
subplot
(
len
(
timeseries
),
1
,
timeseries
.
index
(
ts
)
+
1
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment