/[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.2 - (show annotations) (download)
Fri Jun 4 17:09:11 2004 UTC (19 years, 11 months ago) by adcroft
Branch: MAIN
CVS Tags: checkpoint57m_post, checkpoint57g_pre, checkpoint57s_post, checkpoint58b_post, checkpoint57b_post, checkpoint57g_post, checkpoint56b_post, checkpoint57y_post, checkpoint54d_post, checkpoint54e_post, checkpoint57r_post, checkpoint57d_post, checkpoint57i_post, checkpoint58, checkpoint55, checkpoint54, checkpoint57, checkpoint56, checkpoint58f_post, checkpoint57n_post, checkpoint58d_post, checkpoint58a_post, checkpoint57z_post, checkpoint54f_post, checkpoint58t_post, checkpoint55i_post, checkpoint58m_post, checkpoint57l_post, checkpoint57t_post, checkpoint55c_post, checkpoint57v_post, checkpoint57f_post, checkpoint53d_post, checkpoint57a_post, checkpoint57h_pre, checkpoint54b_post, checkpoint57h_post, checkpoint57y_pre, checkpoint55g_post, checkpoint58o_post, checkpoint57c_post, checkpoint58p_post, checkpoint58q_post, checkpoint55d_post, checkpoint58e_post, checkpoint54a_pre, checkpoint55d_pre, checkpoint57c_pre, checkpoint58r_post, checkpoint55j_post, checkpoint54a_post, checkpoint55h_post, checkpoint58n_post, checkpoint57e_post, checkpoint55b_post, checkpoint55f_post, checkpoint53g_post, checkpoint57p_post, checkpint57u_post, checkpoint57q_post, eckpoint57e_pre, checkpoint58k_post, checkpoint58v_post, checkpoint56a_post, checkpoint58l_post, checkpoint53f_post, checkpoint57h_done, checkpoint57j_post, checkpoint57f_pre, checkpoint58g_post, checkpoint58h_post, checkpoint56c_post, checkpoint58j_post, checkpoint57a_pre, checkpoint55a_post, checkpoint57o_post, checkpoint57k_post, checkpoint57w_post, checkpoint58i_post, checkpoint57x_post, checkpoint58c_post, checkpoint58u_post, checkpoint58s_post, checkpoint55e_post, checkpoint54c_post
Changes since 1.1: +1 -0 lines
Tidy up

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);
54 dens( find(t==0 & s==0) )=0;

  ViewVC Help
Powered by ViewVC 1.1.22