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

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

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


Revision 1.1 - (hide annotations) (download)
Thu Jan 17 15:57:50 2002 UTC (22 years, 4 months ago) by adcroft
Branch: MAIN
CVS Tags: checkpoint46n_post, checkpoint51k_post, checkpoint47e_post, checkpoint52l_pre, checkpoint44e_post, hrcube4, hrcube5, checkpoint46l_post, checkpoint46g_pre, checkpoint47c_post, checkpoint50c_post, checkpoint46f_post, checkpoint52d_pre, checkpoint48e_post, checkpoint50c_pre, checkpoint44f_post, checkpoint46b_post, checkpoint52j_pre, checkpoint51o_pre, checkpoint51l_post, checkpoint48i_post, checkpoint46l_pre, checkpoint52l_post, checkpoint52k_post, chkpt44d_post, checkpoint51, checkpoint50, checkpoint53, checkpoint52, checkpoint50d_post, checkpoint52f_post, checkpoint50b_pre, checkpoint44e_pre, checkpoint51f_post, checkpoint48b_post, checkpoint51d_post, checkpoint48c_pre, checkpoint47d_pre, checkpoint51t_post, checkpoint51n_post, checkpoint52i_pre, hrcube_1, hrcube_2, hrcube_3, checkpoint51s_post, checkpoint47a_post, checkpoint48d_pre, checkpoint51j_post, checkpoint47i_post, checkpoint52e_pre, checkpoint52e_post, checkpoint51n_pre, checkpoint47d_post, checkpoint46d_pre, checkpoint48d_post, checkpoint48f_post, checkpoint45d_post, checkpoint52b_pre, checkpoint46j_pre, checkpoint51l_pre, checkpoint52m_post, chkpt44a_post, checkpoint44h_pre, checkpoint48h_post, checkpoint51q_post, checkpoint51b_pre, checkpoint46a_post, checkpoint47g_post, checkpoint52b_post, checkpoint52c_post, checkpoint46j_post, checkpoint51h_pre, checkpoint46k_post, chkpt44c_pre, checkpoint48a_post, checkpoint45a_post, checkpoint50f_post, checkpoint50a_post, checkpoint50f_pre, checkpoint52f_pre, checkpoint47j_post, checkpoint53c_post, branch-exfmods-tag, checkpoint44g_post, branchpoint-genmake2, checkpoint46e_pre, checkpoint51r_post, checkpoint48c_post, checkpoint45b_post, checkpoint46b_pre, checkpoint51i_post, release1_final_v1, checkpoint51b_post, checkpoint51c_post, checkpoint46c_pre, checkpoint53a_post, checkpoint46, checkpoint47b_post, checkpoint44b_post, checkpoint46h_pre, checkpoint52d_post, checkpoint46m_post, checkpoint46a_pre, checkpoint50g_post, checkpoint45c_post, checkpoint44h_post, checkpoint46g_post, checkpoint52a_pre, checkpoint50h_post, checkpoint52i_post, checkpoint50e_pre, checkpoint50i_post, checkpoint51i_pre, checkpoint52h_pre, checkpoint52j_post, checkpoint47f_post, checkpoint50e_post, chkpt44a_pre, checkpoint46i_post, checkpoint46c_post, branch-netcdf, checkpoint50d_pre, checkpoint52n_post, checkpoint53b_pre, checkpoint46e_post, checkpoint51e_post, checkpoint44b_pre, checkpoint47, checkpoint44, checkpoint45, checkpoint48, checkpoint49, checkpoint46h_post, checkpoint51o_post, checkpoint51f_pre, chkpt44c_post, checkpoint48g_post, checkpoint53b_post, checkpoint47h_post, checkpoint52a_post, checkpoint44f_pre, checkpoint51g_post, ecco_c52_e35, checkpoint46d_post, checkpoint50b_post, checkpoint51m_post, checkpoint53d_pre, checkpoint51a_post, checkpoint51p_post, checkpoint51u_post
Branch point for: branch-exfmods-curt, release1_final, branch-genmake2, release1, branch-nonh, tg2-branch, ecco-branch, netcdf-sm0, checkpoint51n_branch
Created matlab scripts for calculating in-situ density in same way
as model.

1 adcroft 1.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