Skip to content

Commit c629db2

Browse files
committed
Fix regridding
1 parent ec10a24 commit c629db2

2 files changed

Lines changed: 34 additions & 3 deletions

File tree

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ matplotlib = ">=3.10.3,<4"
2323
scipy = ">=1.16.0,<2"
2424
xarray = ">=2025.7.1,<2026"
2525
typer = ">=0.16.0,<0.17"
26-
xcdat = ">=0.9.1,<0.10"
2726
xesmf = ">=0.8.10,<0.9"
2827

2928
[tool.pixi.pypi-dependencies]

src/ref_sample_data/resample.py

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import numpy as np
22
import xarray as xr
3-
import xcdat
43
import xesmf
54

65

@@ -44,7 +43,40 @@ def decimate_rectilinear(dataset: xr.Dataset) -> xr.Dataset:
4443
"""
4544
# Decimate the dataset, but update the bounds
4645
# 10x10 degree grid
47-
output_grid = xcdat.create_uniform_grid(-90, 90, 10, 0, 359, 10)
46+
grid_size = 10 # degrees
47+
nlat = int(180 / grid_size) + 1
48+
nlon = int(360 / grid_size)
49+
output_grid = xr.Dataset.from_dict(
50+
{
51+
"attrs": {},
52+
"coords": {
53+
"lat": {
54+
"attrs": {
55+
"axis": "Y",
56+
"coordinate": "latitude",
57+
"units": "degrees_north",
58+
},
59+
"data": np.linspace(-90, 90, nlat, endpoint=True),
60+
"dims": ("lat",),
61+
},
62+
"lon": {
63+
"attrs": {
64+
"axis": "X",
65+
"coordinate": "longitude",
66+
"units": "degrees_east",
67+
},
68+
"data": np.linspace(0, 360, nlon, endpoint=False),
69+
"dims": ("lon",),
70+
},
71+
},
72+
"data_vars": {},
73+
"dims": {
74+
"lat": nlat,
75+
"lon": nlon,
76+
},
77+
}
78+
)
79+
4880
regrid = xesmf.Regridder(dataset, output_grid, "bilinear", periodic=True)
4981
result = regrid(dataset.copy())
5082
result = result.bounds.add_bounds("Y").bounds.add_bounds("X")

0 commit comments

Comments
 (0)