Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MetObsCommon
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor 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
MetObs
MetObsCommon
Commits
c749cc63
Verified
Commit
c749cc63
authored
2 years ago
by
David Hoese
Browse files
Options
Downloads
Patches
Plain Diff
Add initial basic tests of influxdb tools
parent
fd17fdca
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
metobscommon/tests/test_influxdb.py
+39
-0
39 additions, 0 deletions
metobscommon/tests/test_influxdb.py
metobscommon/util/calc.py
+2
-3
2 additions, 3 deletions
metobscommon/util/calc.py
with
41 additions
and
3 deletions
metobscommon/tests/test_influxdb.py
0 → 100644
+
39
−
0
View file @
c749cc63
from
datetime
import
datetime
from
metobscommon
import
influxdb
def
test_frame_records_single_dict
():
now
=
datetime
(
2023
,
1
,
1
,
12
,
0
,
0
)
timestamp
=
1672574400000000000
# now in nanoseconds from epoch
data_dict
=
{
"
air_temp
"
:
20.0
,
"
wind_speed
"
:
15.0
,
"
timestamp
"
:
now
,
}
lines
=
list
(
influxdb
.
frame_records
(
data_dict
,
measurement_name
=
"
test
"
,
site
=
"
aoss
"
,
inst
=
"
tower
"
,
))
assert
len
(
lines
)
==
1
assert
lines
[
0
]
==
f
"
test,inst=tower,site=aoss air_temp=20.0,wind_speed=15.0
{
timestamp
}
"
def
test_frame_records_single_dict_with_winds
():
now
=
datetime
(
2023
,
1
,
1
,
12
,
0
,
0
)
timestamp
=
1672574400000000000
# now in nanoseconds from epoch
data_dict
=
{
"
air_temp
"
:
20.0
,
"
wind_speed
"
:
15.0
,
"
wind_dir
"
:
0.0
,
"
timestamp
"
:
now
,
}
lines
=
list
(
influxdb
.
frame_records
(
data_dict
,
measurement_name
=
"
test
"
,
site
=
"
aoss
"
,
inst
=
"
tower
"
,
))
assert
len
(
lines
)
==
1
assert
lines
[
0
]
==
f
"
test,inst=tower,site=aoss air_temp=20.0,wind_speed=15.0,wind_east=0.0,wind_north=15.0
{
timestamp
}
"
This diff is collapsed.
Click to expand it.
metobscommon/util/calc.py
+
2
−
3
View file @
c749cc63
...
...
@@ -126,10 +126,9 @@ def dir2txt(val):
def
wind_vector_components
(
windspd
,
winddir
):
"""
Decompose scalar or list/array polar wind direction and speed data
into the horizontal and vertical vector components and speed vector.
"""
Decompose polar wind direction and speed into the horizontal and vertical vector components and speed vector.
Inputs can be scalar or arrays.
Inputs can be scalar or arrays.
Wind direction of 0 is north.
"""
dir_rad
=
np
.
deg2rad
(
winddir
)
spd_arr
=
np
.
array
(
windspd
)
...
...
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