Skip to content

Commit

Permalink
Handle ValueError in get_onc_ctd salinity resampling
Browse files Browse the repository at this point in the history
xarray version 2023.05.0 introduced a ValueError exception raised when a
DataArray being resampled is empty. We previously handled that condition by
catching an IndexError. Now we catch ValueError too.

The change to ValueError for an empty salinity DataArray didn't show up in
production until the 14jun24 update of the production environment brought xarray
version 2024.06.0 into use.
  • Loading branch information
douglatornell committed Jun 20, 2024
1 parent 77d10c8 commit 2a3b6c8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion nowcast/workers/get_onc_ctd.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def count(values, axis):
salinity_mean = salinity.resample(time="15Min").mean()
salinity_std_dev = salinity.resample(time="15Min").std()
salinity_sample_count = salinity.resample(time="15Min").count()
except IndexError:
except (IndexError, ValueError):

Check warning on line 179 in nowcast/workers/get_onc_ctd.py

View check run for this annotation

Codecov / codecov/patch

nowcast/workers/get_onc_ctd.py#L179

Added line #L179 was not covered by tests
logger.warning(f"no {onc_station} salinity data")
salinity_mean = temperature_mean.copy()
salinity_mean.name = "salinity"
Expand Down

0 comments on commit 2a3b6c8

Please sign in to comment.