/[MITgcm]/MITgcm/utils/matlab/dens_poly3.m
ViewVC logotype

Contents of /MITgcm/utils/matlab/dens_poly3.m

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.3 - (show annotations) (download)
Sat Feb 17 23:49:43 2007 UTC (17 years, 2 months ago) by jmc
Branch: MAIN
CVS Tags: checkpoint62v, checkpoint62u, checkpoint62t, checkpoint65z, checkpoint65x, checkpoint65y, checkpoint65r, checkpoint65s, checkpoint65p, checkpoint65q, checkpoint65v, checkpoint65w, checkpoint65t, checkpoint65u, checkpoint65j, checkpoint65k, checkpoint65h, checkpoint65i, checkpoint65n, checkpoint65l, checkpoint65m, checkpoint65b, checkpoint65c, checkpoint65a, checkpoint65f, checkpoint65g, checkpoint65d, checkpoint65e, checkpoint62c, checkpoint59, checkpoint62s, checkpoint62r, checkpoint62q, checkpoint62p, checkpoint62a, checkpoint62g, checkpoint62f, checkpoint62e, checkpoint62d, checkpoint62k, checkpoint62j, checkpoint62i, checkpoint62h, checkpoint62o, checkpoint62n, checkpoint62m, checkpoint62l, checkpoint62w, checkpoint62z, checkpoint62y, checkpoint62x, checkpoint58y_post, checkpoint63g, checkpoint64, checkpoint65, checkpoint60, checkpoint61, checkpoint62, checkpoint63, checkpoint66g, checkpoint66f, checkpoint66e, checkpoint66d, checkpoint66c, checkpoint66b, checkpoint66a, checkpoint66o, checkpoint66n, checkpoint66m, checkpoint66l, checkpoint66k, checkpoint66j, checkpoint66i, checkpoint66h, checkpoint58w_post, checkpoint63p, checkpoint63q, checkpoint63r, checkpoint63s, checkpoint63l, checkpoint63m, checkpoint63n, checkpoint63o, checkpoint63h, checkpoint63i, checkpoint63j, checkpoint63k, checkpoint63d, checkpoint63e, checkpoint63f, checkpoint63a, checkpoint63b, checkpoint63c, checkpoint65o, checkpoint59q, checkpoint59p, checkpoint59r, checkpoint59e, checkpoint59d, checkpoint59g, checkpoint59f, checkpoint59a, checkpoint59c, checkpoint59b, checkpoint59m, checkpoint59l, checkpoint59o, checkpoint59n, checkpoint59i, checkpoint59h, checkpoint59k, checkpoint62b, checkpoint64y, checkpoint64x, checkpoint64z, checkpoint64q, checkpoint64p, checkpoint64s, checkpoint64r, checkpoint64u, checkpoint64t, checkpoint64w, checkpoint64v, checkpoint64i, checkpoint64h, checkpoint64k, checkpoint64j, checkpoint64m, checkpoint64l, checkpoint64o, checkpoint64n, checkpoint64a, checkpoint64c, checkpoint64b, checkpoint64e, checkpoint64d, checkpoint64g, checkpoint64f, checkpoint61f, checkpoint58x_post, checkpoint61n, checkpoint59j, checkpoint61q, checkpoint61e, checkpoint61g, checkpoint61d, checkpoint61b, checkpoint61c, checkpoint61a, checkpoint61o, checkpoint61l, checkpoint61m, checkpoint61j, checkpoint61k, checkpoint61h, checkpoint61i, checkpoint61v, checkpoint61w, checkpoint61t, checkpoint61u, checkpoint61r, checkpoint61s, checkpoint61p, checkpoint61z, checkpoint61x, checkpoint61y, HEAD
Changes since 1.2: +3 -0 lines
add $Header:  $ and $Name:  & (for CVS)

1 function [dens] = dens_poly3(poly3,t,s)
2 % D=DENS_POLY3(P,T,S)
3 %
4 % Calculates in-situ density as approximated by the POLY3 method
5 % used in the MITgcm.
6 % P - coefficients read from file 'POLY3.COEFFS' using INI_POLY3
7 % T - potential temperature
8 % S - salinity
9 %
10 % eg.
11 % >> P=ini_poly3;
12 % >> T=rdmds('T',100);
13 % >> S=rdmds('S',100);
14 % >> D=dens_poly3(P,T,S);
15 %
16 % or to work within a single model level
17 % >> D=dens_poly3(P(3),T(:,:,3),S(:,:,3));
18
19 % $Header: $
20 % $Name: $
21
22 if size(t) ~= size(s)
23 error('T and S must be the same shape and size')
24 end
25 %if size(t,ndims(t)) ~= size(poly3,2)
26 % error('Last dimension of T and S must be the number of levels in P')
27 %end
28
29 n=size(t);
30 nz=size(poly3,2);
31
32 t=reshape(t,[prod(size(t))/nz nz]);
33 s=reshape(s,[prod(size(t))/nz nz]);
34
35 for k=1:nz,
36 tRef=poly3(k).t;
37 sRef=poly3(k).s;
38 dRef=poly3(k).dens;
39 tp=t(:,k)-tRef;
40 sp=s(:,k)-sRef;
41
42 deltaSig= ...
43 poly3(k).coeffs(1) .*tp ...
44 +poly3(k).coeffs(2) .*sp ...
45 +poly3(k).coeffs(3) .*tp.*tp ...
46 +poly3(k).coeffs(4) .*tp .*sp ...
47 +poly3(k).coeffs(5) .*sp.*sp ...
48 +poly3(k).coeffs(6) .*tp.*tp.*tp ...
49 +poly3(k).coeffs(7) .*tp.*tp .*sp ...
50 +poly3(k).coeffs(8) .*tp .*sp.*sp ...
51 +poly3(k).coeffs(9) .*sp.*sp.*sp ...
52 ;
53 dens(:,k)=deltaSig+dRef;
54 end
55
56 dens=reshape(dens,n);
57 dens( find(t==0 & s==0) )=0;

  ViewVC Help
Powered by ViewVC 1.1.22