[MITgcm-support] question about Cartesian Grid in Matlab
Martin Losch
Martin.Losch at awi.de
Mon Mar 4 06:11:11 EST 2013
Yang,
I am not sure if this is the problem, but matlab and the MITgcm (FORTRAN) have different ideas about the order of the dimensions. When I plot Eta, I do this:
xc = rdmds('XC');
yc = rdmds('YC');
Eta = rdmds('Eta',Inf);
contour(xc',yc',Eta')
Note that you need to transpose all fields, because matlab thinks that the first index is the row index, while MITgcm uses it as the column index.
for velocities, keep in mind that they are not collocated, so if you want to be precise you'll have to average them to C-points (where Eta is defined) before plotting them, e.g.:
u = rdmds('U',Inf);
v = rdmds('V',Inf);
w = rdmds('W',Inf);
uc = 0.5* ( u + u([2:end 1],:) );
vc = 0.5* ( v + v([2:end 1],:) );
contour(xc',yc',w')
hold on
quiver(xc,yc,uc,vc)
hold off
Note that quiver does not care about the regular arrangement on a grid and plots (uc(:),vc(:)) at the position (xc(:),yc(:)), so that a quiver plot will always have the correct orientation, but w is a "scalar" in this context and needs to be transposed.
M.
On Mar 2, 2013, at 7:54 PM, yang.zhang <yang.zhang at mun.ca> wrote:
> Hello, Colleagues
> I have a Tutorial_barotropic_gyre result here to show question (I am quite new in MITgcm);
> The wind force is from the west to the east with a Sine variation in south-north direction;
> I draw the wind force in 'Barotropic Gyre1 tif' in the attachment.
>
> So the wind-driven flow is like 'Barotropic Gyre2 tif' in the attachment. The contour is Eta(sea surface height);
> They both seems good; But the vertical velocity W in 'Barotropic Gyre3 tif' confused me a lot, Because a anti-clockwise gyre in the north should has a UPwelling effect (Positive W); and It should be a Downwelling (Negative W) in south because of the clockwise gyre in the south. But 'Barotropic Gyre3.tif' gives opposite.
>
> if Xc, Yc are the grid file for U V output:
> These pictures in the attachment is drawn in Matlab like this:
> contour(Xc,Yc,Eta);
> hold on;
> quiver(Xc,Yc,U,V)
>
> Barotropic Gyre4 tif is made by this:
> contour(Eta);
> hold on;
> quiver(U,V);
> It gives a reasonable result: the divergence results in Positive W; while the convergence gives Negative W.
>
> I don't know which kind of plot is right? or they are both right?
> Any reply will be appreciated!
>
> Yang
>
>
>
>
> <Barotropic Gyre2.tif><Barotropic Gyre1.tif><Barotropic Gyre3.tif><Barotropic Gyre4.tif>_______________________________________________
> MITgcm-support mailing list
> MITgcm-support at mitgcm.org
> http://mitgcm.org/mailman/listinfo/mitgcm-support
More information about the MITgcm-support
mailing list