-
Notifications
You must be signed in to change notification settings - Fork 12
/
relhumid.m
54 lines (45 loc) · 1.48 KB
/
relhumid.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
function rh=relhumid(Td,Tw,P,p_typ)
% RELHUMID: finds relative humidity from wet/dry thermometer readings.
% rh=relhumid(Td,Tw,Pa,type) computes the relative humidity from
% wt and dry-bulb temperature measurements using the psychrometric eqn.
% and constants from Sargent (1980), Meteorol. Mag. 109, 238-246. The
% latter two inputs are optional.
%
% INPUTS : Td - dry bulb thermometer [C]
% Tw - wet thermometer [C]
% Pa - air pressure (optional) [mb]
% type - 'assman' for Assman-type forced ventilation
% 'screen' for standard screen (natural ventilation)
%
% OUTPUT: rh - relative humidity [%]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 8/28/98: version 1.1 (contributed by RP)
% 8/5/99: version 2.0
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
as_consts;
if nargin==2,
P=P_default;
p_typ=psych_default;
elseif nargin==3,
if isstr(P),
p_typ=P;
P=P_default;
else
p_typ=psych_default;
end;
end;
% psychrometric coefficient
switch p_typ,
case 'screen',
A=0.000799; % natural screens
case 'assman',
A = 0.000667; % Assmann-type with forced ventilation
otherwise
error(['unknown psychrometer type: ' p_typ]);
end;
% compute saturation vapour pressure for both temps.
ed=satvap(Td,P);
ewp=satvap(Tw,P);
% The psychrometric eqn!
e = ewp - A*P.*(Td-Tw); % ambient vapour pressure
rh= e./ed * 100;