Calculation of river discharge with ROMS outputs
Calculation of river discharge with ROMS outputs
I am calculating the river discharge with ROMS output. But the river discharge I acquired was not smooth along the channel. I have tried to look for many reasons, but they did not work. Does anyone come across the same problem as mine?
Thank you for your time.
Below is my main code. I calculate the river discharge by using matlab:
%%%the size of v is [38(cross-channel) 643(along-channel) 16(vertical) 60(time(hours))] and zeta is [38 644 60]
%%%I make 25 hours averaged to be the tidally averaged
pm=get_var(cdf_info,'pm');
vbar=get_var(cdf_info,'vbar');
zeta=denanize(zeta,0); %%%to make the nan to 0
vbar=denanize(vbar,0);
hv=(h(:,1:643)+h(:,2:644))/2;
dxv=2./(pm(:,1:643)+pm(:,2:644));
zetav=(zeta(:,1:643,:)+zeta(:,2:644,:))/2;
Q=squeeze(sum(vbar.*(repmat(hv,[1,1,60])+zetav).*repmat(dxv,[1,1,60])));
Qr=meang(Q(:,1:25),2);
Re: Calculation of river discharge with ROMS outputs
I have found why there are so many peaks. Because u(1,:,:,:) are zeros even not in land. And I checked the depth-averaged continuity equation for the grid (1,400). It is not closed just because of ubar(1,400,:) are zeros. For other grids, such as grid (2,400),the depth-averaged continuity equation is closed. Just like the attachment.
So why the u(1,:,:,:) in output are zeros, even not in land.
Thank you very much.
Yours sincerely,
Tao
Re: Calculation of river discharge with ROMS outputs
The size of ubar is (37,644,60) and zeta is (38,644,60). zeta(1,:,:) are not zeros when there are no lands. So I don't think ubar(1,:,:) is the boundary.
Re: Calculation of river discharge with ROMS outputs
In ROMS, variables are dimensioned for a staggered grid, the numbering starting at i=0 for some, at i=1 for others. This is possible to do in Fortran. When reading ROMS input into other tools like Python and Matlab, all variables start with the same index. I don't remember what it is in Matlab, but in C and Python, all variables start at i=0. That means that preprocessing code must take that into account: the range of u indices becomes 0 to 36 instead of 1 to 37 while the zeta indices remain 0 to 37 for 38 values.
Re: Calculation of river discharge with ROMS outputs
So does it mean ubar(1,:,:) in Matlab is the same as ubar(0,:,:) in Fortran? In the output, the length of the first dimension of u is 37, and zeta is 38.I think the positions of u and zeta in output are like the figure I upload. Am I right? If I am right, the problem is that, u(1,:) are all zeros, but zeta(1,:) and v(1,:) are not zeros. And when I calculate the continuity equation for the grids in the first row,such as grid (1,2), the continuity equation is not closed.
Re: Calculation of river discharge with ROMS outputs
The ROMS view is shown here:
Re: Calculation of river discharge with ROMS outputs
The grids I sent is in matlab.Maybe there is something wrong in the output data. Thank you very much for your help, Kate.