ROMS output. Best technique to interpolate in the vertical

Cool Findings and Plots

Moderators: arango, robertson

Post Reply
Message
Author
crojas
Posts: 8
Joined: Mon Mar 07, 2022 9:53 pm
Location: Universidad del BioBio

ROMS output. Best technique to interpolate in the vertical

#1 Unread post by crojas »

Hi.

I'm working with an output from a ROMS model. I have the sigma levels (32) and some physical magnitudes as temperature and salinity. I have already converted sigma levels to depth.
I'm trying to interpolate the data in the vertical to a finer grid. I have the data order as (vertical_data,longitude_location) and I'm using a linear interpolation over one column at the time. However, the result is not good since the gradient of the field it's modified by my method. I have attached a image to show what I mean. So my question is, is there any "recommended" technique to interpolate in the vertical?

Thanks in advance.
Attachments
pden.png
pden.png (56.07 KiB) Viewed 16868 times

jcwarner
Posts: 1200
Joined: Wed Dec 31, 2003 6:16 pm
Location: USGS, USA

Re: ROMS output. Best technique to interpolate in the vertical

#2 Unread post by jcwarner »

" linear interpolation over one column at the time" - that is probably not a good idea.
try a 2D interpolation scheme. Are you using matlab?
help scatteredInterpolant
F = scatteredInterpolant(x_rho,z_rho,salt);
saltnew= F(xnew,znew);

crojas
Posts: 8
Joined: Mon Mar 07, 2022 9:53 pm
Location: Universidad del BioBio

Re: ROMS output. Best technique to interpolate in the vertical

#3 Unread post by crojas »

Thanks for your answer.
Indeed, I'm using Matlab. I should have said that I already tried with scatteredInterpolant but I didn't know how to use it in this case. When I try to use it, I got an error:

Code: Select all

 
F = scatteredInterpolant(x_rho,z_rho,salt);
Error using scatteredInterpolant
The input points must be specified in column-vector format.
 
The variable x_rho is longitude so this is already in column-vector format. However, z_rho is not, since the points change according to the position of the longitude. Then I thought, "well, let's use it as a column-vector at the time" but this is no longer 2D interpolation scheme. So I ended up with the linear interpolation by column. Any ideas?

jcwarner
Posts: 1200
Joined: Wed Dec 31, 2003 6:16 pm
Location: USGS, USA

Re: ROMS output. Best technique to interpolate in the vertical

#4 Unread post by jcwarner »

it just wants you to enter the data as a column.
lets say this is a 2D field in x and z.
lets also say that you have 10 vertical layers and we are looking at the y index of 35 (just picking any number here).
N=10;
yidx=35;

X=repmat(lon_rho(:,yidx),N);
Z=z_rho(:,yidx,:);
S=squeeze(salt(:,yidx,:,tidx));
F = scatteredInterpolant(X(:),Z(:),S(:));

crojas
Posts: 8
Joined: Mon Mar 07, 2022 9:53 pm
Location: Universidad del BioBio

Re: ROMS output. Best technique to interpolate in the vertical

#5 Unread post by crojas »

I had a hard time understanding your answer. But now I get it, thanks for your help!!!!
However, the results are not looking so good.
Looking information about scatteredinterpolant, I find the spline interpolation. And apparently, the results are better than any other methods I have tried so far. Still, I notice that both interpolation's method doesn't reach the right edge (See the longitude -72.2). Is this normal?

Thanks in advance.
Attachments
figura4_24_29.png

jcwarner
Posts: 1200
Joined: Wed Dec 31, 2003 6:16 pm
Location: USGS, USA

Re: ROMS output. Best technique to interpolate in the vertical

#6 Unread post by jcwarner »

looking better.
there are 'extrapolation' options, which need to be used with caution.
but give that a try.
maybe someone else has a better idea.

crojas
Posts: 8
Joined: Mon Mar 07, 2022 9:53 pm
Location: Universidad del BioBio

Re: ROMS output. Best technique to interpolate in the vertical

#7 Unread post by crojas »

I'll keep looking. But for now, I have a better interpolation than before. If I find a way to extrapolate in a nice way, I'll post it here.
So much thanks you for your help.

crojas
Posts: 8
Joined: Mon Mar 07, 2022 9:53 pm
Location: Universidad del BioBio

Re: ROMS output. Best technique to interpolate in the vertical

#8 Unread post by crojas »

So the problem with the right edge was not due to interpolation problem but a wrong definition on the finer grid I make.
Thanks John!
Attachments
pden2.png

rduran
Posts: 152
Joined: Fri Jan 08, 2010 7:22 pm
Location: Theiss Research

Re: ROMS output. Best technique to interpolate in the vertical

#9 Unread post by rduran »

Also, if you are concerned with the representation of the gradient, linear interpolation is C^0 (derivatives are discontinuous at cell edges), and using higher-order interpolation can introduce spurious results such as "unrealistic water masses". I am not an expert in the vertical interpolation of density, but I know people have worked on this. You might want to read this paper https://doi.org/10.1175/JTECH-D-19-0211.1
Matlab code for their interpolation is available at: https://www.teos-10.org/

Post Reply