[MITgcm-support] Ignoring NaNs during interpolation

Martin Losch Martin.Losch at awi.de
Wed Mar 20 06:54:59 EDT 2024


Hi Joan,

did you get an answer for this question?

It’s clearly an xmitgcm/xgcm question and should be posted on their respective pages, I guess that’s why no-one has replied so far.

I just played with the xgcm.Grid.interp yesterday and my conclusion is that “fill_value” determines what you have after interpolation (in your example you chose np.nan), also the value of “boundary” should be choosen carefully (maybe try ‘extend'). Obviously this is not an expert opinion (I really struggle with xArray and xgcm).

Martin

> On 1. Feb 2024, at 23:26, Joan M. Bonilla Pagan <jbonil11 at jhu.edu> wrote:
> 
> Hello,
> 
> Hope this one works.
> 
> My name is Joan, I am a current student who is using MITgcm models. I am trying to edit an interpolation scheme that is taking variables located in the edges and sides of the grid cells and interpolating them to the center of the grid using a structure like the one below:
> grid.interp(
>                  ds[var],
>                  axis=dim[0],
>                  to="center",
>                  boundary="fill",
>                  fill_value=_np.nan,
>              )
> Where ds is an xarray.Dataset that contains the output of the model. Currently, if one of the corners or sides of the grid is a NaN then the interpolated values at the center will be a NaN. Is there a way to change that? I would like to make is so that the interpolation ignores NaNs for cells that have at least one value. Is this possible? I was thinking I could mask the coast afterwards.
> 
> Very respectfully,
> Joan M.
>  
> _______________________________________________
> MITgcm-support mailing list
> MITgcm-support at mitgcm.org <mailto:MITgcm-support at mitgcm.org>
> http://mailman.mitgcm.org/mailman/listinfo/mitgcm-support

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.mitgcm.org/pipermail/mitgcm-support/attachments/20240320/8f6c09aa/attachment.html>


More information about the MITgcm-support mailing list