Skip to content

Commit

Permalink
Merge 9a8f947 into d2dba9e
Browse files Browse the repository at this point in the history
  • Loading branch information
rhroberts committed Jan 15, 2020
2 parents d2dba9e + 9a8f947 commit 22cce3e
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 5 deletions.
18 changes: 18 additions & 0 deletions test/usgs_eddn_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,24 @@ def test_parser_twdb_texuni():
['2018-02-06 02:00:00', pd.np.nan, 72.85],
]
},
{
'message_timestamp_utc': datetime(2020, 1, 14, 13, 36, 14),
'dcp_message': '":vb 119 #720 13.00 :wl 59 #60 -217.66 -217.66 -217.64 -217.60 -217.56 -217.51 -217.45 -217.40 -217.38 -217.39 -217.41 -217.47',
'return_value': [
['2020-01-14 13:00:00', 13.0, 217.66],
['2020-01-14 12:00:00', pd.np.nan, 217.66],
['2020-01-14 11:00:00', pd.np.nan, 217.64],
['2020-01-14 10:00:00', pd.np.nan, 217.60],
['2020-01-14 09:00:00', pd.np.nan, 217.56],
['2020-01-14 08:00:00', pd.np.nan, 217.51],
['2020-01-14 07:00:00', pd.np.nan, 217.45],
['2020-01-14 06:00:00', pd.np.nan, 217.40],
['2020-01-14 05:00:00', pd.np.nan, 217.38],
['2020-01-14 04:00:00', pd.np.nan, 217.39],
['2020-01-14 03:00:00', pd.np.nan, 217.41],
['2020-01-14 02:00:00', pd.np.nan, 217.47],
]
},
]

def test_parser_twdb_fts():
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py27, py34
envlist = py27, py36
[testenv]
sitepackages=False
deps=
Expand Down
20 changes: 16 additions & 4 deletions ulmo/usgs/eddn/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,22 @@ def twdb_fts(df_row, drop_dcp_metadata=True):
message = df_row['dcp_message'].lower()
message_timestamp = df_row['message_timestamp_utc']

lines = message.split(':')[1]
water_levels = [field.strip('+- ') for field in lines.split()[3:]]
df = _twdb_assemble_dataframe(message_timestamp, None, water_levels,
reverse=False)
battery_voltage = pd.np.nan
for line in message.split(':'):
if line.split() != []:
line = line.split()
# grab water level data
if line[0] == 'wl':
water_levels = [
field.strip('+- ') for field in line[3:]
]
# grab battery voltage
if line[0] == 'vb':
battery_voltage = line[3].strip('+- ')

df = _twdb_assemble_dataframe(
message_timestamp, battery_voltage, water_levels, reverse=False
)
return df


Expand Down

0 comments on commit 22cce3e

Please sign in to comment.