Skip to content

Commit 2d3e43e

Browse files
committed
style(tensorstore): Use different method for calculating means
1 parent a8558c2 commit 2d3e43e

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

src/nwp_consumer/internal/entities/tensorstore.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -350,16 +350,12 @@ def _calc_null_percentage(data: np.typing.NDArray[np.float32]) -> float:
350350
f"Got: {store_da.dims}.",
351351
))
352352

353-
result = xr.apply_ufunc(
354-
_calc_null_percentage,
355-
store_da,
356-
input_core_dims=[spatial_dims],
357-
vectorize=True,
358-
dask="parallelized",
359-
)
353+
nan_percentage_per_step: xr.DataArray = store_da.isnull().mean(
354+
dim=spatial_dims,
355+
).mean("step")
360356

361-
failed_image_count: int = (result > nans_in_image_threshold).sum().values
362-
total_image_count: int = result.size
357+
failed_image_count: int = (nan_percentage_per_step > nans_in_image_threshold).sum().values
358+
total_image_count: int = nan_percentage_per_step.size
363359
failed_image_percentage: float = failed_image_count / total_image_count
364360
if failed_image_percentage > images_failing_nan_check_threshold:
365361
log.warning(

0 commit comments

Comments
 (0)