Skip to content

Commit 7bbbbe3

Browse files
committed
fix NaN variable values in the remaining products (fixes #118)
1 parent c669d38 commit 7bbbbe3

7 files changed

Lines changed: 13 additions & 12 deletions

aodntools/timeseries_products/velocity_aggregated_timeseries.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ def velocity_aggregated(files_to_agg, site_code, input_dir='', output_dir='./',
144144
WCUR[start:end] = flat_variable(nc, 'WCUR')
145145
WCURqc[start:end] = flat_variable(nc, 'WCUR_quality_control')
146146
else:
147-
WCUR[start:end] = np.full(n_obs, np.nan)
147+
WCUR[start:end] = np.ma.masked
148148
WCURqc[start:end] = np.full(n_obs, 9)
149149

150150
##calculate depth and add CELL_INDEX

aodntools/timeseries_products/velocity_hourly_timeseries.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,15 @@ def cell_velocity_resample(df, binning_function):
3232
:return: binned U, v, W CUR according to the binning function
3333
"""
3434
df_binned = df.apply(binning_function)
35-
UCUR = np.array(df_binned['UCUR'])
36-
VCUR = np.array(df_binned['VCUR'])
37-
if 'WCUR' in df_binned:
38-
WCUR = np.array(df_binned['WCUR'])
39-
else:
40-
WCUR = np.full(len(df), np.nan)
41-
DEPTH = np.array(df_binned['DEPTH'])
42-
43-
return UCUR, VCUR, WCUR, DEPTH
44-
35+
binned_vars = []
36+
for var in ('UCUR', 'VCUR', 'WCUR', 'DEPTH'):
37+
if var in df_binned:
38+
x = np.ma.masked_array(df_binned[var], mask=np.isnan(df_binned[var]))
39+
else:
40+
x = np.ma.masked
41+
binned_vars.append(x)
42+
43+
return tuple(binned_vars)
4544

4645
def append_resampled_values(nc_cell, ds, slice_start, binning_functions):
4746
"""

test_aodntools/timeseries_products/IMOS_ANMN-NRS_VZ_20180816_NRSROT_FV02_velocity-hourly-timeseries_END-20191018_C-20220502.nc renamed to test_aodntools/timeseries_products/IMOS_ANMN-NRS_VZ_20180816_NRSROT_FV02_velocity-hourly-timeseries_END-20191018_C-20220608.nc

233 KB
Binary file not shown.

test_aodntools/timeseries_products/test_hourly_timeseries.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ def test_some_files_without_good_data(self):
141141
for path, errors in bad_files.items():
142142
self.assertEqual(NO_INWATER_DATA_FILE, path)
143143
self.assertIn('no in-water data', errors)
144+
with Dataset(output_file) as dataset:
145+
self.check_nan_values(dataset)
144146

145147
def test_bad_timestamps(self):
146148
output_file, bad_files = hourly_aggregator(files_to_aggregate=SYD100_FILES,

test_aodntools/timeseries_products/test_velocity_hourly_timeseries.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
class TestVelocityHourlyTimeseries(BaseTestCase):
3333
EXPECTED_OUTPUT_FILE = os.path.join(
34-
TEST_ROOT, 'IMOS_ANMN-NRS_VZ_20180816_NRSROT_FV02_velocity-hourly-timeseries_END-20191018_C-20220502.nc'
34+
TEST_ROOT, 'IMOS_ANMN-NRS_VZ_20180816_NRSROT_FV02_velocity-hourly-timeseries_END-20191018_C-20220608.nc'
3535
)
3636

3737
def test_velocity_hourly(self):

0 commit comments

Comments
 (0)