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
f18964ac
Commit
f18964ac
authored
6 years ago
by
Bichen Li
Browse files
Options
Downloads
Patches
Plain Diff
-Add Simulink readin function
parent
cda742b5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dataprocessing/readtools.py
+55
-0
55 additions, 0 deletions
dataprocessing/readtools.py
with
55 additions
and
0 deletions
dataprocessing/readtools.py
+
55
−
0
View file @
f18964ac
import
numpy
as
np
import
pandas
as
pd
from
.timeseries
import
*
...
...
@@ -271,3 +272,57 @@ def read_timeseries_NEPLAN_loadflow(file_name, timeseries_names=None, is_regex=F
for
num_to_del
in
range
(
len
(
line_del
)):
del
timeseries
[
line_del
[
len
(
line_del
)
-
num_to_del
-
1
]]
return
timeseries
def
read_timeseries_simulink_loadflow
(
file_name
,
timeseries_names
=
None
,
is_regex
=
False
):
str_tmp
=
open
(
file_name
,
'
r
'
,
encoding
=
'
latin-1
'
)
# Read in files, using latin-1 to decode /xb0
# Read in data from result file of neplan
name
=
[]
# list for data type names
value
=
[]
# list for data
timeseries
=
[]
line_del
=
[]
# a list for the value to be deleted
for
line
in
str_tmp
.
readlines
():
line
=
line
.
replace
(
"
°
"
,
""
)
del
value
[:]
del
name
[:]
# read in different data and start processing
if
len
(
line
)
>
37
:
if
line
[
31
:
35
]
==
'
--->
'
:
if
line
[
13
:
17
]
==
'
Arms
'
:
name
=
[
line
[
37
:
len
(
line
)].
rstrip
()
+
'
.Arms
'
,
line
[
37
:
len
(
line
)].
rstrip
()
+
'
.IDegree
'
]
elif
line
[
13
:
17
]
==
'
Vrms
'
:
name
=
[
line
[
37
:
len
(
line
)].
rstrip
()
+
'
.Vrms
'
,
line
[
37
:
len
(
line
)].
rstrip
()
+
'
.VDegree
'
]
value
=
[
float
(
line
[
0
:
13
]),
float
(
line
[
18
:
31
])]
timeseries
.
append
(
TimeSeries
(
name
[
0
],
np
.
array
([
0.
,
1.
]),
np
.
array
([
value
[
0
],
value
[
0
]])))
timeseries
.
append
(
TimeSeries
(
name
[
1
],
np
.
array
([
0.
,
1.
]),
np
.
array
([
value
[
1
],
value
[
1
]])))
# Read in variables which match with regex
if
is_regex
is
True
:
p
=
re
.
compile
(
timeseries_names
)
length
=
len
(
timeseries
)
for
rule_check
in
range
(
length
):
if
p
.
search
(
timeseries
[
rule_check
].
name
):
pass
else
:
line_del
.
append
(
rule_check
)
# Read in specified time series
elif
timeseries_names
is
not
None
:
length
=
len
(
timeseries
)
for
rule_check
in
range
(
length
):
if
timeseries_names
==
timeseries
[
rule_check
].
name
:
pass
else
:
line_del
.
append
(
rule_check
)
# delete those values that are not needed.
line_del
=
set
(
line_del
)
line_del
=
sorted
(
line_del
)
for
num_to_del
in
range
(
len
(
line_del
)):
del
timeseries
[
line_del
[
len
(
line_del
)
-
num_to_del
-
1
]]
return
timeseries
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