Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
PyWake
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
TOPFARM
PyWake
Commits
d38562e2
Commit
d38562e2
authored
3 years ago
by
Mads M. Pedersen
Browse files
Options
Downloads
Patches
Plain Diff
merge functions da2py and coords2py
parent
1f33b135
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
py_wake/site/_site.py
+4
-4
4 additions, 4 deletions
py_wake/site/_site.py
py_wake/utils/xarray_utils.py
+3
-7
3 additions, 7 deletions
py_wake/utils/xarray_utils.py
py_wake/wind_farm_models/wind_farm_model.py
+3
-3
3 additions, 3 deletions
py_wake/wind_farm_models/wind_farm_model.py
with
10 additions
and
14 deletions
py_wake/site/_site.py
+
4
−
4
View file @
d38562e2
...
...
@@ -4,7 +4,7 @@ from py_wake.site.shear import PowerShear
import
py_wake.utils.xarray_utils
# register ilk function @UnusedImport
import
xarray
as
xr
from
abc
import
ABC
,
abstractmethod
from
py_wake.utils.xarray_utils
import
da2py
,
coords2py
from
py_wake.utils.xarray_utils
import
da2py
"""
suffixs:
...
...
@@ -49,9 +49,9 @@ class LocalWind(xr.Dataset):
for
k
,
v
in
[(
'
x
'
,
x_i
),
(
'
y
'
,
y_i
),
(
'
h
'
,
h_i
)]:
if
v
is
not
None
:
coords
[
k
]
=
(
'
i
'
,
np
.
zeros
(
n_i
)
+
v
)
xr
.
Dataset
.
__init__
(
self
,
data_vars
=
{
k
:
da2py
(
v
)
for
k
,
v
in
[(
'
WD
'
,
WD
),
(
'
WS
'
,
WS
),
(
'
TI
'
,
TI
),
(
'
P
'
,
P
)]
if
v
is
not
None
},
coords
=
{
k
:
coords
2py
(
v
)
for
k
,
v
in
coords
.
items
()})
xr
.
Dataset
.
__init__
(
self
,
data_vars
=
{
k
:
da2py
(
v
,
include_dims
=
True
)
for
k
,
v
in
[(
'
WD
'
,
WD
),
(
'
WS
'
,
WS
),
(
'
TI
'
,
TI
),
(
'
P
'
,
P
)]
if
v
is
not
None
},
coords
=
{
k
:
da
2py
(
v
)
for
k
,
v
in
coords
.
items
()})
self
.
attrs
[
'
wd_bin_size
'
]
=
wd_bin_size
# set localWind.WS_ilk etc.
...
...
This diff is collapsed.
Click to expand it.
py_wake/utils/xarray_utils.py
+
3
−
7
View file @
d38562e2
...
...
@@ -130,16 +130,12 @@ if not hasattr(xr.DataArray(None), 'ilk'):
xr
.
register_dataarray_accessor
(
'
plot
'
)(
plot_xy_map
)
def
da2py
(
v
,
include_dims
=
True
):
def
da2py
(
v
,
include_dims
=
False
):
if
isinstance
(
v
,
tuple
):
return
tuple
([
da2py
(
v
,
include_dims
)
for
v
in
v
])
if
isinstance
(
v
,
DataArray
):
if
include_dims
:
return
(
v
.
dims
,
v
.
values
)
else
:
return
v
.
values
return
v
def
coords2py
(
v
):
if
isinstance
(
v
,
tuple
):
return
tuple
([
da2py
(
v
,
False
)
for
v
in
v
])
return
v
This diff is collapsed.
Click to expand it.
py_wake/wind_farm_models/wind_farm_model.py
+
3
−
3
View file @
d38562e2
...
...
@@ -60,8 +60,8 @@ class WindFarmModel(ABC):
if
len
(
x
)
==
0
:
lw
=
UniformSite
([
1
],
0.1
).
local_wind
(
x_i
=
[],
y_i
=
[],
h_i
=
[],
wd
=
wd
,
ws
=
ws
)
z
=
xr
.
DataArray
(
np
.
zeros
((
0
,
len
(
lw
.
wd
),
len
(
lw
.
ws
))),
coords
=
[(
'
wt
'
,
[]),
(
'
wd
'
,
da2py
(
lw
.
wd
,
False
)),
(
'
ws
'
,
da2py
(
lw
.
ws
,
False
))])
z
=
xr
.
DataArray
(
np
.
zeros
((
0
,
len
(
lw
.
wd
),
len
(
lw
.
ws
))),
coords
=
[(
'
wt
'
,
[]),
(
'
wd
'
,
da2py
(
lw
.
wd
)),
(
'
ws
'
,
da2py
(
lw
.
ws
))])
return
SimulationResult
(
self
,
lw
,
[],
yaw
,
tilt
,
z
,
z
,
z
,
z
,
kwargs
)
res
=
self
.
calc_wt_interaction
(
x_i
=
np
.
asarray
(
x
),
y_i
=
np
.
asarray
(
y
),
h_i
=
h
,
type_i
=
type
,
yaw_ilk
=
yaw_ilk
,
tilt_ilk
=
tilt_ilk
,
...
...
@@ -170,7 +170,7 @@ class SimulationResult(xr.Dataset):
ilk_dims
=
([
'
wt
'
,
'
wd
'
,
'
ws
'
],
[
'
wt
'
,
'
time
'
])[
'
time
'
in
lw
]
xr
.
Dataset
.
__init__
(
self
,
data_vars
=
{
k
:
(
ilk_dims
,
da2py
((
v
,
v
[:,
:,
0
])[
'
time
'
in
lw
]
,
include_dims
=
False
),
data_vars
=
{
k
:
(
ilk_dims
,
da2py
((
v
,
v
[:,
:,
0
])[
'
time
'
in
lw
]),
{
'
Description
'
:
d
})
for
k
,
v
,
d
in
[(
'
WS_eff
'
,
WS_eff_ilk
,
'
Effective local wind speed [m/s]
'
),
(
'
TI_eff
'
,
np
.
zeros_like
(
WS_eff_ilk
)
+
TI_eff_ilk
,
...
...
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