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
564151b0
Commit
564151b0
authored
6 years ago
by
Mads M. Pedersen
Browse files
Options
Downloads
Patches
Plain Diff
add support for
htc.wind.mann['filename_u'] = 'testu.bin'
parent
f14b72d9
No related branches found
No related tags found
No related merge requests found
Pipeline
#7366
passed
6 years ago
Stage: test
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
wetb/hawc2/htc_contents.py
+20
-14
20 additions, 14 deletions
wetb/hawc2/htc_contents.py
wetb/hawc2/turbulence_file.py
+11
-11
11 additions, 11 deletions
wetb/hawc2/turbulence_file.py
with
31 additions
and
25 deletions
wetb/hawc2/htc_contents.py
+
20
−
14
View file @
564151b0
...
@@ -54,15 +54,6 @@ class HTCContents(object):
...
@@ -54,15 +54,6 @@ class HTCContents(object):
name_
=
""
name_
=
""
parent
=
None
parent
=
None
def
__setitem__
(
self
,
key
,
value
):
if
isinstance
(
key
,
str
):
self
.
contents
[
key
]
=
value
value
.
parent
=
self
elif
isinstance
(
key
,
int
):
self
.
values
[
key
]
=
value
else
:
raise
NotImplementedError
def
__getitem__
(
self
,
key
):
def
__getitem__
(
self
,
key
):
if
isinstance
(
key
,
str
):
if
isinstance
(
key
,
str
):
key
=
key
.
replace
(
"
.
"
,
"
/
"
)
key
=
key
.
replace
(
"
.
"
,
"
/
"
)
...
@@ -152,11 +143,6 @@ class HTCContents(object):
...
@@ -152,11 +143,6 @@ class HTCContents(object):
for
k
in
keys
:
for
k
in
keys
:
del
self
.
parent
.
contents
[
k
]
del
self
.
parent
.
contents
[
k
]
def
add_line
(
self
,
name
,
values
,
comments
=
""
):
line
=
HTCLine
(
name
,
values
,
comments
)
self
.
_add_contents
(
line
)
return
line
def
location
(
self
):
def
location
(
self
):
if
self
.
parent
is
None
:
if
self
.
parent
is
None
:
return
os
.
path
.
basename
(
self
.
filename
)
return
os
.
path
.
basename
(
self
.
filename
)
...
@@ -192,6 +178,20 @@ class HTCSection(HTCContents):
...
@@ -192,6 +178,20 @@ class HTCSection(HTCContents):
self
.
end_comments
=
end_comments
.
strip
(
"
\t
"
)
self
.
end_comments
=
end_comments
.
strip
(
"
\t
"
)
self
.
contents
=
OrderedDict
()
self
.
contents
=
OrderedDict
()
def
add_line
(
self
,
name
,
values
,
comments
=
""
):
line
=
HTCLine
(
name
,
values
,
comments
)
self
.
_add_contents
(
line
)
return
line
def
__setitem__
(
self
,
key
,
value
):
if
isinstance
(
value
,
HTCContents
):
self
.
contents
[
key
]
=
value
value
.
parent
=
self
elif
isinstance
(
value
,
str
):
self
.
add_line
(
key
,
[
value
])
else
:
self
.
add_line
(
key
,
value
)
@staticmethod
@staticmethod
def
from_lines
(
lines
):
def
from_lines
(
lines
):
line
,
begin_comments
=
parse_next_line
(
lines
)
line
,
begin_comments
=
parse_next_line
(
lines
)
...
@@ -266,6 +266,12 @@ class HTCLine(HTCContents):
...
@@ -266,6 +266,12 @@ class HTCLine(HTCContents):
except
:
except
:
raise
IndexError
(
"
Parameter %s does not exists for %s
"
%
(
key
+
1
,
self
.
location
()))
raise
IndexError
(
"
Parameter %s does not exists for %s
"
%
(
key
+
1
,
self
.
location
()))
def
__setitem__
(
self
,
key
,
value
):
if
isinstance
(
key
,
int
):
self
.
values
[
key
]
=
value
else
:
raise
NotImplementedError
@staticmethod
@staticmethod
def
from_lines
(
lines
):
def
from_lines
(
lines
):
line
,
end_comments
=
parse_next_line
(
lines
)
line
,
end_comments
=
parse_next_line
(
lines
)
...
...
This diff is collapsed.
Click to expand it.
wetb/hawc2/turbulence_file.py
+
11
−
11
View file @
564151b0
...
@@ -19,21 +19,21 @@ class TurbulenceFile(object):
...
@@ -19,21 +19,21 @@ class TurbulenceFile(object):
self
.
mean_wsp
=
mean_wsp
self
.
mean_wsp
=
mean_wsp
self
.
center_position
=
center_position
self
.
center_position
=
center_position
self
.
data
=
mann_turbulence
.
load
(
filename
,
Nxyz
)
self
.
data
=
mann_turbulence
.
load
(
filename
,
Nxyz
)
@property
def
data3d
(
self
):
return
self
.
data
.
reshape
(
self
.
Nxyz
)
@staticmethod
@staticmethod
def
load_from_htc
(
htcfilename
,
modelpath
=
None
,
type
=
'
mann
'
):
def
load_from_htc
(
htcfilename
,
modelpath
=
None
,
type
=
'
mann
'
):
htc
=
HTCFile
(
htcfilename
,
modelpath
)
htc
=
HTCFile
(
htcfilename
,
modelpath
)
Nxyz
=
np
.
array
([
htc
.
wind
[
type
][
'
box_dim_%s
'
%
uvw
][
0
]
for
uvw
in
'
uvw
'
])
Nxyz
=
np
.
array
([
htc
.
wind
[
type
][
'
box_dim_%s
'
%
uvw
][
0
]
for
uvw
in
'
uvw
'
])
dxyz
=
np
.
array
([
htc
.
wind
[
type
][
'
box_dim_%s
'
%
uvw
][
1
]
for
uvw
in
'
uvw
'
])
dxyz
=
np
.
array
([
htc
.
wind
[
type
][
'
box_dim_%s
'
%
uvw
][
1
]
for
uvw
in
'
uvw
'
])
center_position
=
htc
.
wind
.
center_pos0
.
values
center_position
=
htc
.
wind
.
center_pos0
.
values
wsp
=
htc
.
wind
.
wsp
wsp
=
htc
.
wind
.
wsp
return
[
TurbulenceFile
(
os
.
path
.
join
(
htc
.
modelpath
,
htc
.
wind
[
type
][
'
filename_%s
'
%
uvw
][
0
]),
Nxyz
,
dxyz
,
wsp
,
(
0
,
wsp
)[
uvw
==
'
u
'
],
center_position
)
for
uvw
in
'
uvw
'
]
return
[
TurbulenceFile
(
os
.
path
.
join
(
htc
.
modelpath
,
htc
.
wind
[
type
][
'
filename_%s
'
%
uvw
][
0
]),
Nxyz
,
dxyz
,
wsp
,
(
0
,
wsp
)[
uvw
==
'
u
'
],
center_position
)
for
uvw
in
'
uvw
'
]
if
__name__
==
'
__main__
'
:
if
__name__
==
'
__main__
'
:
pass
pass
\ No newline at end of file
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