From 7013704f6b05e19fb3038541aefe88d439671681 Mon Sep 17 00:00:00 2001 From: David Hoese <david.hoese@ssec.wisc.edu> Date: Thu, 11 Jun 2020 10:32:39 -0500 Subject: [PATCH] Fix accumulated precipitation using wrong units Data comes from instrument in inches but was being used as millimeters --- aosstower/level_b1/nc.py | 5 +++++ aosstower/schema.py | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/aosstower/level_b1/nc.py b/aosstower/level_b1/nc.py index e170050..949b258 100644 --- a/aosstower/level_b1/nc.py +++ b/aosstower/level_b1/nc.py @@ -39,6 +39,11 @@ def get_data(input_files): frame = pd.DataFrame(_get_data(input_files)) frame = frame.set_index('stamp') frame = frame.mask(frame == -99999.).fillna(value=np.nan) + + for col_name in frame.columns: + if col_name in schema.unit_conversions: + conv_func = schema.unit_conversions[col_name] + frame[col_name] = conv_func(frame[col_name]) return frame diff --git a/aosstower/schema.py b/aosstower/schema.py index f03f7c0..afb060f 100644 --- a/aosstower/schema.py +++ b/aosstower/schema.py @@ -241,7 +241,7 @@ database = dict( 'accumulated_precipitation', 'accum_precip', 'Precipitation accumulated since 0Z', - 'mm', + 'mm', # data comes from instrument as inches but we typically want millimeters '0', '254', None, @@ -273,3 +273,6 @@ database_dict = {k: v._asdict() for k, v in database.items()} met_vars = {'air_temp', 'dewpoint', 'rh', 'solar_flux', 'pressure', 'precip', 'accum_precip', 'wind_speed', 'wind_dir', 'gust'} engr_vars = set(database.keys()) - met_vars + +unit_conversions = {} +unit_conversions['accum_precip'] = lambda x: x * 25.4 -- GitLab