Skip to content

Commit

Permalink
more nimbus
Browse files Browse the repository at this point in the history
  • Loading branch information
RondeauG committed Nov 15, 2024
1 parent e7e9853 commit 40f6075
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions tests/test_ensembles.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,12 @@
import xesmf as xe
except ImportError:
xe = None
# temp fix for changes to xclim-testdata
from functools import partial

from xclim.testing import open_dataset
from xclim.testing.helpers import test_timeseries as timeseries
from xclim.testing.utils import nimbus

import xscen as xs

# FIXME: Remove if-else when updating minimum xclim version to 0.53
if Version(xc.__version__) < Version("0.53.0"):
# Hack to revert to old testdata with old xclim
open_dataset = partial(open_dataset, branch="v2023.12.14")


LOGGER = logging.getLogger(__name__)


Expand Down Expand Up @@ -1103,7 +1095,7 @@ def test_build_partition_data(self, samplecat, tmp_path):

class TestReduceEnsemble:
def test_with_criteria(self):
ds = open_dataset("EnsembleReduce/TestEnsReduceCriteria.nc")
ds = xr.open_dataset(nimbus().fetch("EnsembleReduce/TestEnsReduceCriteria.nc"))
selected, clusters, fig_data = xs.reduce_ensemble(
ds["data"], method="kmeans", max_clusters=3
)
Expand All @@ -1122,7 +1114,9 @@ def test_without_criteria(self, horizon):
"CNRM-CM5": "EnsembleStats/BCCAQv2+ANUSPLIN300_CNRM-CM5_historical+rcp45_r1i1p1_1970-2050_tg_mean_YS.nc",
}
for d in datasets:
ds = open_dataset(datasets[d]).isel(lon=slice(0, 4), lat=slice(0, 4))
ds = xr.open_dataset(nimbus().fetch(datasets[d])).isel(
lon=slice(0, 4), lat=slice(0, 4)
)
ds = xs.climatological_op(
ds,
op="mean",
Expand All @@ -1146,7 +1140,7 @@ def test_without_criteria(self, horizon):
assert fig_data == {}

def test_errors(self):
ds = open_dataset("EnsembleReduce/TestEnsReduceCriteria.nc")
ds = xr.open_dataset(nimbus().fetch("EnsembleReduce/TestEnsReduceCriteria.nc"))
with pytest.raises(
ValueError, match="Data must have a 'horizon' dimension to be subsetted."
):
Expand Down

0 comments on commit 40f6075

Please sign in to comment.