Skip to content

Commit

Permalink
Handle ValueError in get_onc_ctd salinity resampling (#278)
Browse files Browse the repository at this point in the history
* Handle ValueError in get_onc_ctd salinity resampling

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.

* Correct spelling errors in get_onc_ctd logging msgs

A couple of typos were found in the logging messages in the get_onc_ctd worker.
Specifically, the word "exclude" was mistyped as "exlude". This has now been
corrected.
  • Loading branch information
douglatornell authored Jun 20, 2024
1 parent f191688 commit d9f5fbf
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions nowcast/workers/get_onc_ctd.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,12 @@ def get_onc_ctd(parsed_args, config, *args):
)
logger.debug(
f"filtering ONC {parsed_args.onc_station} temperature data for {ymd} "
f"to exlude qaqcFlag!=1"
f"to exclude qaqcFlag!=1"
)
temperature = _qaqc_filter(ctd_data, "temperature")
logger.debug(
f"filtering ONC {parsed_args.onc_station} salinity data for {ymd} "
f"to exlude qaqcFlag!=1"
f"to exclude qaqcFlag!=1"
)
salinity = _qaqc_filter(ctd_data, "salinity")
logger.debug(f"creating ONC {parsed_args.onc_station} CTD T&S dataset for {ymd}")
Expand Down 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):
logger.warning(f"no {onc_station} salinity data")
salinity_mean = temperature_mean.copy()
salinity_mean.name = "salinity"
Expand Down

0 comments on commit d9f5fbf

Please sign in to comment.