Skip to content

Commit d2cda9f

Browse files
committed
make bad_files a dict like in other products
1 parent 76432e4 commit d2cda9f

1 file changed

Lines changed: 6 additions & 9 deletions

File tree

aodntools/timeseries_products/velocity_hourly_timeseries.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def velocity_hourly_aggregated(files_to_agg, site_code, input_dir='', output_dir
9696
:param output_dir: path where the result file will be written
9797
:param download_url_prefix: URL prefix for file download (to be prepended to paths in files_to_agg)
9898
:param opendap_url_prefix: URL prefix for OPENAP access (to be prepended to paths in files_to_agg)
99-
:return: file path of the aggregated product, list of rejected files
99+
:return: file path of the hourly aggregated product, dict of rejected files: errors
100100
"""
101101

102102
varlist = ['UCUR', 'VCUR', 'WCUR', 'DEPTH']
@@ -107,8 +107,7 @@ def velocity_hourly_aggregated(files_to_agg, site_code, input_dir='', output_dir
107107
epoch = np.datetime64("1950-01-01T00:00:00")
108108
one_day = np.timedelta64(1, 'D')
109109

110-
bad_files = []
111-
rejected_files = []
110+
bad_files = {}
112111

113112
chunk_size = 90 ## size in days
114113

@@ -122,14 +121,12 @@ def velocity_hourly_aggregated(files_to_agg, site_code, input_dir='', output_dir
122121
with xr.open_dataset(os.path.join(input_dir, file)) as nc:
123122
error_list = check_file(nc, site_code)
124123
if error_list:
125-
bad_files.append([file, error_list])
126-
rejected_files.append(file)
124+
bad_files.update({file: error_list})
127125
print(" ")
128126

129-
130127
## remove bad files form the list
131-
for file in bad_files:
132-
files_to_agg.remove(file[0])
128+
for file in bad_files.keys():
129+
files_to_agg.remove(file)
133130

134131
## sort the files in chronological order
135132
files_to_agg = utils.sort_files(files_to_agg, input_dir=input_dir)
@@ -296,7 +293,7 @@ def velocity_hourly_aggregated(files_to_agg, site_code, input_dir='', output_dir
296293
'date_created': datetime.utcnow().strftime(timeformat),
297294
'history': datetime.utcnow().strftime(timeformat) + ': Aggregated file created.',
298295
'keywords': ', '.join(varlist + ['AGGREGATED']),
299-
'rejected_files': "\n".join(rejected_files),
296+
'rejected_files': "\n".join(bad_files.keys()),
300297
'contributor_name': "; ".join(contributor_name),
301298
'contributor_email': "; ".join(contributor_email),
302299
'contributor_role': "; ".join(contributor_role),

0 commit comments

Comments
 (0)