diff --git a/aodntools/timeseries_products/hourly_timeseries.py b/aodntools/timeseries_products/hourly_timeseries.py index 66e5292..7f5d7f1 100644 --- a/aodntools/timeseries_products/hourly_timeseries.py +++ b/aodntools/timeseries_products/hourly_timeseries.py @@ -414,6 +414,8 @@ def hourly_aggregator(files_to_aggregate, site_code, qcflags, input_dir='', outp nc_clean['TIME'] = nc_clean.indexes['TIME'].to_datetimeindex() df_temp = nc_clean.to_dataframe() + ## keep TIME as the only index (for ADCP files it would be a MultiIndex at this point) + df_temp = df_temp.reset_index().set_index('TIME') df_temp = df_temp[parameter_names] df_temp = PDresample_by_hour(df_temp, function_dict, function_stats) # do the magic diff --git a/test_aodntools/timeseries_products/test_hourly_timeseries.py b/test_aodntools/timeseries_products/test_hourly_timeseries.py index 07ad35b..bbc1d94 100644 --- a/test_aodntools/timeseries_products/test_hourly_timeseries.py +++ b/test_aodntools/timeseries_products/test_hourly_timeseries.py @@ -117,6 +117,19 @@ def test_hourly_aggregator_with_nonqc(self): for f in chartostring(dataset['source_file'][:]): self.assertIn(f, INPUT_FILES) + def test_with_adcp(self): + # Replace the BAD_FILE with an ADCP file - aggregation should work (only takes TEMP from the ADCP) + input_files = INPUT_FILES[:2] + \ + ['IMOS_ANMN-NRS_AETVZ_20180816T080000Z_NRSROT-ADCP_FV01_NRSROT-ADCP-1808-Sentinel-or-Monitor-Workhorse-ADCP-44_END-20180822T053000Z_C-20200623T000000Z.nc'] + output_file, bad_files = hourly_aggregator(files_to_aggregate=input_files, + site_code='NRSROT', + qcflags=(1, 2), + input_dir=TEST_ROOT, + output_dir='/tmp' + ) + + self.assertEqual(0, len(bad_files)) + def test_all_rejected(self): self.assertRaises(NoInputFilesError, hourly_aggregator, [BAD_FILE], 'NRSROT', (1, 2), input_dir=TEST_ROOT)