# Regridding from MOM6 native coordinates

**URL:** <https://forum.access-hive.org.au/t/regridding-from-mom6-native-coordinates/5862>\
**Category:** Biogeochemistry\
**Tags:** python, help, mom6, regrid\
**Created:** [4 February 2026 06:01 UTC](https://forum.access-hive.org.au/t/regridding-from-mom6-native-coordinates/5862 "2026-02-04T06:01:50Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lizzie](https://avatars.discourse-cdn.com/v4/letter/l/da6949/32.png) [@Lizzie](https://forum.access-hive.org.au/u/Lizzie)\
**Post date:** [4 February 2026 06:01 UTC](https://forum.access-hive.org.au/t/regridding-from-mom6-native-coordinates/5862/1 "2026-02-04T06:01:50Z")

</div>

At the moment, output from MOM6 returns BGC variables on the z\* grid which I understand varies in time, given by e or h. Is there a neat way to regrid the BGC data onto a fixed grid and then interp it onto the same vertical grid as the physical data which is output on the z grid?

I was trying something like this but it doesn’t work!

```auto
import xarray as xr

import xgcm

from xgcm import transform

# bgc data 

ds = bgc3d_m_05_tides

# Cell interface depth to cell centre depth

grid = Grid(phy_m_05_tides, coords={'Z': {'center': 'z_l', 'left': 'z_i'}},autoparse_metadata=False)

z= grid.interp(phy_m_05_tides.e, 'Z', boundary='fill', fill_value=None)

# add the depth field to the ds

ds= ds.assign_coords(z=z)

# this is the target depth I want to eventually put the BGC data onto 

z_fixed = phy_m_05_tides.z_l

# this is where I get stuck!?

ds=ds.interp(z=zl,kwargs={"fill_value": "extrapolate"})

#check to see if it now plots as a nice cross section. (At the moment it doesn’t!)

ds.no3.isel(time=1).isel(xh=100).plot(vmin=0,vmax=2.5e-5)

```

Thank you

---

<div class="post-metadata">

**Author:** ![dougiesquire](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.access-hive.org.au/dougiesquire/32/16_2.png) [@dougiesquire](https://forum.access-hive.org.au/u/dougiesquire)\
**Post date:** [4 February 2026 10:23 UTC](https://forum.access-hive.org.au/t/regridding-from-mom6-native-coordinates/5862/2 "2026-02-04T10:23:48Z")

</div>

Hi @Lizzie. This is how I’d usually do this:

```python
def interfaces_to_centres(da_zi):
    """
    Average interface quantities to get centre quantities
    """
    zl = (da_zi.zi.values[:-1] + da_zi.zi.values[1:]) / 2
    da_zi = da_zi.rename(zi="zl")
    lowers = da_zi.isel(zl=slice(1,None)).assign_coords({"zl": zl})
    uppers = da_zi.isel(zl=slice(None,-1)).assign_coords({"zl": zl})
    da_zl = (lowers + uppers) / 2
    da_zl.zl.attrs["axis"] = "Z"
    return da_zl

# Average e at interfaces onto cell centres; flip sign so depths are positive
e_zl = -1 * interfaces_to_centres(phy_m_05_tides.e)

# Get target depths
z_fixed = phy_m_05_tides.z_l.values

# Interpolate no3 onto target levels
grid = Grid(ds, periodic=False)
no3_z = grid.transform(
    ds.no3,
    'Z',
    z_fixed,
    target_data=e_zl,
    method='linear',
    mask_edges=True
)

```

I’ve tried to write this to use your variable names etc so that you can just drop into your code. Apologies in advance if it doesn’t work first go.

---

<div class="post-metadata">

**Author:** ![dougiesquire](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.access-hive.org.au/dougiesquire/32/16_2.png) [@dougiesquire](https://forum.access-hive.org.au/u/dougiesquire)\
**Post date:** [4 February 2026 10:27 UTC](https://forum.access-hive.org.au/t/regridding-from-mom6-native-coordinates/5862/3 "2026-02-04T10:27:29Z")

</div>



---

<div class="post-metadata">

**Author:** ![dougiesquire](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.access-hive.org.au/dougiesquire/32/16_2.png) [@dougiesquire](https://forum.access-hive.org.au/u/dougiesquire)\
**Post date:** [4 February 2026 21:51 UTC](https://forum.access-hive.org.au/t/regridding-from-mom6-native-coordinates/5862/4 "2026-02-04T21:51:21Z")

</div>

@Lizzie, I hope you don’t mind, I changed the title slightly and added a few more tags to hopefully make this post a little more findable.

---

<div class="post-metadata">

**Author:** ![dougiesquire](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.access-hive.org.au/dougiesquire/32/16_2.png) [@dougiesquire](https://forum.access-hive.org.au/u/dougiesquire)\
**Post date:** [6 February 2026 19:14 UTC](https://forum.access-hive.org.au/t/regridding-from-mom6-native-coordinates/5862/5 "2026-02-06T19:14:36Z")

</div>



---

<div class="post-metadata">

**Author:** ![dougiesquire](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.access-hive.org.au/dougiesquire/32/16_2.png) [@dougiesquire](https://forum.access-hive.org.au/u/dougiesquire)\
**Post date:** [6 February 2026 19:14 UTC](https://forum.access-hive.org.au/t/regridding-from-mom6-native-coordinates/5862/6 "2026-02-06T19:14:41Z")

</div>


