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
d15e98c3
There was a problem fetching the pipeline summary.
Commit
d15e98c3
authored
8 years ago
by
David Verelst
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' of gitlab.windenergy.dtu.dk:toolbox/WindEnergyToolbox
parents
e25bf01a
8b13f0ce
No related branches found
No related tags found
No related merge requests found
Pipeline
#
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
wetb/utils/geometry.py
+36
-2
36 additions, 2 deletions
wetb/utils/geometry.py
wetb/utils/tests/test_geometry.py
+6
-0
6 additions, 0 deletions
wetb/utils/tests/test_geometry.py
with
42 additions
and
2 deletions
wetb/utils/geometry.py
+
36
−
2
View file @
d15e98c3
...
@@ -29,13 +29,33 @@ def mean_deg(dir, axis=0):
...
@@ -29,13 +29,33 @@ def mean_deg(dir, axis=0):
----------
----------
dir : array_like
dir : array_like
Angles in degrees
Angles in degrees
axis : int
if dir is 2d array_like, axis defines which axis to take the mean of
Returns
Returns
-------
-------
mean_deg : float
mean_deg : float
Mean angle
Mean angle
"""
"""
return
deg
(
np
.
arctan2
(
np
.
mean
(
sind
(
dir
[:]),
axis
),
np
.
mean
(
cosd
(
dir
[:]),
axis
)))
return
deg
(
mean_rad
(
rad
(
dir
),
axis
))
def
mean_rad
(
dir
,
axis
=
0
):
"""
Mean of angles in radians
Parameters
----------
dir : array_like
Angles in radians
axis : int
if dir is 2d array_like, axis defines which axis to take the mean of
Returns
-------
mean_rad : float
Mean angle
"""
return
np
.
arctan2
(
np
.
nanmean
(
np
.
sin
(
dir
[:]),
axis
),
np
.
nanmean
(
np
.
cos
(
dir
[:]),
axis
))
def
std_deg
(
dir
):
def
std_deg
(
dir
):
"""
Standard deviation of angles in degrees
"""
Standard deviation of angles in degrees
...
@@ -50,8 +70,22 @@ def std_deg(dir):
...
@@ -50,8 +70,22 @@ def std_deg(dir):
std_deg : float
std_deg : float
standard deviation
standard deviation
"""
"""
return
deg
(
np
.
sqrt
(
1
-
(
np
.
mean
(
sind
(
dir
))
**
2
+
np
.
mean
(
cosd
(
dir
))
**
2
)))
return
deg
(
std_rad
(
rad
(
dir
)))
def
std_rad
(
dir
):
"""
Standard deviation of angles in radians
Parameters
----------
dir : array_like
Angles in radians
Returns
-------
std_rad : float
standard deviation
"""
return
np
.
sqrt
(
1
-
(
np
.
nanmean
(
np
.
sin
(
dir
))
**
2
+
np
.
nanmean
(
np
.
cos
(
dir
))
**
2
))
def
wsp_dir2uv
(
wsp
,
dir
,
dir_ref
=
None
):
def
wsp_dir2uv
(
wsp
,
dir
,
dir_ref
=
None
):
"""
Convert horizontal wind speed and direction to u,v
"""
Convert horizontal wind speed and direction to u,v
...
...
This diff is collapsed.
Click to expand it.
wetb/utils/tests/test_geometry.py
+
6
−
0
View file @
d15e98c3
...
@@ -57,11 +57,17 @@ class TestGeometry(unittest.TestCase):
...
@@ -57,11 +57,17 @@ class TestGeometry(unittest.TestCase):
np
.
testing
.
assert_array_almost_equal
(
mean_deg
(
a
,
1
),
[
45
,
0
,
-
45
])
np
.
testing
.
assert_array_almost_equal
(
mean_deg
(
a
,
1
),
[
45
,
0
,
-
45
])
np
.
testing
.
assert_array_almost_equal
(
mean_deg
(
a
.
T
,
0
),
[
45
,
0
,
-
45
])
np
.
testing
.
assert_array_almost_equal
(
mean_deg
(
a
.
T
,
0
),
[
45
,
0
,
-
45
])
def
test_mean_deg_nan
(
self
):
self
.
assertEqual
(
mean_deg
(
np
.
array
([
0.
,
90
,
np
.
nan
])),
45
)
def
test_std_deg
(
self
):
def
test_std_deg
(
self
):
self
.
assertEqual
(
std_deg
(
np
.
array
([
0
,
0
,
0
])),
0
)
self
.
assertEqual
(
std_deg
(
np
.
array
([
0
,
0
,
0
])),
0
)
self
.
assertAlmostEqual
(
std_deg
(
np
.
array
([
0
,
90
,
180
,
270
])),
57.296
,
2
)
self
.
assertAlmostEqual
(
std_deg
(
np
.
array
([
0
,
90
,
180
,
270
])),
57.296
,
2
)
def
test_std_deg_nan
(
self
):
self
.
assertAlmostEqual
(
std_deg
(
np
.
array
([
0
,
90
,
180
,
270
,
np
.
nan
])),
57.296
,
2
)
def
test_wspdir2uv
(
self
):
def
test_wspdir2uv
(
self
):
u
,
v
=
wsp_dir2uv
(
np
.
array
([
1
,
1
,
1
]),
np
.
array
([
30
,
0
,
330
]))
u
,
v
=
wsp_dir2uv
(
np
.
array
([
1
,
1
,
1
]),
np
.
array
([
30
,
0
,
330
]))
np
.
testing
.
assert_array_almost_equal
(
u
,
[
0.8660
,
1
,
0.8660
],
3
)
np
.
testing
.
assert_array_almost_equal
(
u
,
[
0.8660
,
1
,
0.8660
],
3
)
...
...
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