/[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.1.2.1 - (show annotations) (download)
Wed Feb 6 15:48:10 2002 UTC (22 years ago) by heimbach
Branch: ecco-branch
CVS Tags: ecco_c50_e32, ecco_c50_e33, ecco_c50_e30, ecco_c50_e31, ecco_c51_e34d, ecco_c51_e34e, ecco_c51_e34f, ecco_c51_e34g, ecco_c51_e34a, ecco_c51_e34b, ecco_c51_e34c, icebear5, icebear4, icebear3, icebear2, ecco_c50_e29, ecco_c50_e28, ecco_c44_e19, ecco_c44_e18, ecco_c44_e17, ecco_c44_e16, ecco_c50_e33a, ecco_c51_e34, ecco_ice2, ecco_ice1, ecco_c44_e22, ecco_c44_e25, ecco_c44_e23, ecco_c44_e20, ecco_c44_e21, ecco_c44_e26, ecco_c44_e27, ecco_c44_e24, ecco-branch-mod2, ecco-branch-mod3, ecco-branch-mod4, ecco-branch-mod5
Branch point for: c24_e25_ice, icebear
Changes since 1.1: +0 -0 lines
Updating ecco-branch-mod1 to checkpoint44.
Will be tagged ecco-branch-mod2.

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 if size(t) ~= size(s)
20 error('T and S must be the same shape and size')
21 end
22 %if size(t,ndims(t)) ~= size(poly3,2)
23 % error('Last dimension of T and S must be the number of levels in P')
24 %end
25
26 n=size(t);
27 nz=size(poly3,2);
28
29 t=reshape(t,[prod(size(t))/nz nz]);
30 s=reshape(s,[prod(size(t))/nz nz]);
31
32 for k=1:nz,
33 tRef=poly3(k).t;
34 sRef=poly3(k).s;
35 dRef=poly3(k).dens;
36 tp=t(:,k)-tRef;
37 sp=s(:,k)-sRef;
38
39 deltaSig= ...
40 poly3(k).coeffs(1) .*tp ...
41 +poly3(k).coeffs(2) .*sp ...
42 +poly3(k).coeffs(3) .*tp.*tp ...
43 +poly3(k).coeffs(4) .*tp .*sp ...
44 +poly3(k).coeffs(5) .*sp.*sp ...
45 +poly3(k).coeffs(6) .*tp.*tp.*tp ...
46 +poly3(k).coeffs(7) .*tp.*tp .*sp ...
47 +poly3(k).coeffs(8) .*tp .*sp.*sp ...
48 +poly3(k).coeffs(9) .*sp.*sp.*sp ...
49 ;
50 dens(:,k)=deltaSig+dRef;
51 end
52
53 dens=reshape(dens,n);

  ViewVC Help
Powered by ViewVC 1.1.22