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
Commits
f3012cf8
Commit
f3012cf8
authored
8 years ago
by
mads
Browse files
Options
Downloads
Patches
Plain Diff
added set_time in htcfile and improved general set-function
parent
b1044933
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
wetb/hawc2/htc_file.py
+19
-7
19 additions, 7 deletions
wetb/hawc2/htc_file.py
wetb/hawc2/tests/test_htc_file.py
+25
-4
25 additions, 4 deletions
wetb/hawc2/tests/test_htc_file.py
with
44 additions
and
11 deletions
wetb/hawc2/htc_file.py
+
19
−
7
View file @
f3012cf8
...
...
@@ -104,16 +104,28 @@ class HTCFile(HTCContents, HTCDefaults):
with
open
(
filename
,
'
w
'
,
encoding
=
'
utf-8
'
)
as
fid
:
fid
.
write
(
str
(
self
))
def
set_name
(
self
,
name
,
folder
=
"
htc
/
"
):
def
set_name
(
self
,
name
,
htc_
folder
=
"
htc
"
,
log_folder
=
"
log
"
,
res_folder
=
"
res
"
):
#if os.path.isabs(folder) is False and os.path.relpath(folder).startswith("htc" + os.path.sep):
folder
=
"
./
"
+
os
.
path
.
relpath
(
folder
).
replace
(
"
\\
"
,
"
/
"
)
fmt_
folder
=
lambda
folder
:
"
./
"
+
os
.
path
.
relpath
(
folder
).
replace
(
"
\\
"
,
"
/
"
)
self
.
filename
=
os
.
path
.
rel
path
(
os
.
path
.
join
(
self
.
modelpath
,
folder
,
"
%s.htc
"
%
name
)).
replace
(
"
\\
"
,
"
/
"
)
self
.
filename
=
os
.
path
.
abs
path
(
os
.
path
.
join
(
self
.
modelpath
,
fmt_
folder
(
htc_folder
)
,
"
%s.htc
"
%
name
)).
replace
(
"
\\
"
,
"
/
"
)
if
'
simulation
'
in
self
and
'
logfile
'
in
self
.
simulation
:
self
.
simulation
.
logfile
=
os
.
path
.
join
(
folder
.
replace
(
"
htc
"
,
"
log
"
,
1
),
"
%s.log
"
%
name
).
replace
(
"
\\
"
,
"
/
"
)
elif
'
test_structure
'
in
self
and
'
logfile
'
in
self
.
test_structure
:
self
.
test_structure
.
logfile
=
os
.
path
.
join
(
folder
.
replace
(
"
htc
"
,
"
log
"
,
1
),
"
%s.log
"
%
name
).
replace
(
"
\\
"
,
"
/
"
)
self
.
output
.
filename
=
os
.
path
.
join
(
folder
.
replace
(
"
htc
"
,
"
res
"
,
1
),
"
%s
"
%
name
).
replace
(
"
\\
"
,
"
/
"
)
self
.
simulation
.
logfile
=
os
.
path
.
join
(
fmt_folder
(
log_folder
),
"
%s.log
"
%
name
).
replace
(
"
\\
"
,
"
/
"
)
elif
'
test_structure
'
in
self
and
'
logfile
'
in
self
.
test_structure
:
# hawc2aero
self
.
test_structure
.
logfile
=
os
.
path
.
join
(
fmt_folder
(
log_folder
),
"
%s.log
"
%
name
).
replace
(
"
\\
"
,
"
/
"
)
self
.
output
.
filename
=
os
.
path
.
join
(
fmt_folder
(
res_folder
),
"
%s
"
%
name
).
replace
(
"
\\
"
,
"
/
"
)
def
set_time
(
self
,
start
=
None
,
stop
=
None
,
step
=
None
):
if
stop
is
not
None
:
self
.
simulation
.
time_stop
=
stop
else
:
stop
=
self
.
simulation
.
time_stop
[
0
]
if
step
is
not
None
:
self
.
simulation
.
newmark
.
deltat
=
step
if
start
is
not
None
:
self
.
output
.
time
=
start
,
stop
if
"
wind
"
in
self
and
self
.
wind
.
turb_format
[
0
]
>
0
:
self
.
wind
.
scale_time_start
=
start
def
input_files
(
self
):
files
=
self
.
htc_inputfiles
...
...
This diff is collapsed.
Click to expand it.
wetb/hawc2/tests/test_htc_file.py
+
25
−
4
View file @
f3012cf8
...
...
@@ -84,6 +84,14 @@ class TestHtcFile(unittest.TestCase):
self
.
assertEqual
(
htcfile
.
simulation
.
time_stop
[
0
],
2
*
time_stop
)
self
.
assertEqual
(
htcfile
.
simulation
.
time_stop
.
__class__
,
HTCLine
)
htcfile
.
output
.
time
=
10
,
20
self
.
assertEqual
(
htcfile
.
output
.
time
[:
2
],
[
10
,
20
])
self
.
assertEqual
(
str
(
htcfile
.
output
.
time
),
"
time
\t
10 20;
\n
"
)
htcfile
.
output
.
time
=
[
11
,
21
]
self
.
assertEqual
(
htcfile
.
output
.
time
[:
2
],
[
11
,
21
])
htcfile
.
output
.
time
=
"
12 22
"
self
.
assertEqual
(
htcfile
.
output
.
time
[:
2
],
[
12
,
22
])
def
test_htc_file_set_key
(
self
):
htcfile
=
HTCFile
(
self
.
testfilepath
+
"
test.htc
"
)
htcfile
.
simulation
.
name
=
"
value
"
...
...
@@ -99,9 +107,21 @@ class TestHtcFile(unittest.TestCase):
pass
def
test_htcfile_setname
(
self
):
htcfile
=
HTCFile
()
htcfile
.
set_name
(
"
mytest
"
)
self
.
assertEqual
(
htcfile
.
filename
,
'
../htc/mytest.htc
'
)
htcfile
=
HTCFile
(
self
.
testfilepath
+
"
test.htc
"
)
htcfile
.
set_name
(
"
mytest
"
,
htc_folder
=
"
htcfiles
"
)
self
.
assertEqual
(
os
.
path
.
relpath
(
htcfile
.
filename
,
self
.
testfilepath
),
r
'
mytest.htc
'
)
self
.
assertEqual
(
htcfile
.
simulation
.
logfile
[
0
],
'
./log/mytest.log
'
)
self
.
assertEqual
(
htcfile
.
output
.
filename
[
0
],
'
./res/mytest
'
)
def
test_set_time
(
self
):
htcfile
=
HTCFile
(
self
.
testfilepath
+
"
test.htc
"
)
htcfile
.
set_time
(
10
,
20
,
0.2
)
self
.
assertEqual
(
htcfile
.
simulation
.
time_stop
[
0
],
20
)
self
.
assertEqual
(
htcfile
.
simulation
.
newmark
.
deltat
[
0
],
0.2
)
self
.
assertEqual
(
htcfile
.
wind
.
scale_time_start
[
0
],
10
)
self
.
assertEqual
(
htcfile
.
output
.
time
[:
2
],
[
10
,
20
])
...
...
@@ -124,7 +144,7 @@ class TestHtcFile(unittest.TestCase):
box_dim_u
\t
4096 1.4652;
box_dim_v
\t
32 3.2258;
box_dim_w
\t
32 3.2258;
std_scaling
\t
1
.000000 0.800000 0.500000
;
"""
std_scaling
\t
1
0.8 0.5
;
"""
for
a
,
b
in
zip
(
s
.
split
(
"
\n
"
),
str
(
htcfile
.
wind
.
mann
).
split
(
"
\n
"
)):
self
.
assertEqual
(
a
.
strip
(),
b
.
strip
())
self
.
assertEqual
(
htcfile
.
wind
.
turb_format
[
0
],
1
)
...
...
@@ -223,6 +243,7 @@ class TestHtcFile(unittest.TestCase):
if
__name__
==
"
__main__
"
:
#import sys;sys.argv = ['', 'Test.testName']
unittest
.
main
()
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