<p>I have been using the routines in <a href="https://github.com/nctoolbox/nctoolbox" rel="nofollow noreferrer">nctoolbox</a> (also check <a href="http://nctoolbox.github.io/nctoolbox/" rel="nofollow noreferrer">here</a>) that do all the slicing (vertical, horizontal, following a track).
The repository is in <a href="https://github.com/nctoolbox/nctoolbox/tree/master/cdm/utilities/slicing" rel="nofollow noreferrer">GitHub</a>.</p>

<p>The one you should looking at is <a href="https://github.com/nctoolbox/nctoolbox/blob/master/cdm/utilities/slicing/vsliceg.m" rel="nofollow noreferrer">vsliceg.m</a>.</p>

<p>You can follow the logic there or develop your own.</p>

CC BY-SA 3.0
2017-08-02T00:12:03.880Z
from a quick look, it seems that the script interpolates the values between the grid points? Do you think that it is appropriate? I do not think that we can extract information below the resolution of the model. Otherwise, we would not need to increase the resolution in the first place. I'd prefer to just take the value at the grid point closest to the section.
shamalaia
CC BY-SA 3.0
2017-08-02T00:26:27.400Z
The issue is that a lot of model solutions use discretizations such as Arakawa-C (https://en.wikipedia.org/wiki/Arakawa_grids#Arakawa_C-grid) that calculate different fields at different locations and thus interpolation is necessary
arkaia
CC BY-SA 3.0
2017-07-31T16:16:19.010Z
2017-07-31T16:16:19.010Z
arkaia
<p>I would:</p>

<ol>
<li><p>Compute (U,V) transport on the model's C grid. This is easy if the model returns a batotropic velocity.</p></li>
<li><p>Define a set of points S along the transect. The points should have spacing comparable to the model's horizontal resolution.</p></li>
<li><p>Interpolate (U,V) transport to S. </p></li>
<li><p>Find the component of (U,V) perpendicular to your transect.</p></li>
<li><p>Iterate over model outputs. </p></li>
</ol>

<p>I can't say much about general numerical processing toolboxes. It looks like there are several for ROMS and MATLAB; google "ROMS toolbox arango" (it has been a long time since I used ROMS).</p>

CC BY-SA 3.0
2017-08-04T20:25:51.427Z
2017-08-04T20:25:51.427Z
John
<p>Suppose that I want to calculate the transport across a certain transect (green line) from the outputs of an ocean numerical model. The model has the $u$ values at the center of the grids (crosses) and the $v$ values at the corners (circles), as it uses a C-grid.</p>

<p><a href="https://i.sstatic.net/NVXSM.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/NVXSM.jpg" alt="scheme"></a></p>

<p>Should I use the velocity values closest to the transect? Should I average the values at the corners? Interpolate?</p>

<p>Side question: does anyone know some Matlab toolbox to analyze numerical model outputs?</p>

CC BY-SA 3.0
2017-07-31T02:48:09.480Z
How does this question relate to Earth Science?
Fred
CC BY-SA 3.0
2017-07-31T03:00:50.850Z
How does numerical modeling relate to Earth Science?
shamalaia
CC BY-SA 3.0
2017-07-31T03:12:10.650Z
Just because it is numerical modeling, doesn't mean the question is about Earth Science. As currently written, the question is more about mathematics & modeling, not Earth Science.
Fred
CC BY-SA 3.0
2017-07-31T07:43:22.977Z
Please don't answer with a counter question. Just [edit] some more contect into your question. And you *may* find more people being able to answer this on other SE sites, as Fred suggested (In which case, remove it here - duplicates across SE sites are not recommended).
Jan Doggen
CC BY-SA 3.0
2017-07-31T14:35:47.777Z
This question is about modelling of ocean flow (as per the edit to the question) - it seems perfectly on-topic to me. Voting to leave open.
Semidiurnal Simon
CC BY-SA 3.0
2017-07-31T23:51:39.197Z
Agree it's perfectly on topic here.  That said, it's surprising there doesn't appear to be an SE site for numerical methods or modeling, as this type of question would seem to apply across a wide range of disciplines, and boil down to mathematics.  Maybe it'd work there?
JeopardyTempest
CC BY-SA 3.0
2017-08-01T00:35:31.953Z
I do not think that it does boil down to mathematics. It depends on the specific problem. For some applications, it could be acceptable to interpolate, for others it couldn't.
shamalaia
CC BY-SA 3.0
2017-08-01T12:57:53.670Z
We tried to start an ocean and atmospheric modeling stackexchange, but it never got enough interest. Too bad. That is the reason we ended here and that is why I feel this kind of question must be on topic. Otherwise, the poor modelers (like me, sort of) would cry
arkaia
<numerical-modelling><data-analysis><matlab>
correct way to calculate transport through a section in an ocean numerical model
shamalaia
# correct way to calculate transport through a section in an ocean numerical model

(Asked by: username_0 on 2017-07-31)

Suppose that I want to calculate the transport across a certain transect (green line) from the outputs of an ocean numerical model. The model has the $u$ values at the center of the grids (crosses) and the $v$ values at the corners (circles), as it uses a C-grid.

[![scheme](https://i.sstatic.net/NVXSM.jpg)](https://i.sstatic.net/NVXSM.jpg)

Should I use the velocity values closest to the transect? Should I average the values at the corners? Interpolate?

Side question: does anyone know some Matlab toolbox to analyze numerical model outputs?

**Tags:** numerical-modelling, data-analysis, matlab

> **Comments:**
> **username_1**: How does this question relate to Earth Science?  
> **username_0**: How does numerical modeling relate to Earth Science?  
> **username_1**: Just because it is numerical modeling, doesn't mean the question is about Earth Science. As currently written, the question is more about mathematics & modeling, not Earth Science.  
> **username_2**: Please don't answer with a counter question. Just [edit] some more contect into your question. And you *may* find more people being able to answer this on other SE sites, as username_1 suggested (In which case, remove it here - duplicates across SE sites are not recommended).  
> **username_3**: This question is about modelling of ocean flow (as per the edit to the question) - it seems perfectly on-topic to me. Voting to leave open.  
> **username_4**: Agree it's perfectly on topic here.  That said, it's surprising there doesn't appear to be an SE site for numerical methods or modeling, as this type of question would seem to apply across a wide range of disciplines, and boil down to mathematics.  Maybe it'd work there?  
> **username_0**: I do not think that it does boil down to mathematics. It depends on the specific problem. For some applications, it could be acceptable to interpolate, for others it couldn't.  
> **username_5**: We tried to start an ocean and atmospheric modeling stackexchange, but it never got enough interest. Too bad. That is the reason we ended here and that is why I feel this kind of question must be on topic. Otherwise, the poor modelers (like me, sort of) would cry  

---

## 2 answers

### Answer by username_5 on 2017-07-31. Score: 2

I have been using the routines in [nctoolbox](https://github.com/nctoolbox/nctoolbox) (also check [here](http://nctoolbox.github.io/nctoolbox/)) that do all the slicing (vertical, horizontal, following a track).
The repository is in [GitHub](https://github.com/nctoolbox/nctoolbox/tree/master/cdm/utilities/slicing).

The one you should looking at is [vsliceg.m](https://github.com/nctoolbox/nctoolbox/blob/master/cdm/utilities/slicing/vsliceg.m).

You can follow the logic there or develop your own.

> **Comments:**
> **username_0**: from a quick look, it seems that the script interpolates the values between the grid points? Do you think that it is appropriate? I do not think that we can extract information below the resolution of the model. Otherwise, we would not need to increase the resolution in the first place. I'd prefer to just take the value at the grid point closest to the section.  
> **username_5**: The issue is that a lot of model solutions use discretizations such as Arakawa-C (https://en.wikipedia.org/wiki/Arakawa_grids#Arakawa_C-grid) that calculate different fields at different locations and thus interpolation is necessary  

---

### Answer by username_6 on 2017-08-04. Score: 1

I would:

1. Compute (U,V) transport on the model's C grid. This is easy if the model returns a batotropic velocity.
2. Define a set of points S along the transect. The points should have spacing comparable to the model's horizontal resolution.
3. Interpolate (U,V) transport to S.
4. Find the component of (U,V) perpendicular to your transect.
5. Iterate over model outputs.

I can't say much about general numerical processing toolboxes. It looks like there are several for ROMS and MATLAB; google "ROMS toolbox arango" (it has been a long time since I used ROMS).


---

