Skip to content

Commit

Permalink
Fixes missmatched coordinate names
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonb5 committed Dec 7, 2023
1 parent d5d7f49 commit a2eb927
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions xcdat/regridder/regrid2.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,15 +177,25 @@ def _build_dataset(
"X": dst_lon_bnds,
}

dims = list(input_data_var.dims)

for cf_axis_name, dim_names in input_data_var.cf.axes.items():
dim_name = dim_names[0]

if cf_axis_name in ("X", "Y"):
output_grid_dim_name = output_grid.cf.axes[cf_axis_name][0]

output_coords[dim_name] = output_grid[output_grid_dim_name].copy()
output_coords[output_grid_dim_name] = output_grid[
output_grid_dim_name
].copy()

for i, x in enumerate(dims):
if x == dim_name:
dims[i] = output_grid_dim_name

break

bnds_name = f"{dim_name}_bnds"
bnds_name = f"{output_grid_dim_name}_bnds"

output_data_vars[bnds_name] = xr.DataArray(
output_bnds[cf_axis_name].copy(),
Expand All @@ -202,7 +212,7 @@ def _build_dataset(

output_da = xr.DataArray(
output_data,
dims=input_data_var.dims,
dims=dims,
coords=output_coords,
attrs=ds[data_var].attrs.copy(),
name=data_var,
Expand Down

0 comments on commit a2eb927

Please sign in to comment.