Skip to content
Snippets Groups Projects
Commit 3100c32b authored by William Roberts's avatar William Roberts
Browse files

Fix mask being called in incorrect place

parent f29c1570
No related branches found
No related tags found
No related merge requests found
......@@ -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)
......
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()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment