Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spherical padding and faster tests #45

Merged
merged 8 commits into from
Sep 20, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions tests/test_regrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,22 @@
@pytest.fixture(scope="session")
def sample_input_data() -> xr.Dataset:
ds = xr.open_dataset(DATA_PATH / "era5_2m_dewpoint_temperature_2000_monthly.nc")
return ds.isel(time=slice(0, N_TIMESTAMPS)).persist()
# slice after compute due to current xarray bug: https://github.com/pydata/xarray/issues/8909
# then convert to dask so regridding is lazy on attribute tests
return ds.compute().isel(time=slice(0, N_TIMESTAMPS)).chunk()
slevang marked this conversation as resolved.
Show resolved Hide resolved


@pytest.fixture(scope="session")
def conservative_input_data() -> xr.Dataset:
ds = xr.open_dataset(DATA_PATH / "era5_total_precipitation_2020_monthly.nc")
return ds.isel(time=slice(0, N_TIMESTAMPS)).persist()
return ds.compute().isel(time=slice(0, N_TIMESTAMPS)).chunk()


@pytest.fixture(scope="session")
def cdo_comparison_data() -> dict[str, xr.Dataset]:
data = {}
for method, path in CDO_FILES.items():
data[method] = xr.open_dataset(path).isel(time=slice(0, N_TIMESTAMPS)).persist()
data[method] = xr.open_dataset(path).compute().isel(time=slice(0, N_TIMESTAMPS))
return data


Expand Down Expand Up @@ -203,7 +205,7 @@ def test_conservative_nan_thresholds_against_coarsen(nan_threshold):

@pytest.mark.skipif(xesmf is None, reason="xesmf required")
def test_conservative_nan_thresholds_against_xesmf():
ds = xr.tutorial.open_dataset("ersstv5").sst.isel(time=[0]).persist()
ds = xr.tutorial.open_dataset("ersstv5").sst.compute().isel(time=[0])
slevang marked this conversation as resolved.
Show resolved Hide resolved
ds = ds.rename(lon="longitude", lat="latitude")
new_grid = xarray_regrid.Grid(
north=90,
Expand Down
Loading