NCCOOS Trac Projects: Top | Web | Platforms | Processing | Viz | Sprints | Sandbox | (Wind)

root/gliderproc/trunk/MATLAB/seawater/sw_alpha.m

Revision 495 (checked in by cbc, 11 years ago)

Initial import of Stark code.

Line 
1
2 function [ALPHA] = sw_alpha(S, T, P, keyword)
3
4 % SW_ALPHA   Thermal expansion coefficient (alpha)
5 %================================================================
6 % SW_ALPHA  $Id: sw_alpha.m,v 1.1 2003/12/12 04:23:22 pen078 Exp $
7 %           Copyright (C) CSIRO, Nathan Bindoff 1993.
8 %
9 % USAGE:  [ALPHA] = alpha(S, T, P, keyword)
10 %
11 %         [ALPHA] = alpha(S, T,    P, 'temp')    %default
12 %         [ALPHA] = alpha(S, PTMP, P, 'ptmp')
13 %
14 % DESCRIPTION:
15 %    A function to calculate the thermal expansion coefficient.
16 %
17 % INPUT:
18 %   S       = salinity              [psu      (PSS-78) ]
19 % * PTMP    = potential temperature [degree C (ITS-90)]
20 % * T       = temperature           [degree C (ITS-90)]
21 %   P       = pressure              [db]
22 %             (P may have dims 1x1, mx1, 1xn or mxn for S(mxn) )
23 %
24 %   keyword = optional string to identify if temp or ptmp passed.
25 %           = No argument defaults to 'temp'
26 %           = 'temp' assumes (S,T,P) passed.    Will execute slower
27 %                    as ptmp will be calculated internally.
28 %           = 'ptmp' assumes (S,PTMP,P) passed. Will execute faster.
29 %
30 % OUTPUT:
31 %   ALPHA = Thermal expansion coeff (alpha) [degree_C.^-1]
32 %
33 % AUTHOR:   N.L. Bindoff  1993, Lindsay Pender (Lindsay.Pender@csiro.au)
34 %
35 % DISCLAIMER:
36 %   This software is provided "as is" without warranty of any kind.
37 %   See the file sw_copy.m for conditions of use and licence.
38 %
39 % REFERENCE:
40 %    McDougall, T.J. 1987.  "Neutral Surfaces"
41 %    Journal of Physical Oceanography vol 17 pages 1950-1964,
42 %
43 % CHECK VALUE:
44 %    See sw_beta.m amd sw_aonb.m
45 %================================================================
46
47 % Modifications
48 % 93-04-22. Phil Morgan,  Help display modified to suit library
49 % 93-04-23. Phil Morgan,  Input argument checking
50 % 94-10-15. Phil Morgan,  Pass S,T,P and keyword for 'ptmp'
51 % 99-06-25. Lindsay Pender, Fixed transpose of row vectors.
52 % 03-12-12. Lindsay Pender, Converted to ITS-90.
53
54 % CHECK INPUT ARGUMENTS
55 if ~(nargin==3 | nargin==4)
56   error('sw_alpha.m: requires 3 or 4 input arguments')
57 end %if
58 if nargin == 3
59   keyword = 'temp';
60 end %if
61
62 % CHECK S,T,P dimensions and verify consistent
63 [ms,ns] = size(S);
64 [mt,nt] = size(T);
65 [mp,np] = size(P);
66
67
68 % CHECK THAT S & T HAVE SAME SHAPE
69 if (ms~=mt) | (ns~=nt)
70    error('check_stp: S & T must have same dimensions')
71 end %if
72
73 % CHECK OPTIONAL SHAPES FOR P
74 if     mp==1  & np==1      % P is a scalar.  Fill to size of S
75    P = P(1)*ones(ms,ns);
76 elseif np==ns & mp==1      % P is row vector with same cols as S
77    P = P( ones(1,ms), : ); %   Copy down each column.
78 elseif mp==ms & np==1      % P is column vector
79    P = P( :, ones(1,ns) ); %   Copy across each row
80 elseif mp==ms & np==ns     % PR is a matrix size(S)
81    % shape ok
82 else
83    error('check_stp: P has wrong dimensions')
84 end %if
85
86 %***check_stp
87
88 % BEGIN
89
90 ALPHA = sw_aonb(S,T,P,keyword).*sw_beta(S,T,P,keyword);
91
92 return
93 %------------------------------------------------------------------------
94
95
Note: See TracBrowser for help on using the browser.