Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
WindEnergyToolbox
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
wtlib
WindEnergyToolbox
Commits
38694412
Commit
38694412
authored
6 years ago
by
Emmanuel Branlard
Browse files
Options
Downloads
Patches
Plain Diff
Some fast out files have a different number of header lines
parent
8e10d70d
No related branches found
No related tags found
No related merge requests found
Pipeline
#5518
failed
6 years ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
wetb/fast/fast_io.py
+32
-11
32 additions, 11 deletions
wetb/fast/fast_io.py
with
32 additions
and
11 deletions
wetb/fast/fast_io.py
+
32
−
11
View file @
38694412
...
@@ -49,17 +49,38 @@ def load_ascii_output(filename):
...
@@ -49,17 +49,38 @@ def load_ascii_output(filename):
with
open
(
filename
)
as
f
:
with
open
(
filename
)
as
f
:
info
=
{}
info
=
{}
info
[
'
name
'
]
=
os
.
path
.
splitext
(
os
.
path
.
basename
(
filename
))[
0
]
info
[
'
name
'
]
=
os
.
path
.
splitext
(
os
.
path
.
basename
(
filename
))[
0
]
try
:
# Header is whatever is before the keyword `time`
header
=
[
f
.
readline
()
for
_
in
range
(
8
)]
in_header
=
True
info
[
'
description
'
]
=
header
[
4
].
strip
()
header
=
[]
info
[
'
attribute_names
'
]
=
header
[
6
].
split
()
while
in_header
:
info
[
'
attribute_units
'
]
=
[
unit
[
1
:
-
1
]
for
unit
in
header
[
7
].
split
()]
#removing "()"
l
=
f
.
readline
()
data
=
np
.
array
([
line
.
split
()
for
line
in
f
.
readlines
()]).
astype
(
np
.
float
)
if
not
l
:
raise
Exception
(
'
Error finding the end of FAST out file header. Keyword Time missing.
'
)
return
data
,
info
in_header
=
(
l
+
'
dummy
'
).
lower
().
split
()[
0
]
!=
'
time
'
except
(
ValueError
,
AssertionError
):
if
in_header
:
header
.
append
(
l
)
raise
else
:
info
[
'
description
'
]
=
header
info
[
'
attribute_names
'
]
=
l
.
split
()
info
[
'
attribute_units
'
]
=
[
unit
[
1
:
-
1
]
for
unit
in
f
.
readline
().
split
()]
# Data, up to end of file or empty line (potential comment line at the end)
split_lines
=
[]
while
True
:
l
=
f
.
readline
().
strip
()
if
not
l
or
len
(
l
)
==
0
:
break
split_lines
.
append
(
l
.
split
())
data
=
np
.
array
(
split_lines
).
astype
(
np
.
float
)
# Harcoded 8 line header and
#header = [f.readline() for _ in range(8)]
#info['description'] = header[4].strip()
#info['attribute_names'] = header[6].split()
#info['attribute_units'] = [unit[1:-1] for unit in header[7].split()] #removing "()"
#data = np.array([line.split() for line in f.readlines() if len(line)]).astype(np.float)
return
data
,
info
def
load_binary_output
(
filename
):
def
load_binary_output
(
filename
):
...
...
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