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
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
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
toolbox
WindEnergyToolbox
Merge requests
!95
Save st
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Save st
save_st
into
master
Overview
2
Commits
1
Pipelines
3
Changes
2
Merged
Mads M. Pedersen
requested to merge
save_st
into
master
6 years ago
Overview
2
Commits
1
Pipelines
3
Changes
2
Expand
0
0
Merge request reports
Viewing commit
db469bb9
Show latest version
2 files
+
52
−
11
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
2
Search (e.g. *.vue) (Ctrl+P)
db469bb9
hawc2.StFile: add method to save st file (plus test)
· db469bb9
David Verelst
authored
6 years ago
wetb/hawc2/tests/test_st_file.py
+
20
−
3
Options
@@ -10,15 +10,19 @@ from __future__ import absolute_import
from
future
import
standard_library
standard_library
.
install_aliases
()
import
unittest
from
wetb.hawc2.st_file
import
StFile
import
os
from
numpy
import
testing
from
wetb.hawc2.st_file
import
StFile
testfilepath
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'
test_files/
'
)
# test file path
class
TestStFile
(
unittest
.
TestCase
):
def
test_stfile
(
self
):
st
=
StFile
(
testfilepath
+
"
DTU_10MW_RWT_Blade_st.dat
"
)
st
=
StFile
(
testfilepath
+
'
DTU_10MW_RWT_Blade_st.dat
'
)
self
.
assertEqual
(
st
.
radius_st
()[
2
],
3.74238
)
self
.
assertEqual
(
st
.
radius_st
(
3
),
3.74238
)
self
.
assertEqual
(
st
.
x_e
(
67.7351
),
4.4320990737400E-01
)
@@ -27,10 +31,23 @@ class TestStFile(unittest.TestCase):
def
test_stfile_interpolate
(
self
):
st
=
StFile
(
testfilepath
+
"
DTU_10MW_RWT_Blade_st.dat
"
)
st
=
StFile
(
testfilepath
+
'
DTU_10MW_RWT_Blade_st.dat
'
)
self
.
assertAlmostEqual
(
st
.
x_e
(
72.2261
),
0.381148048
)
self
.
assertAlmostEqual
(
st
.
y_e
(
72.2261
),
0.016692967
)
def
test_save
(
self
):
fname
=
os
.
path
.
join
(
testfilepath
,
'
DTU_10MW_RWT_Blade_st.dat
'
)
fname2
=
os
.
path
.
join
(
testfilepath
,
'
DTU_10MW_RWT_Blade_st2.dat
'
)
st
=
StFile
(
fname
)
st
.
save
(
fname2
,
encoding
=
'
utf-8
'
,
precision
=
'
%20.12e
'
)
st2
=
StFile
(
fname2
)
self
.
assertEqual
(
len
(
st
.
main_data_sets
),
len
(
st2
.
main_data_sets
))
self
.
assertEqual
(
len
(
st
.
main_data_sets
[
1
]),
len
(
st2
.
main_data_sets
[
1
]))
for
k
in
st
.
main_data_sets
[
1
]:
testing
.
assert_almost_equal
(
st
.
main_data_sets
[
1
][
k
],
st2
.
main_data_sets
[
1
][
k
],
decimal
=
12
)
os
.
remove
(
fname2
)
if
__name__
==
"
__main__
"
:
#import sys;sys.argv = ['', 'Test.testName']
Loading