Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AossTower
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Monitor
Incidents
Analyze
Value stream analytics
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
AossTower
Commits
3100c32b
Commit
3100c32b
authored
5 years ago
by
William Roberts
Browse files
Options
Downloads
Patches
Plain Diff
Fix mask being called in incorrect place
parent
f29c1570
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
aosstower/level_00/influxdb.py
+8
-9
8 additions, 9 deletions
aosstower/level_00/influxdb.py
aosstower/tests/test_influxdb.py
+23
-0
23 additions, 0 deletions
aosstower/tests/test_influxdb.py
with
31 additions
and
9 deletions
aosstower/level_00/influxdb.py
+
8
−
9
View file @
3100c32b
...
...
@@ -92,8 +92,8 @@ class Updater(object):
return
self
.
_calculate_averages
()
def
_calculate_averages
(
self
):
frame
=
pd
.
DataFrame
(
self
.
data
)
frame
=
frame
.
set_index
(
'
timestamp
'
).
mask
(
frame
==
-
99999.
)
frame
=
pd
.
DataFrame
(
self
.
data
)
.
set_index
(
'
timestamp
'
)
frame
=
frame
.
mask
(
frame
==
-
99999.
)
# Add wind direction components so we can average wind direction properly.
frame
[
'
wind_east
'
],
frame
[
'
wind_north
'
],
_
=
calc
.
wind_vector_components
(
frame
[
'
wind_speed
'
],
frame
[
'
wind_dir
'
])
...
...
@@ -137,7 +137,7 @@ def convert_to_influx_frame(record_gen, symbols, debug=False):
def
construct_url
(
data
):
# Sends data as empty string to show that recording worked, but that the data is nonexistent.
# Sends
null
data as empty string to show that recording worked, but that the data is nonexistent.
for
key
,
val
in
data
.
items
():
if
val
is
None
or
isinstance
(
val
,
float
)
and
np
.
isnan
(
val
):
data
[
key
]
=
''
...
...
@@ -241,13 +241,12 @@ def main():
# Record is in a list of size 1, but want just the record.
avg
=
updater
.
rolling_average
(
record
[
0
])
# Once every 5 minutes: 0 through 295 seconds inclusive in 5 second intervals.
if
avg
is
not
None
:
if
wu_pw
and
args
.
ldmp
and
avg
is
not
None
:
url
=
construct_url
(
get_url_data
(
avg
,
args
.
wu_id
,
wu_pw
))
if
wu_pw
and
args
.
ldmp
:
resp
=
requests
.
post
(
url
)
if
resp
.
status_code
!=
200
:
warnings
.
warn
(
'
Data failed to upload to {0} with status code {1}: {2}
'
.
format
(
url
,
resp
.
status_code
,
resp
.
text
))
resp
=
requests
.
post
(
url
)
if
resp
.
status_code
!=
200
:
warnings
.
warn
(
'
Data failed to upload to {0} with status code {1}: {2}
'
.
format
(
url
,
resp
.
status_code
,
resp
.
text
))
if
args
.
sleep_interval
:
time
.
sleep
(
args
.
sleep_interval
)
...
...
This diff is collapsed.
Click to expand it.
aosstower/tests/test_influxdb.py
0 → 100644
+
23
−
0
View file @
3100c32b
import
unittest
class
TestInfluxdb
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
test_cases
=
[]
def
tearDown
(
self
):
return
def
suite
():
"""
The test suite for test_wind_functions.
"""
loader
=
unittest
.
TestLoader
()
mysuite
=
unittest
.
TestSuite
()
mysuite
.
addTest
(
loader
.
loadTestsFromTestCase
(
TestInfluxdb
))
return
mysuite
if
__name__
==
"
__main__
"
:
unittest
.
main
()
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