# FAQ

# How does spatial interpolation work in Ichthyop?

A particle in Ichthyop only knows about its environment what is provided by the outputs of the hydrodynamic model. Such information, for instance the zonal and meridional current velocities, are usually provided on an Arakawa C-grid, every U-point and V-point respectively.

Here is the 2D scheme of cells (i, j) bottom left, (i+1, j) bottom right, (i, j+1) top left and (i+1, j+1) top right.

Particle current location at *X(x, y, z)

Let's see how the interpolation works for both zonal and meridional velocities. The question we ask is what is the value of U and V at particle location?

We have i=round(x), j=truncate(y) and k=truncate(z), dx=x-i, dy=y-j, dz=z-k

Let's call t, the current time of the simulation, and t0 and t1 the values of the time NetCDF variable bounding t: t0 <= t < t1

We first interpolate the model velocity field at t0:

This large expression can be narrowed down to:

*U(t0, x, y, z) = SUM( U(t0, i+ii-1, j+jj, k+kk) * |(0.5-ii-dx) * (1-jj-dy) * (1-kk-dz)| , ii in [0,1], jj in [0,1], kk in [0,1] )*

with i=round(x), j=truncate(y), k=truncate(z), dx=x-i, dy=y-j, dz=z-k

Similarly, the meridional velocity can be expressed as:

*V(t0, x, y, z) = SUM( U(t0, i+ii, j+jj-1, k+kk) * |(1-ii-dx) * (0.5-jj-dy) * (1-kk-dz)| , ii in [0:1], jj in [0:1], kk in [0:1] )*

with i=truncate(x), j=round(y), k=truncate(z), dx=x-i, dy=y-j, dz=z-k

It means that the velocity, either zonal or meridional, at particle location is the result of a trilinear interpolation of the height (four above, four below) surrounding velocities in the grid.

Same with U(t1, x, y, z) and V(t1, x, y, z)

Let's take frac = (t - t0) / (t1 - t0). Then we have

*U(t, x, y, z) = (1 - frac) * U(t0, x, y, z) + frac * U(t1, x, y, z)*

*V(t, x, y, z) = (1 - frac) * V(t0, x, y, z) + frac * V(t1, x, y, z)*

This is the general case when all the surrounding cells are in water. Now what happened if the particle is in a cell adjacent to the coast? Let's say that in our example cell(i+1,j) and cell(i+1, j+1) are land. Basically the interpolation is limited to the four (two above and two below) closest surrounding velocity points:

*U(t0, x, y, z) = SUM( U(t0, i+ii-1, j, k+kk) * |(0.5-ii-dx) * (1-dy) * (1-kk-dz)| , ii in [0,1], kk in [0,1] )*

*V(t0, x, y, z) = SUM( U(t0, i, j+jj-1, k+kk) * |(1-dx) * (0.5-jj-dy) * (1-kk-dz)| , jj in [0:1], kk in [0:1] )*

In order to determine whether a particle is close to the coastline, Ichthyop proceeds in two steps: it first determines in which quater of the cell the grid point is located. Then it checks wether or not the three adjacent cells to this quater are in water.

X1 will be considered as "close to coast" if any of cells (i,j+1) (i-1,j) (i-1,j+1) is on land.

X2 will be considered as "close to coast" if any of cells (i,j+1) (i+1,j) (i+1,j+1) is on land.

X3 will be considered as "close to coast" if any of cells (i,j-1) (i+1,j) (i+1,j-1) is on land.

X4 will be considered as "close to coast" if any of cells (i,j-1) (i-1,j) (i-1,j-1) is on land.