Skip to content
Snippets Groups Projects
Unverified Commit 2e8b79ed authored by David Hoese's avatar David Hoese
Browse files

Change retrieval of wind_speed to assume it's in the database

parent 6a6189d9
Branches
No related tags found
No related merge requests found
......@@ -59,10 +59,8 @@ def handle_symbols(symbols):
if not trans:
raise ValueError("Unknown site/instrument: {},{}".format(site, inst))
influx_name = trans.get(s)
if s in ('wind_speed', 'wind_direction'):
if s == "wind_direction":
add_winds.add((site, inst))
# ret.setdefault((site, inst), []).append((None, 'wind_east'))
# ret.setdefault((site, inst), []).append((None, 'wind_north'))
elif influx_name is None:
raise ValueError("Unknown symbol: {}".format(symbol))
......@@ -153,10 +151,6 @@ def handle_json(frame, symbols, epoch, order='columns', **kwargs):
def handle_xml(frame, symbols, epoch, sep=',', **kwargs):
doc = Document()
if not sep:
sep = ','
header = 'metobs'
timeStamps = list(frame.columns.values)
......@@ -224,22 +218,20 @@ def handle_xml(frame, symbols, epoch, sep=',', **kwargs):
def handle_influxdb_result(result, symbols, interval):
frames = []
# TODO: Round symbol values
# TODO: Mask invalid values
for si, (req_syms, influx_symbs) in symbols.items():
data_points = result.get_points('metobs_' + interval, tags={'site': si[0], 'inst': si[1]})
frame = pd.DataFrame(data_points, columns=['time'] + influx_symbs)
frame.set_index('time', inplace=True)
frame.fillna(value=np.nan, inplace=True)
if influx_symbs[-1] == 'wind_north':
# remove winds
if 'wind_speed' in frame.columns:
frame['wind_speed'] = round_value(np.hypot(frame['wind_east'], frame['wind_north']), 'wind_speed')
# remove wind components
if 'wind_dir' in frame.columns:
frame['wind_direction'] = round_value(np.rad2deg(np.arctan2(frame['wind_east'], frame['wind_north'])), 'wind_direction')
frame['wind_direction'] = np.rad2deg(np.arctan2(frame['wind_east'], frame['wind_north']))
frame = frame.iloc[:, :-2]
frame.columns = req_syms[:-2]
else:
frame.columns = req_syms
frame = frame.round({s: ROUNDING.get(s, 1) for s in frame.columns})
frames.append(frame)
frame = pd.concat(frames, axis=1, copy=False)
return frame
......
......@@ -16,7 +16,6 @@ def parse_dt(d):
def query(site, inst, symbols, begin, end, value, epoch):
host = 'metobs01'
host = 'localhost'
port = 8086
username = 'root'
password = 'root'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment