Skip to content

Commit 628f216

Browse files
Merge pull request #160 from aodn/fix_multiindex
Fix MultiIndex issue in hourly_timeseries
2 parents c4f31cb + a93e478 commit 628f216

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

aodntools/timeseries_products/hourly_timeseries.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,8 @@ def hourly_aggregator(files_to_aggregate, site_code, qcflags, input_dir='', outp
414414
nc_clean['TIME'] = nc_clean.indexes['TIME'].to_datetimeindex()
415415
df_temp = nc_clean.to_dataframe()
416416

417+
## keep TIME as the only index (for ADCP files it would be a MultiIndex at this point)
418+
df_temp = df_temp.reset_index().set_index('TIME')
417419
df_temp = df_temp[parameter_names]
418420

419421
df_temp = PDresample_by_hour(df_temp, function_dict, function_stats) # do the magic

test_aodntools/timeseries_products/test_hourly_timeseries.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,19 @@ def test_hourly_aggregator_with_nonqc(self):
117117
for f in chartostring(dataset['source_file'][:]):
118118
self.assertIn(f, INPUT_FILES)
119119

120+
def test_with_adcp(self):
121+
# Replace the BAD_FILE with an ADCP file - aggregation should work (only takes TEMP from the ADCP)
122+
input_files = INPUT_FILES[:2] + \
123+
['IMOS_ANMN-NRS_AETVZ_20180816T080000Z_NRSROT-ADCP_FV01_NRSROT-ADCP-1808-Sentinel-or-Monitor-Workhorse-ADCP-44_END-20180822T053000Z_C-20200623T000000Z.nc']
124+
output_file, bad_files = hourly_aggregator(files_to_aggregate=input_files,
125+
site_code='NRSROT',
126+
qcflags=(1, 2),
127+
input_dir=TEST_ROOT,
128+
output_dir='/tmp'
129+
)
130+
131+
self.assertEqual(0, len(bad_files))
132+
120133
def test_all_rejected(self):
121134
self.assertRaises(NoInputFilesError, hourly_aggregator, [BAD_FILE], 'NRSROT', (1, 2), input_dir=TEST_ROOT)
122135

0 commit comments

Comments
 (0)