Skip to content

Commit 5041611

Browse files
committed
update velocity_hourly to properly handle missing WCUR
1 parent 7bbbbe3 commit 5041611

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

aodntools/timeseries_products/velocity_hourly_timeseries.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,10 @@ def velocity_hourly_aggregated(files_to_agg, site_code, input_dir='', output_dir
185185
with xr.open_dataset(os.path.join(input_dir, file)) as nc:
186186

187187
is_2D = 'HEIGHT_ABOVE_SENSOR' in list(nc.variables)
188+
varlist_nc = [v for v in varlist if v in nc.variables.keys()]
188189

189190
## mask values with QC flag>2
190-
for var in varlist:
191+
for var in varlist_nc:
191192
nc[var] = nc[var].where(nc[var+'_quality_control'] <= QC_FLAG_MAX)
192193

193194
## process in chunks
@@ -209,12 +210,12 @@ def velocity_hourly_aggregated(files_to_agg, site_code, input_dir='', output_dir
209210
nc_cell = nc_chunk.sel(HEIGHT_ABOVE_SENSOR=cell_height)
210211
## convert to absolute DEPTH
211212
nc_cell['DEPTH'] = nc_cell['DEPTH'] - cell_height
212-
slice_end = append_resampled_values(nc_cell[varlist], ds, slice_start, binning_fun)
213+
slice_end = append_resampled_values(nc_cell[varlist_nc], ds, slice_start, binning_fun)
213214
CELL_INDEX[slice_start:slice_end] = np.full(slice_end - slice_start, cell_idx, dtype=np.uint32)
214215

215216
slice_start = slice_end
216217
else:
217-
slice_end = append_resampled_values(nc_chunk[varlist], ds, slice_start, binning_fun)
218+
slice_end = append_resampled_values(nc_chunk[varlist_nc], ds, slice_start, binning_fun)
218219
CELL_INDEX[slice_start:slice_end] = np.full(slice_end - slice_start, 0, dtype=np.uint32)
219220

220221
slice_start = slice_end

0 commit comments

Comments
 (0)