Skip to content

Commit

Permalink
Silence Iris warnings in area_statistics preprocessor function (#…
Browse files Browse the repository at this point in the history
…2625)

Co-authored-by: Valeriu Predoi <valeriu.predoi@gmail.com>
  • Loading branch information
bouweandela and valeriupredoi authored Jan 16, 2025
1 parent 3c6977e commit de514e4
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion esmvalcore/preprocessor/_area.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from __future__ import annotations

import logging
import warnings
from pathlib import Path
from typing import TYPE_CHECKING, Iterable, Literal, Optional

Expand Down Expand Up @@ -354,7 +355,16 @@ def area_statistics(
agg, agg_kwargs, "cell_area", cube, try_adding_calculated_cell_area
)

result = cube.collapsed(["latitude", "longitude"], agg, **agg_kwargs)
with warnings.catch_warnings():
# Silence various warnings about collapsing multi-dimensional and/or
# non contiguous coordinates as this should be fine when the cell areas
# are provided and will fail when they needed but not provided.
warnings.filterwarnings(
"ignore",
category=iris.warnings.IrisVagueMetadataWarning,
module="iris",
)
result = cube.collapsed(["latitude", "longitude"], agg, **agg_kwargs)
if normalize is not None:
result = get_normalized_cube(cube, result, normalize)

Expand Down

0 comments on commit de514e4

Please sign in to comment.