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
852cccee
Commit
852cccee
authored
3 years ago
by
Mads M. Pedersen
Browse files
Options
Downloads
Patches
Plain Diff
new site based on global wind atlas data
parent
edccd939
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
py_wake/site/xrsite.py
+49
-3
49 additions, 3 deletions
py_wake/site/xrsite.py
py_wake/tests/test_sites/test_xrsite.py
+26
-1
26 additions, 1 deletion
py_wake/tests/test_sites/test_xrsite.py
py_wake/utils/weibull.py
+5
-0
5 additions, 0 deletions
py_wake/utils/weibull.py
with
80 additions
and
4 deletions
py_wake/site/xrsite.py
+
49
−
3
View file @
852cccee
import
xarray
as
xr
from
py_wake.site.distance
import
StraightDistance
import
numpy
as
np
from
py_wake.utils.grid_interpolator
import
GridInterpolator
,
EqDistRegGrid2DInterpolator
from
numpy
import
newaxis
as
na
import
xarray
as
xr
from
requests
import
get
from
py_wake.site._site
import
Site
from
py_wake.site.distance
import
StraightDistance
from
py_wake.utils
import
weibull
from
py_wake.utils.grid_interpolator
import
GridInterpolator
,
EqDistRegGrid2DInterpolator
class
XRSite
(
Site
):
...
...
@@ -309,3 +311,47 @@ class UniformWeibullSite(XRSite):
if
ti
is
not
None
:
ds
[
'
TI
'
]
=
ti
XRSite
.
__init__
(
self
,
ds
,
interp_method
=
interp_method
,
shear
=
shear
)
class
GlobalWindAtlasSite
(
XRSite
):
"""
Site with Global Wind Climate (GWC) from the Global Wind Atlas based on
lat and long which is interpolated at specific roughness and height.
"""
def
__init__
(
self
,
lat
,
long
,
height
,
roughness
,
ti
=
None
,
**
kwargs
):
"""
Parameters
----------
lat: float
Latitude of the location
long: float
Longitude of the location
height: float
Height of the location
roughness: float
roughness length at the location
"""
self
.
gwc_ds
=
self
.
_read_gwc
(
lat
,
long
)
if
ti
is
not
None
:
self
.
gwc_ds
[
'
TI
'
]
=
ti
XRSite
.
__init__
(
self
,
ds
=
self
.
gwc_ds
.
interp
(
height
=
height
,
roughness
=
roughness
),
**
kwargs
)
def
_read_gwc
(
self
,
lat
,
long
):
url_str
=
f
'
https://globalwindatlas.info/api/gwa/custom/Lib/?lat=
{
lat
}
&long=
{
long
}
'
lines
=
get
(
url_str
).
text
.
strip
().
split
(
'
\r\n
'
)
# Read header information one line at a time
# desc = txt[0].strip() # File Description
nrough
,
nhgt
,
nsec
=
map
(
int
,
lines
[
1
].
split
())
# dimensions
roughnesses
=
np
.
array
(
lines
[
2
].
split
(),
dtype
=
float
)
# Roughness classes
heights
=
np
.
array
(
lines
[
3
].
split
(),
dtype
=
float
)
# heights
data
=
np
.
array
([
l
.
split
()
for
l
in
lines
[
4
:]],
dtype
=
float
).
reshape
((
nrough
,
nhgt
*
2
+
1
,
nsec
))
freq
=
data
[:,
0
]
/
data
[:,
0
].
sum
(
1
)[:,
na
]
A
=
data
[:,
1
::
2
]
k
=
data
[:,
2
::
2
]
ds
=
xr
.
Dataset
({
'
Weibull_A
'
:
([
"
roughness
"
,
"
height
"
,
"
wd
"
],
A
),
'
Weibull_k
'
:
([
"
roughness
"
,
"
height
"
,
"
wd
"
],
k
),
"
Sector_frequency
"
:
([
"
roughness
"
,
"
wd
"
],
freq
)},
coords
=
{
"
height
"
:
heights
,
"
roughness
"
:
roughnesses
,
"
wd
"
:
np
.
linspace
(
0
,
360
,
nsec
,
endpoint
=
False
)})
return
ds
This diff is collapsed.
Click to expand it.
py_wake/tests/test_sites/test_xrsite.py
+
26
−
1
View file @
852cccee
import
numpy
as
np
from
py_wake.site.shear
import
PowerShear
from
py_wake.site.xrsite
import
XRSite
from
py_wake.site.xrsite
import
XRSite
,
GlobalWindAtlasSite
import
xarray
as
xr
from
py_wake.tests
import
npt
import
pytest
...
...
@@ -190,6 +190,31 @@ def test_complex_grid_local_wind(complex_grid_site):
[
0.01079997
,
0.01656828
,
0.02257487
]])
def
test_GlobalWindAtlasSite
():
ref
=
Hornsrev1Site
()
lat
,
long
=
55.52972
,
7.906111
# hornsrev
site
=
GlobalWindAtlasSite
(
lat
,
long
,
height
=
70
,
roughness
=
0.001
,
ti
=
0.075
)
ref_mean
=
weibull
.
mean
(
ref
.
ds
.
Weibull_A
,
ref
.
ds
.
Weibull_k
)
gwa_mean
=
weibull
.
mean
(
site
.
ds
.
Weibull_A
,
site
.
ds
.
Weibull_k
)
if
0
:
plt
.
figure
()
plt
.
plot
(
ref
.
ds
.
wd
,
ref_mean
,
label
=
'
HornsrevSite
'
)
plt
.
plot
(
site
.
ds
.
wd
,
gwa_mean
,
label
=
'
HornsrevSite
'
)
for
r
in
[
0
,
1.5
]:
for
h
in
[
10
,
200
]:
A
,
k
=
[
site
.
gwc_ds
[
v
].
sel
(
roughness
=
r
,
height
=
h
)
for
v
in
[
'
Weibull_A
'
,
'
Weibull_k
'
]]
plt
.
plot
(
site
.
gwc_ds
.
wd
,
weibull
.
mean
(
A
,
k
),
label
=
f
'
{
h
}
,
{
r
}
'
)
plt
.
legend
()
plt
.
show
()
npt
.
assert_allclose
(
gwa_mean
,
ref_mean
,
atol
=
1.4
)
for
var
,
atol
in
[(
'
Sector_frequency
'
,
0.03
),
(
'
Weibull_A
'
,
1.6
),
(
'
Weibull_k
'
,
0.4
)]:
npt
.
assert_allclose
(
site
.
ds
[
var
],
ref
.
ds
[
var
],
atol
=
atol
)
def
test_wrong_height
():
ti
=
0.1
ds
=
xr
.
Dataset
(
...
...
This diff is collapsed.
Click to expand it.
py_wake/utils/weibull.py
+
5
−
0
View file @
852cccee
import
numpy
as
np
from
scipy.special
import
gamma
def
mean
(
A
,
k
):
return
A
*
gamma
(
1
+
1
/
k
)
def
cdf
(
ws
,
A
,
k
):
...
...
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